cocoa-py 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cocoa_py-0.1.0a1/LICENSE +21 -0
- cocoa_py-0.1.0a1/MANIFEST.in +4 -0
- cocoa_py-0.1.0a1/PKG-INFO +104 -0
- cocoa_py-0.1.0a1/README.md +82 -0
- cocoa_py-0.1.0a1/cocoa_py.egg-info/PKG-INFO +104 -0
- cocoa_py-0.1.0a1/cocoa_py.egg-info/SOURCES.txt +14 -0
- cocoa_py-0.1.0a1/cocoa_py.egg-info/dependency_links.txt +1 -0
- cocoa_py-0.1.0a1/cocoa_py.egg-info/requires.txt +3 -0
- cocoa_py-0.1.0a1/cocoa_py.egg-info/top_level.txt +1 -0
- cocoa_py-0.1.0a1/native/coreml/CoreMLModule.h +16 -0
- cocoa_py-0.1.0a1/native/coreml/CoreMLModule.mm +952 -0
- cocoa_py-0.1.0a1/pyproject.toml +30 -0
- cocoa_py-0.1.0a1/setup.cfg +4 -0
- cocoa_py-0.1.0a1/setup.py +56 -0
- cocoa_py-0.1.0a1/tests/CoreMLFixtures/CoreMLFixtures.zip +0 -0
- cocoa_py-0.1.0a1/tests/test_coreml.py +115 -0
cocoa_py-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yosorable
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cocoa-py
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Native Apple platform modules for Python; initial Core ML preview
|
|
5
|
+
Author: Yosorable
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: apple,macos,coreml,native,inference
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
14
|
+
Classifier: Programming Language :: Objective C
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Requires-Python: <3.15,>=3.14
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Provides-Extra: coreml
|
|
20
|
+
Requires-Dist: numpy<3,>=2.3.3; extra == "coreml"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# cocoa-py
|
|
24
|
+
|
|
25
|
+
Native Apple platform modules for Python, extracted from Pythona and designed
|
|
26
|
+
to be used independently of the app.
|
|
27
|
+
|
|
28
|
+
## Preview status
|
|
29
|
+
|
|
30
|
+
**Version 0.1.0a1 contains the standalone `coreml` extension only.** It provides
|
|
31
|
+
Core ML model compilation, inspection, and inference on macOS. The `audio`,
|
|
32
|
+
`scene`, `photos`, and other system modules are planned for subsequent previews
|
|
33
|
+
and are not included in this release.
|
|
34
|
+
|
|
35
|
+
This preview targets macOS 14 or later and standard CPython 3.14 with the GIL.
|
|
36
|
+
An Apple Silicon wheel is provided. The source distribution requires Apple's
|
|
37
|
+
Xcode command-line tools and the macOS SDK to build.
|
|
38
|
+
|
|
39
|
+
The source originated in an iOS app, but this preview does not yet provide an
|
|
40
|
+
iOS embedding package or integration instructions.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
python3.14 -m pip install 'cocoa-py[coreml]==0.1.0a1'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The `coreml` extra installs NumPy, which the native extension needs at runtime.
|
|
49
|
+
The distribution name is `cocoa-py`; the public module is imported directly:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import coreml
|
|
53
|
+
import numpy as np
|
|
54
|
+
|
|
55
|
+
compiled_path = coreml.compile("model.mlpackage")
|
|
56
|
+
model = coreml.load(compiled_path, compute_units="all")
|
|
57
|
+
print(coreml.describe(model))
|
|
58
|
+
|
|
59
|
+
# Replace the input name, shape and dtype with those required by your model.
|
|
60
|
+
result = coreml.predict(model, {"input": np.zeros((1, 3, 224, 224), dtype=np.float32)})
|
|
61
|
+
print(result)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Models are supplied by the caller. Importing `coreml` initializes its NumPy
|
|
65
|
+
interface; models are compiled or loaded only by explicit API calls.
|
|
66
|
+
|
|
67
|
+
## API
|
|
68
|
+
|
|
69
|
+
| Function | Purpose |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `compile(model_path, output_dir=None)` | Compile a `.mlmodel` or `.mlpackage`, returning the `.mlmodelc` directory. |
|
|
72
|
+
| `load(path, compute_units="all")` | Load a compiled model and return a `Model` handle. |
|
|
73
|
+
| `describe(model)` | Inspect model inputs and outputs, including shapes and data types. |
|
|
74
|
+
| `predict(model, inputs)` | Run inference with a dictionary of named inputs. |
|
|
75
|
+
| `batch_predict(model, inputs_list)` | Run a batch of input dictionaries. |
|
|
76
|
+
| `metadata(model)` | Read author, version, license and description metadata. |
|
|
77
|
+
|
|
78
|
+
`compute_units` accepts `all`, `cpuAndNeuralEngine`, `cpuAndGPU`, or `cpuOnly`.
|
|
79
|
+
The system chooses available hardware within that selection.
|
|
80
|
+
|
|
81
|
+
Tensor inputs support NumPy `float16`, `float32`, `float64`, and `int32` arrays.
|
|
82
|
+
Color image inputs use `uint8` RGB or RGBA arrays; grayscale images use `uint8`
|
|
83
|
+
or `float16` according to the model. Color image outputs use RGBA. Tensor
|
|
84
|
+
outputs preserve their supported dtype and are returned as contiguous arrays.
|
|
85
|
+
Scalar inputs may be integers, floats, or strings where accepted by the model.
|
|
86
|
+
|
|
87
|
+
This API provides stateless inference. Stateful models, model updates, and
|
|
88
|
+
sequence inputs and outputs are not exposed by this preview.
|
|
89
|
+
|
|
90
|
+
## Build and test
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
python3.14 -m pip install build
|
|
94
|
+
MACOSX_DEPLOYMENT_TARGET=14.0 python3.14 -m build
|
|
95
|
+
python3.14 -m pip install --force-reinstall '.[coreml]'
|
|
96
|
+
python3.14 -m unittest discover -s tests -v
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The source distribution includes small generated test models. Tests exercise
|
|
100
|
+
real Core ML compilation and inference on the Mac; no simulator is required.
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT. Copyright (c) 2026 Yosorable.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# cocoa-py
|
|
2
|
+
|
|
3
|
+
Native Apple platform modules for Python, extracted from Pythona and designed
|
|
4
|
+
to be used independently of the app.
|
|
5
|
+
|
|
6
|
+
## Preview status
|
|
7
|
+
|
|
8
|
+
**Version 0.1.0a1 contains the standalone `coreml` extension only.** It provides
|
|
9
|
+
Core ML model compilation, inspection, and inference on macOS. The `audio`,
|
|
10
|
+
`scene`, `photos`, and other system modules are planned for subsequent previews
|
|
11
|
+
and are not included in this release.
|
|
12
|
+
|
|
13
|
+
This preview targets macOS 14 or later and standard CPython 3.14 with the GIL.
|
|
14
|
+
An Apple Silicon wheel is provided. The source distribution requires Apple's
|
|
15
|
+
Xcode command-line tools and the macOS SDK to build.
|
|
16
|
+
|
|
17
|
+
The source originated in an iOS app, but this preview does not yet provide an
|
|
18
|
+
iOS embedding package or integration instructions.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
python3.14 -m pip install 'cocoa-py[coreml]==0.1.0a1'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The `coreml` extra installs NumPy, which the native extension needs at runtime.
|
|
27
|
+
The distribution name is `cocoa-py`; the public module is imported directly:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import coreml
|
|
31
|
+
import numpy as np
|
|
32
|
+
|
|
33
|
+
compiled_path = coreml.compile("model.mlpackage")
|
|
34
|
+
model = coreml.load(compiled_path, compute_units="all")
|
|
35
|
+
print(coreml.describe(model))
|
|
36
|
+
|
|
37
|
+
# Replace the input name, shape and dtype with those required by your model.
|
|
38
|
+
result = coreml.predict(model, {"input": np.zeros((1, 3, 224, 224), dtype=np.float32)})
|
|
39
|
+
print(result)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Models are supplied by the caller. Importing `coreml` initializes its NumPy
|
|
43
|
+
interface; models are compiled or loaded only by explicit API calls.
|
|
44
|
+
|
|
45
|
+
## API
|
|
46
|
+
|
|
47
|
+
| Function | Purpose |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| `compile(model_path, output_dir=None)` | Compile a `.mlmodel` or `.mlpackage`, returning the `.mlmodelc` directory. |
|
|
50
|
+
| `load(path, compute_units="all")` | Load a compiled model and return a `Model` handle. |
|
|
51
|
+
| `describe(model)` | Inspect model inputs and outputs, including shapes and data types. |
|
|
52
|
+
| `predict(model, inputs)` | Run inference with a dictionary of named inputs. |
|
|
53
|
+
| `batch_predict(model, inputs_list)` | Run a batch of input dictionaries. |
|
|
54
|
+
| `metadata(model)` | Read author, version, license and description metadata. |
|
|
55
|
+
|
|
56
|
+
`compute_units` accepts `all`, `cpuAndNeuralEngine`, `cpuAndGPU`, or `cpuOnly`.
|
|
57
|
+
The system chooses available hardware within that selection.
|
|
58
|
+
|
|
59
|
+
Tensor inputs support NumPy `float16`, `float32`, `float64`, and `int32` arrays.
|
|
60
|
+
Color image inputs use `uint8` RGB or RGBA arrays; grayscale images use `uint8`
|
|
61
|
+
or `float16` according to the model. Color image outputs use RGBA. Tensor
|
|
62
|
+
outputs preserve their supported dtype and are returned as contiguous arrays.
|
|
63
|
+
Scalar inputs may be integers, floats, or strings where accepted by the model.
|
|
64
|
+
|
|
65
|
+
This API provides stateless inference. Stateful models, model updates, and
|
|
66
|
+
sequence inputs and outputs are not exposed by this preview.
|
|
67
|
+
|
|
68
|
+
## Build and test
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
python3.14 -m pip install build
|
|
72
|
+
MACOSX_DEPLOYMENT_TARGET=14.0 python3.14 -m build
|
|
73
|
+
python3.14 -m pip install --force-reinstall '.[coreml]'
|
|
74
|
+
python3.14 -m unittest discover -s tests -v
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The source distribution includes small generated test models. Tests exercise
|
|
78
|
+
real Core ML compilation and inference on the Mac; no simulator is required.
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT. Copyright (c) 2026 Yosorable.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cocoa-py
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Native Apple platform modules for Python; initial Core ML preview
|
|
5
|
+
Author: Yosorable
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: apple,macos,coreml,native,inference
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
14
|
+
Classifier: Programming Language :: Objective C
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Requires-Python: <3.15,>=3.14
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Provides-Extra: coreml
|
|
20
|
+
Requires-Dist: numpy<3,>=2.3.3; extra == "coreml"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# cocoa-py
|
|
24
|
+
|
|
25
|
+
Native Apple platform modules for Python, extracted from Pythona and designed
|
|
26
|
+
to be used independently of the app.
|
|
27
|
+
|
|
28
|
+
## Preview status
|
|
29
|
+
|
|
30
|
+
**Version 0.1.0a1 contains the standalone `coreml` extension only.** It provides
|
|
31
|
+
Core ML model compilation, inspection, and inference on macOS. The `audio`,
|
|
32
|
+
`scene`, `photos`, and other system modules are planned for subsequent previews
|
|
33
|
+
and are not included in this release.
|
|
34
|
+
|
|
35
|
+
This preview targets macOS 14 or later and standard CPython 3.14 with the GIL.
|
|
36
|
+
An Apple Silicon wheel is provided. The source distribution requires Apple's
|
|
37
|
+
Xcode command-line tools and the macOS SDK to build.
|
|
38
|
+
|
|
39
|
+
The source originated in an iOS app, but this preview does not yet provide an
|
|
40
|
+
iOS embedding package or integration instructions.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
python3.14 -m pip install 'cocoa-py[coreml]==0.1.0a1'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The `coreml` extra installs NumPy, which the native extension needs at runtime.
|
|
49
|
+
The distribution name is `cocoa-py`; the public module is imported directly:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import coreml
|
|
53
|
+
import numpy as np
|
|
54
|
+
|
|
55
|
+
compiled_path = coreml.compile("model.mlpackage")
|
|
56
|
+
model = coreml.load(compiled_path, compute_units="all")
|
|
57
|
+
print(coreml.describe(model))
|
|
58
|
+
|
|
59
|
+
# Replace the input name, shape and dtype with those required by your model.
|
|
60
|
+
result = coreml.predict(model, {"input": np.zeros((1, 3, 224, 224), dtype=np.float32)})
|
|
61
|
+
print(result)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Models are supplied by the caller. Importing `coreml` initializes its NumPy
|
|
65
|
+
interface; models are compiled or loaded only by explicit API calls.
|
|
66
|
+
|
|
67
|
+
## API
|
|
68
|
+
|
|
69
|
+
| Function | Purpose |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `compile(model_path, output_dir=None)` | Compile a `.mlmodel` or `.mlpackage`, returning the `.mlmodelc` directory. |
|
|
72
|
+
| `load(path, compute_units="all")` | Load a compiled model and return a `Model` handle. |
|
|
73
|
+
| `describe(model)` | Inspect model inputs and outputs, including shapes and data types. |
|
|
74
|
+
| `predict(model, inputs)` | Run inference with a dictionary of named inputs. |
|
|
75
|
+
| `batch_predict(model, inputs_list)` | Run a batch of input dictionaries. |
|
|
76
|
+
| `metadata(model)` | Read author, version, license and description metadata. |
|
|
77
|
+
|
|
78
|
+
`compute_units` accepts `all`, `cpuAndNeuralEngine`, `cpuAndGPU`, or `cpuOnly`.
|
|
79
|
+
The system chooses available hardware within that selection.
|
|
80
|
+
|
|
81
|
+
Tensor inputs support NumPy `float16`, `float32`, `float64`, and `int32` arrays.
|
|
82
|
+
Color image inputs use `uint8` RGB or RGBA arrays; grayscale images use `uint8`
|
|
83
|
+
or `float16` according to the model. Color image outputs use RGBA. Tensor
|
|
84
|
+
outputs preserve their supported dtype and are returned as contiguous arrays.
|
|
85
|
+
Scalar inputs may be integers, floats, or strings where accepted by the model.
|
|
86
|
+
|
|
87
|
+
This API provides stateless inference. Stateful models, model updates, and
|
|
88
|
+
sequence inputs and outputs are not exposed by this preview.
|
|
89
|
+
|
|
90
|
+
## Build and test
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
python3.14 -m pip install build
|
|
94
|
+
MACOSX_DEPLOYMENT_TARGET=14.0 python3.14 -m build
|
|
95
|
+
python3.14 -m pip install --force-reinstall '.[coreml]'
|
|
96
|
+
python3.14 -m unittest discover -s tests -v
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The source distribution includes small generated test models. Tests exercise
|
|
100
|
+
real Core ML compilation and inference on the Mac; no simulator is required.
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT. Copyright (c) 2026 Yosorable.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
cocoa_py.egg-info/PKG-INFO
|
|
7
|
+
cocoa_py.egg-info/SOURCES.txt
|
|
8
|
+
cocoa_py.egg-info/dependency_links.txt
|
|
9
|
+
cocoa_py.egg-info/requires.txt
|
|
10
|
+
cocoa_py.egg-info/top_level.txt
|
|
11
|
+
native/coreml/CoreMLModule.h
|
|
12
|
+
native/coreml/CoreMLModule.mm
|
|
13
|
+
tests/test_coreml.py
|
|
14
|
+
tests/CoreMLFixtures/CoreMLFixtures.zip
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
coreml
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#ifndef CoreMLModule_h
|
|
2
|
+
#define CoreMLModule_h
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
/// Register the _coreml built-in Python module.
|
|
9
|
+
/// Must be called BEFORE Py_Initialize().
|
|
10
|
+
void registerCoreMLModule(void);
|
|
11
|
+
|
|
12
|
+
#ifdef __cplusplus
|
|
13
|
+
}
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#endif /* CoreMLModule_h */
|