noxpy 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.
- noxpy-0.1.0a1/LICENSE +21 -0
- noxpy-0.1.0a1/PKG-INFO +121 -0
- noxpy-0.1.0a1/README.md +96 -0
- noxpy-0.1.0a1/pyproject.toml +44 -0
- noxpy-0.1.0a1/python/noxpy/__init__.py +25 -0
- noxpy-0.1.0a1/python/noxpy/__main__.py +165 -0
- noxpy-0.1.0a1/python/noxpy/_native/cpython/noxpy_shim.c +568 -0
- noxpy-0.1.0a1/python/noxpy/_native/include/nox_host.h +77 -0
- noxpy-0.1.0a1/python/noxpy/_native/include/noxpy_abi.h +163 -0
- noxpy-0.1.0a1/python/noxpy/audit.py +190 -0
- noxpy-0.1.0a1/python/noxpy/build.py +604 -0
- noxpy-0.1.0a1/python/noxpy/codegen.py +283 -0
- noxpy-0.1.0a1/python/noxpy/config.py +220 -0
- noxpy-0.1.0a1/python/noxpy/doctor.py +145 -0
- noxpy-0.1.0a1/python/noxpy/errors.py +46 -0
- noxpy-0.1.0a1/python/noxpy/ir.py +272 -0
- noxpy-0.1.0a1/python/noxpy.egg-info/PKG-INFO +121 -0
- noxpy-0.1.0a1/python/noxpy.egg-info/SOURCES.txt +20 -0
- noxpy-0.1.0a1/python/noxpy.egg-info/dependency_links.txt +1 -0
- noxpy-0.1.0a1/python/noxpy.egg-info/entry_points.txt +2 -0
- noxpy-0.1.0a1/python/noxpy.egg-info/top_level.txt +1 -0
- noxpy-0.1.0a1/setup.cfg +4 -0
noxpy-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Melih Burak Memiş
|
|
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.
|
noxpy-0.1.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: noxpy
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Native Python extensions written in Nox. Free-threaded first (abi3t), safe by design.
|
|
5
|
+
Author: Melih Burak Memiş
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/mburakmmm/noxPY
|
|
8
|
+
Project-URL: Repository, https://github.com/mburakmmm/noxPY
|
|
9
|
+
Project-URL: Issues, https://github.com/mburakmmm/noxPY/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/mburakmmm/noxPY/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: nox,python,cpython,abi3t,free-threaded,native-extension
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: C
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
21
|
+
Requires-Python: >=3.15
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# NoxPy
|
|
27
|
+
|
|
28
|
+
[](https://github.com/mburakmmm/noxPY/actions/workflows/ci.yml)
|
|
29
|
+
[](https://github.com/mburakmmm/noxPY/actions/workflows/release.yml)
|
|
30
|
+
[](LICENSE)
|
|
31
|
+
[](https://docs.python.org/3.15/)
|
|
32
|
+
[](docs/adr/0001-cpython-315-dual-abi3t.md)
|
|
33
|
+
[](TODO.md)
|
|
34
|
+
|
|
35
|
+
**Native Python extensions written in [Nox](https://github.com/mburakmmm/nox-lang). Free-threaded first (`abi3t`), safe by design.**
|
|
36
|
+
|
|
37
|
+
NoxPy combines a native CPython 3.15+ binding layer and a PEP 517/660 build pipeline so developers can author typed Nox modules, compile platform wheels targeting `cp315-abi3.abi3t`, and import them in both ordinary CPython 3.15 and free-threaded CPython `3.15t` without requiring wheel consumers to install `noxc`, Zig, or a C compiler.
|
|
38
|
+
|
|
39
|
+
> **Current Status (Phase 1 `0.1 alpha` Functions & Wheels Verified on macOS arm64):**
|
|
40
|
+
> Built dual-tag `cp315-abi3.abi3t-macosx_14_0_arm64.whl` wheels for [`examples/hello`](examples/hello/) and [`examples/fastmath`](examples/fastmath/) using `noxc v2.2.81` (`--host-abi`), installed them into isolated `CPython 3.15.2` and unforced `3.15.0b3t` virtualenvs (`gil_enabled=False`) with zero compiler tools on `PATH`, and verified positional/keyword calls, binary-safe `str`/`bytes`, `ValueError` containment, and 8-thread concurrency. Next: Phase 2 (collections, `T | None`, sdist, PEP 660 editable installs).
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Architecture
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
Python package / user code
|
|
48
|
+
-> CPython native module (.abi3t.so / .pyd) via PyModExport_<leaf>
|
|
49
|
+
-> deterministic C adapters + audited abi3t shim (native/cpython/noxpy_shim.c)
|
|
50
|
+
-> versioned Nox Host Export ABI (native/include/nox_host_abi.h)
|
|
51
|
+
-> compiled Nox modules + matching hidden-visibility Nox runtime
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Design charter & normative invariants live in [`AGENTS.md`](AGENTS.md):
|
|
55
|
+
- **Minimum Python:** CPython `3.15+` (`Py_TARGET_ABI3T=0x030F0000`, `_Py_OPAQUE_PYOBJECT`, `PyModExport_*`, `Py_MOD_GIL_NOT_USED`).
|
|
56
|
+
- **True concurrency:** Zero process-global invocation mutexes; per-module atomic lifecycle leases (`NEW -> INITIALIZING -> READY -> CLOSING -> CLOSED`).
|
|
57
|
+
- **Strict conversions:** `bool` never silently coerces to `int`; `__index__`/`__float__` are never implicitly invoked; `int64` overflow raises `OverflowError`; UTF-8 `str` and `bytes` spans preserve embedded `\0`.
|
|
58
|
+
- **Clean upstream boundary:** `nox-lang` is strictly read-only here; missing compiler/runtime primitives are tracked with executable reproducers in [`UPSTREAM_REQUIREMENTS.md`](UPSTREAM_REQUIREMENTS.md).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Phase & Verification Matrix
|
|
63
|
+
|
|
64
|
+
| Component | State | Verified Scope |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| CPython 3.15 `abi3t` core shim ([`noxpy_shim.c`](native/cpython/noxpy_shim.c)) | **Tested** | Compiled `-Wall -Wextra -Werror` (`Py_TARGET_ABI3T=0x030F0000`), symbol-audited, tested (`int64`, `bool`, `float`, `\0`-safe `str`/`bytes`) on CPython 3.15.2 |
|
|
67
|
+
| Config, Binding IR, Stub & C Codegen ([`src/`](src/), [`python/noxpy/`](python/noxpy/)) | **Tested** | Genuine Nox core (`nox.json`, `src/{core,codegen,builder,cli}/*.nox`) verified via `noxc test tests/nox` (`3/3`), Python `tests/unit/` (`24/24`), and byte-for-byte differential + `clang -Werror` CPython 3.15 header check (`tests/codegen/`, `4/4`) |
|
|
68
|
+
| Phase 0 End-to-End Host ABI Suite ([`experiments/phase0_poc/`](experiments/phase0_poc/)) | **Verified** | Genuine `@export` Nox modules built via `--host-abi` (`include/nox_host.h`), concurrent `1/2/4/8` threads (`peak_in_flight=8`), dual-library isolation, `\0`-safe `str`/`bytes`, `ValueError` inspection, `NoxHostHandle` lifecycle |
|
|
69
|
+
| Upstream Contract Verification ([`tests/reproducers/`](tests/reproducers/)) | **Verified (`7/7`)** | `UR-001`–`UR-007` positively verified against `noxc v2.2.81` (`2dcee335`) |
|
|
70
|
+
| Free-Threaded `python3.15t` Unforced Run | **Verified** | [`test_freethreaded_315t.py`](tests/abi/test_freethreaded_315t.py) passes locally on `3.15.0b3t` (`gil_enabled=False`, `peak_in_flight=8`) and in CI |
|
|
71
|
+
| Production Packaging & Wheels (Phase 1 — `0.1 alpha`) | **Verified (`macOS arm64`)** | [`noxpy.build`](python/noxpy/build.py) PEP 517 backend, [`noxpy.audit`](python/noxpy/audit.py), `noxpy new/build/develop`, `examples/hello` & `examples/fastmath` dual-tag wheels tested in clean `3.15.2` & `3.15t` venvs |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Quickstart (Local Verification)
|
|
76
|
+
|
|
77
|
+
Prerequisites: CPython `3.15+`, `clang`, [`rtk`](RTK.md), and (for Phase 0 PoC / reproducers) `noxc >= 2.2.70`.
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
# 1. Inspect toolchain, CPython 3.15 abi3t headers, and Phase 0 gate status
|
|
81
|
+
PYTHONPATH=python python3.15 -m noxpy doctor
|
|
82
|
+
|
|
83
|
+
# 2. Run genuine Nox unit/codegen tests & Python unit/differential tests
|
|
84
|
+
noxc check src/cli/main.nox
|
|
85
|
+
noxc test tests/nox
|
|
86
|
+
python3.15 -m unittest discover -s tests/unit -v
|
|
87
|
+
python3.15 -m unittest discover -s tests/codegen -v
|
|
88
|
+
|
|
89
|
+
# 3. Run the isolated Phase 0 native C + CPython 3.15 PoC
|
|
90
|
+
bash experiments/phase0_poc/build_and_test.sh
|
|
91
|
+
|
|
92
|
+
# 4. Verify all 7 upstream requirements against installed noxc
|
|
93
|
+
bash tests/reproducers/run_all.sh
|
|
94
|
+
|
|
95
|
+
# 5. Validate strict RTK hooks & release gate dry-run
|
|
96
|
+
python3 scripts/hooks/verify_rtk_enforcement.py
|
|
97
|
+
python3.15 scripts/release/prepare_phase_release.py --dry-run
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Repository Map
|
|
103
|
+
|
|
104
|
+
- [`AGENTS.md`](AGENTS.md) — Normative engineering charter, CPython 3.15 `abi3t` rules, and phase gates.
|
|
105
|
+
- [`TODO.md`](TODO.md) — Phased implementation checklist (Phase 0 through Phase 7).
|
|
106
|
+
- [`UPSTREAM_REQUIREMENTS.md`](UPSTREAM_REQUIREMENTS.md) — Prioritized upstream `nox-lang` batches (`Batch A/B/C`) with runnable reproducers.
|
|
107
|
+
- [`docs/RELEASE.md`](docs/RELEASE.md) — Phase-by-phase release runbook, immutable artifact pipeline, and OIDC publishing.
|
|
108
|
+
- [`docs/adr/`](docs/adr/) & [`docs/evidence/`](docs/evidence/) — Architectural Decision Records and recorded verification evidence.
|
|
109
|
+
- [`native/`](native/) — Target `nox_host_abi.h` contract and audited CPython 3.15 `abi3t` C shim.
|
|
110
|
+
- [`src/`](src/) & [`nox.json`](nox.json) — Upstream-independent NoxPy core written in genuine Nox (`errors`, `ir`, `.pyi`/C codegen, `pyproject.toml` config validator, and `noxpy` Nox CLI).
|
|
111
|
+
- [`python/noxpy/`](python/noxpy/) — Python PEP 517 bootstrap adapter, `pyproject.toml` validator, Binding IR, `.pyi`/C codegen, and `noxpy` CLI (`doctor`, `check`, `generate-stubs`).
|
|
112
|
+
- [`.github/workflows/`](.github/workflows/) — SHA-pinned CI and tag-gated release automation.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Contributing, Security & License
|
|
117
|
+
|
|
118
|
+
- Contributions: see [`CONTRIBUTING.md`](CONTRIBUTING.md).
|
|
119
|
+
- Security & trust boundary: see [`SECURITY.md`](SECURITY.md).
|
|
120
|
+
- Release history: see [`CHANGELOG.md`](CHANGELOG.md).
|
|
121
|
+
- License: [MIT](LICENSE).
|
noxpy-0.1.0a1/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# NoxPy
|
|
2
|
+
|
|
3
|
+
[](https://github.com/mburakmmm/noxPY/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/mburakmmm/noxPY/actions/workflows/release.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://docs.python.org/3.15/)
|
|
7
|
+
[](docs/adr/0001-cpython-315-dual-abi3t.md)
|
|
8
|
+
[](TODO.md)
|
|
9
|
+
|
|
10
|
+
**Native Python extensions written in [Nox](https://github.com/mburakmmm/nox-lang). Free-threaded first (`abi3t`), safe by design.**
|
|
11
|
+
|
|
12
|
+
NoxPy combines a native CPython 3.15+ binding layer and a PEP 517/660 build pipeline so developers can author typed Nox modules, compile platform wheels targeting `cp315-abi3.abi3t`, and import them in both ordinary CPython 3.15 and free-threaded CPython `3.15t` without requiring wheel consumers to install `noxc`, Zig, or a C compiler.
|
|
13
|
+
|
|
14
|
+
> **Current Status (Phase 1 `0.1 alpha` Functions & Wheels Verified on macOS arm64):**
|
|
15
|
+
> Built dual-tag `cp315-abi3.abi3t-macosx_14_0_arm64.whl` wheels for [`examples/hello`](examples/hello/) and [`examples/fastmath`](examples/fastmath/) using `noxc v2.2.81` (`--host-abi`), installed them into isolated `CPython 3.15.2` and unforced `3.15.0b3t` virtualenvs (`gil_enabled=False`) with zero compiler tools on `PATH`, and verified positional/keyword calls, binary-safe `str`/`bytes`, `ValueError` containment, and 8-thread concurrency. Next: Phase 2 (collections, `T | None`, sdist, PEP 660 editable installs).
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Architecture
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
Python package / user code
|
|
23
|
+
-> CPython native module (.abi3t.so / .pyd) via PyModExport_<leaf>
|
|
24
|
+
-> deterministic C adapters + audited abi3t shim (native/cpython/noxpy_shim.c)
|
|
25
|
+
-> versioned Nox Host Export ABI (native/include/nox_host_abi.h)
|
|
26
|
+
-> compiled Nox modules + matching hidden-visibility Nox runtime
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Design charter & normative invariants live in [`AGENTS.md`](AGENTS.md):
|
|
30
|
+
- **Minimum Python:** CPython `3.15+` (`Py_TARGET_ABI3T=0x030F0000`, `_Py_OPAQUE_PYOBJECT`, `PyModExport_*`, `Py_MOD_GIL_NOT_USED`).
|
|
31
|
+
- **True concurrency:** Zero process-global invocation mutexes; per-module atomic lifecycle leases (`NEW -> INITIALIZING -> READY -> CLOSING -> CLOSED`).
|
|
32
|
+
- **Strict conversions:** `bool` never silently coerces to `int`; `__index__`/`__float__` are never implicitly invoked; `int64` overflow raises `OverflowError`; UTF-8 `str` and `bytes` spans preserve embedded `\0`.
|
|
33
|
+
- **Clean upstream boundary:** `nox-lang` is strictly read-only here; missing compiler/runtime primitives are tracked with executable reproducers in [`UPSTREAM_REQUIREMENTS.md`](UPSTREAM_REQUIREMENTS.md).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Phase & Verification Matrix
|
|
38
|
+
|
|
39
|
+
| Component | State | Verified Scope |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| CPython 3.15 `abi3t` core shim ([`noxpy_shim.c`](native/cpython/noxpy_shim.c)) | **Tested** | Compiled `-Wall -Wextra -Werror` (`Py_TARGET_ABI3T=0x030F0000`), symbol-audited, tested (`int64`, `bool`, `float`, `\0`-safe `str`/`bytes`) on CPython 3.15.2 |
|
|
42
|
+
| Config, Binding IR, Stub & C Codegen ([`src/`](src/), [`python/noxpy/`](python/noxpy/)) | **Tested** | Genuine Nox core (`nox.json`, `src/{core,codegen,builder,cli}/*.nox`) verified via `noxc test tests/nox` (`3/3`), Python `tests/unit/` (`24/24`), and byte-for-byte differential + `clang -Werror` CPython 3.15 header check (`tests/codegen/`, `4/4`) |
|
|
43
|
+
| Phase 0 End-to-End Host ABI Suite ([`experiments/phase0_poc/`](experiments/phase0_poc/)) | **Verified** | Genuine `@export` Nox modules built via `--host-abi` (`include/nox_host.h`), concurrent `1/2/4/8` threads (`peak_in_flight=8`), dual-library isolation, `\0`-safe `str`/`bytes`, `ValueError` inspection, `NoxHostHandle` lifecycle |
|
|
44
|
+
| Upstream Contract Verification ([`tests/reproducers/`](tests/reproducers/)) | **Verified (`7/7`)** | `UR-001`–`UR-007` positively verified against `noxc v2.2.81` (`2dcee335`) |
|
|
45
|
+
| Free-Threaded `python3.15t` Unforced Run | **Verified** | [`test_freethreaded_315t.py`](tests/abi/test_freethreaded_315t.py) passes locally on `3.15.0b3t` (`gil_enabled=False`, `peak_in_flight=8`) and in CI |
|
|
46
|
+
| Production Packaging & Wheels (Phase 1 — `0.1 alpha`) | **Verified (`macOS arm64`)** | [`noxpy.build`](python/noxpy/build.py) PEP 517 backend, [`noxpy.audit`](python/noxpy/audit.py), `noxpy new/build/develop`, `examples/hello` & `examples/fastmath` dual-tag wheels tested in clean `3.15.2` & `3.15t` venvs |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Quickstart (Local Verification)
|
|
51
|
+
|
|
52
|
+
Prerequisites: CPython `3.15+`, `clang`, [`rtk`](RTK.md), and (for Phase 0 PoC / reproducers) `noxc >= 2.2.70`.
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
# 1. Inspect toolchain, CPython 3.15 abi3t headers, and Phase 0 gate status
|
|
56
|
+
PYTHONPATH=python python3.15 -m noxpy doctor
|
|
57
|
+
|
|
58
|
+
# 2. Run genuine Nox unit/codegen tests & Python unit/differential tests
|
|
59
|
+
noxc check src/cli/main.nox
|
|
60
|
+
noxc test tests/nox
|
|
61
|
+
python3.15 -m unittest discover -s tests/unit -v
|
|
62
|
+
python3.15 -m unittest discover -s tests/codegen -v
|
|
63
|
+
|
|
64
|
+
# 3. Run the isolated Phase 0 native C + CPython 3.15 PoC
|
|
65
|
+
bash experiments/phase0_poc/build_and_test.sh
|
|
66
|
+
|
|
67
|
+
# 4. Verify all 7 upstream requirements against installed noxc
|
|
68
|
+
bash tests/reproducers/run_all.sh
|
|
69
|
+
|
|
70
|
+
# 5. Validate strict RTK hooks & release gate dry-run
|
|
71
|
+
python3 scripts/hooks/verify_rtk_enforcement.py
|
|
72
|
+
python3.15 scripts/release/prepare_phase_release.py --dry-run
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Repository Map
|
|
78
|
+
|
|
79
|
+
- [`AGENTS.md`](AGENTS.md) — Normative engineering charter, CPython 3.15 `abi3t` rules, and phase gates.
|
|
80
|
+
- [`TODO.md`](TODO.md) — Phased implementation checklist (Phase 0 through Phase 7).
|
|
81
|
+
- [`UPSTREAM_REQUIREMENTS.md`](UPSTREAM_REQUIREMENTS.md) — Prioritized upstream `nox-lang` batches (`Batch A/B/C`) with runnable reproducers.
|
|
82
|
+
- [`docs/RELEASE.md`](docs/RELEASE.md) — Phase-by-phase release runbook, immutable artifact pipeline, and OIDC publishing.
|
|
83
|
+
- [`docs/adr/`](docs/adr/) & [`docs/evidence/`](docs/evidence/) — Architectural Decision Records and recorded verification evidence.
|
|
84
|
+
- [`native/`](native/) — Target `nox_host_abi.h` contract and audited CPython 3.15 `abi3t` C shim.
|
|
85
|
+
- [`src/`](src/) & [`nox.json`](nox.json) — Upstream-independent NoxPy core written in genuine Nox (`errors`, `ir`, `.pyi`/C codegen, `pyproject.toml` config validator, and `noxpy` Nox CLI).
|
|
86
|
+
- [`python/noxpy/`](python/noxpy/) — Python PEP 517 bootstrap adapter, `pyproject.toml` validator, Binding IR, `.pyi`/C codegen, and `noxpy` CLI (`doctor`, `check`, `generate-stubs`).
|
|
87
|
+
- [`.github/workflows/`](.github/workflows/) — SHA-pinned CI and tag-gated release automation.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Contributing, Security & License
|
|
92
|
+
|
|
93
|
+
- Contributions: see [`CONTRIBUTING.md`](CONTRIBUTING.md).
|
|
94
|
+
- Security & trust boundary: see [`SECURITY.md`](SECURITY.md).
|
|
95
|
+
- Release history: see [`CHANGELOG.md`](CHANGELOG.md).
|
|
96
|
+
- License: [MIT](LICENSE).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=75.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "noxpy"
|
|
7
|
+
version = "0.1.0a1"
|
|
8
|
+
description = "Native Python extensions written in Nox. Free-threaded first (abi3t), safe by design."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.15"
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Melih Burak Memiş" },
|
|
15
|
+
]
|
|
16
|
+
keywords = ["nox", "python", "cpython", "abi3t", "free-threaded", "native-extension"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Operating System :: MacOS",
|
|
21
|
+
"Operating System :: POSIX :: Linux",
|
|
22
|
+
"Programming Language :: C",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.15",
|
|
25
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
26
|
+
"Topic :: Software Development :: Build Tools",
|
|
27
|
+
]
|
|
28
|
+
dependencies = []
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/mburakmmm/noxPY"
|
|
32
|
+
Repository = "https://github.com/mburakmmm/noxPY"
|
|
33
|
+
Issues = "https://github.com/mburakmmm/noxPY/issues"
|
|
34
|
+
Changelog = "https://github.com/mburakmmm/noxPY/blob/main/CHANGELOG.md"
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
noxpy = "noxpy.__main__:main"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["python"]
|
|
41
|
+
include = ["noxpy*"]
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.package-data]
|
|
44
|
+
noxpy = ["_native/include/*.h", "_native/cpython/*.c"]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""NoxPy — Native Python extensions written in Nox."""
|
|
2
|
+
|
|
3
|
+
from .config import NoxPyProjectConfig, load_pyproject
|
|
4
|
+
from .errors import NoxPyError
|
|
5
|
+
from .ir import (
|
|
6
|
+
ExportedFunctionIR,
|
|
7
|
+
ModuleIR,
|
|
8
|
+
ParamIR,
|
|
9
|
+
SourceSpan,
|
|
10
|
+
parse_upstream_metadata_json,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__version__ = "0.1.0a1"
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"__version__",
|
|
17
|
+
"ExportedFunctionIR",
|
|
18
|
+
"ModuleIR",
|
|
19
|
+
"NoxPyError",
|
|
20
|
+
"NoxPyProjectConfig",
|
|
21
|
+
"ParamIR",
|
|
22
|
+
"SourceSpan",
|
|
23
|
+
"load_pyproject",
|
|
24
|
+
"parse_upstream_metadata_json",
|
|
25
|
+
]
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""Thin CLI entry point for `python -m noxpy` (`AGENTS.md` §15.4)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from .build import build_project_wheel, develop_install, scaffold_project
|
|
11
|
+
from .codegen import generate_c_adapter, generate_pyi
|
|
12
|
+
from .config import load_pyproject
|
|
13
|
+
from .doctor import collect_doctor_report
|
|
14
|
+
from .errors import NoxPyError
|
|
15
|
+
from .ir import parse_upstream_metadata_json
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _cmd_doctor(args: argparse.Namespace) -> int:
|
|
19
|
+
report = collect_doctor_report()
|
|
20
|
+
if args.json:
|
|
21
|
+
sys.stdout.write(json.dumps(report, indent=2) + "\n")
|
|
22
|
+
else:
|
|
23
|
+
py = report["python"]
|
|
24
|
+
nx = report["noxc"]
|
|
25
|
+
p315t = report["python_315t"]
|
|
26
|
+
print(f"Python: {py['version']} ({py['executable']}) abi3t_headers={py['abi3t_header_ready']}")
|
|
27
|
+
print(f"PythonT: found={p315t['found']} ({p315t['probe']})")
|
|
28
|
+
print(f"noxc: found={nx['found']} version={nx['version']} path={nx['path']}")
|
|
29
|
+
print(f"clang: found={report['clang']['found']} ({report['clang']['version']})")
|
|
30
|
+
print(f"rtk: found={report['rtk']['found']} ({report['rtk']['version']})")
|
|
31
|
+
print(
|
|
32
|
+
f"Phase: {report['phase_gate']['current_phase']} "
|
|
33
|
+
f"(phase0_exit_ready={report['phase_gate']['phase0_exit_ready']}, "
|
|
34
|
+
f"phase1_ready={report['phase_gate']['phase1_ready']})"
|
|
35
|
+
)
|
|
36
|
+
return 0
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _cmd_check(args: argparse.Namespace) -> int:
|
|
40
|
+
pyproject_path = Path(args.pyproject).resolve()
|
|
41
|
+
cfg = load_pyproject(pyproject_path)
|
|
42
|
+
ir = None
|
|
43
|
+
if args.ir:
|
|
44
|
+
raw = json.loads(Path(args.ir).read_text(encoding="utf-8"))
|
|
45
|
+
ir = parse_upstream_metadata_json(
|
|
46
|
+
raw,
|
|
47
|
+
expected_module_name=cfg.module_name,
|
|
48
|
+
abi=cfg.abi,
|
|
49
|
+
free_threaded=cfg.free_threaded,
|
|
50
|
+
)
|
|
51
|
+
elif getattr(args, "inspect", False):
|
|
52
|
+
from .build import inspect_module_ir
|
|
53
|
+
|
|
54
|
+
ir = inspect_module_ir(pyproject_path.parent, cfg)
|
|
55
|
+
|
|
56
|
+
if args.json:
|
|
57
|
+
out: dict[str, object] = {
|
|
58
|
+
"status": "ok",
|
|
59
|
+
"distribution": cfg.distribution_name,
|
|
60
|
+
"module": cfg.module_name,
|
|
61
|
+
"abi": cfg.abi,
|
|
62
|
+
"free_threaded": cfg.free_threaded,
|
|
63
|
+
}
|
|
64
|
+
if ir is not None:
|
|
65
|
+
out["exported_functions"] = [f.name for f in ir.functions]
|
|
66
|
+
sys.stdout.write(json.dumps(out, indent=2) + "\n")
|
|
67
|
+
else:
|
|
68
|
+
print(f"OK: {cfg.distribution_name} ({cfg.module_name}, {cfg.abi})")
|
|
69
|
+
return 0
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _cmd_generate_stubs(args: argparse.Namespace) -> int:
|
|
73
|
+
raw = json.loads(Path(args.ir).read_text(encoding="utf-8"))
|
|
74
|
+
ir = parse_upstream_metadata_json(raw)
|
|
75
|
+
sys.stdout.write(generate_pyi(ir))
|
|
76
|
+
if args.emit_c:
|
|
77
|
+
sys.stdout.write("\n/* --- C ADAPTER --- */\n")
|
|
78
|
+
sys.stdout.write(generate_c_adapter(ir))
|
|
79
|
+
return 0
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _cmd_build(args: argparse.Namespace) -> int:
|
|
83
|
+
proj = Path(args.project).resolve()
|
|
84
|
+
out_dir = Path(args.out_dir).resolve() if args.out_dir else (proj / "dist")
|
|
85
|
+
res = build_project_wheel(proj, out_dir, release=bool(args.release))
|
|
86
|
+
if args.json:
|
|
87
|
+
sys.stdout.write(json.dumps(res.to_dict(), indent=2) + "\n")
|
|
88
|
+
else:
|
|
89
|
+
print(f"Built wheel: {res.wheel_path}")
|
|
90
|
+
print(f"Tags: {', '.join(res.tags)}")
|
|
91
|
+
print(f"SHA-256: {res.wheel_sha256}")
|
|
92
|
+
print(f"Exports: {', '.join(res.exported_functions)}")
|
|
93
|
+
return 0
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _cmd_develop(args: argparse.Namespace) -> int:
|
|
97
|
+
res = develop_install(args.project, python_exe=args.python, release=bool(args.release))
|
|
98
|
+
if args.json:
|
|
99
|
+
sys.stdout.write(json.dumps(res.to_dict(), indent=2) + "\n")
|
|
100
|
+
else:
|
|
101
|
+
print(f"Installed {res.module_name} ({', '.join(res.exported_functions)})")
|
|
102
|
+
return 0
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _cmd_new(args: argparse.Namespace) -> int:
|
|
106
|
+
dest = scaffold_project(args.name, args.dir)
|
|
107
|
+
if args.json:
|
|
108
|
+
sys.stdout.write(json.dumps({"status": "ok", "path": str(dest), "name": args.name}, indent=2) + "\n")
|
|
109
|
+
else:
|
|
110
|
+
print(f"Created NoxPy project at {dest}")
|
|
111
|
+
return 0
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def main(argv: list[str] | None = None) -> int:
|
|
115
|
+
parser = argparse.ArgumentParser(prog="noxpy")
|
|
116
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
117
|
+
|
|
118
|
+
p_doc = sub.add_parser("doctor", help="Inspect toolchain, CPython 3.15/3.15t, and readiness.")
|
|
119
|
+
p_doc.add_argument("--json", action="store_true")
|
|
120
|
+
p_doc.set_defaults(func=_cmd_doctor)
|
|
121
|
+
|
|
122
|
+
p_chk = sub.add_parser("check", help="Validate pyproject.toml and optional UR-007 IR JSON manifest.")
|
|
123
|
+
p_chk.add_argument("pyproject", nargs="?", default="pyproject.toml")
|
|
124
|
+
p_chk.add_argument("--ir", help="Path to UR-007 JSON metadata manifest.")
|
|
125
|
+
p_chk.add_argument("--inspect", action="store_true", help="Invoke noxc expand --json on source.")
|
|
126
|
+
p_chk.add_argument("--json", action="store_true")
|
|
127
|
+
p_chk.set_defaults(func=_cmd_check)
|
|
128
|
+
|
|
129
|
+
p_stubs = sub.add_parser("generate-stubs", help="Generate deterministic .pyi from UR-007 IR JSON.")
|
|
130
|
+
p_stubs.add_argument("--ir", required=True, help="Path to UR-007 JSON metadata manifest.")
|
|
131
|
+
p_stubs.add_argument("--emit-c", action="store_true", help="Also print generated abi3t C adapter.")
|
|
132
|
+
p_stubs.set_defaults(func=_cmd_generate_stubs)
|
|
133
|
+
|
|
134
|
+
p_bld = sub.add_parser("build", help="Compile Nox extension and package audited cp315-abi3.abi3t wheel.")
|
|
135
|
+
p_bld.add_argument("project", nargs="?", default=".", help="Project directory containing pyproject.toml.")
|
|
136
|
+
p_bld.add_argument("--out-dir", "-o", help="Output wheel directory (defaults to <project>/dist).")
|
|
137
|
+
p_bld.add_argument("--release", action="store_true", help="Enable noxc --release optimization.")
|
|
138
|
+
p_bld.add_argument("--json", action="store_true")
|
|
139
|
+
p_bld.set_defaults(func=_cmd_build)
|
|
140
|
+
|
|
141
|
+
p_dev = sub.add_parser("develop", help="Build and install extension into active or --python virtualenv.")
|
|
142
|
+
p_dev.add_argument("project", nargs="?", default=".", help="Project directory containing pyproject.toml.")
|
|
143
|
+
p_dev.add_argument("--python", help="Target virtualenv Python interpreter.")
|
|
144
|
+
p_dev.add_argument("--release", action="store_true")
|
|
145
|
+
p_dev.add_argument("--json", action="store_true")
|
|
146
|
+
p_dev.set_defaults(func=_cmd_develop)
|
|
147
|
+
|
|
148
|
+
p_new = sub.add_parser("new", help="Scaffold a new Phase 1 NoxPy extension project.")
|
|
149
|
+
p_new.add_argument("name", help="Distribution/module identifier (e.g. fastmath).")
|
|
150
|
+
p_new.add_argument("--dir", help="Target directory (defaults to ./<name>).")
|
|
151
|
+
p_new.add_argument("--json", action="store_true")
|
|
152
|
+
p_new.set_defaults(func=_cmd_new)
|
|
153
|
+
|
|
154
|
+
args = parser.parse_args(argv)
|
|
155
|
+
try:
|
|
156
|
+
return int(args.func(args))
|
|
157
|
+
except NoxPyError as exc:
|
|
158
|
+
sys.stderr.write(f"error: {exc}\n")
|
|
159
|
+
if exc.hint:
|
|
160
|
+
sys.stderr.write(f"hint: {exc.hint}\n")
|
|
161
|
+
return 1
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if __name__ == "__main__":
|
|
165
|
+
raise SystemExit(main())
|