Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
"""Bundle Cargo's C ABI library in a platform wheel, without a Python ABI tie."""
|
|
|
|
|
import json
|
2026-11-17 15:07:51 -08:00
|
|
|
import os
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
from pathlib import Path
|
|
|
|
|
import shutil
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
|
|
|
|
import tomllib
|
|
|
|
|
|
|
|
|
|
from setuptools import Distribution, setup
|
|
|
|
|
from setuptools.command.build_py import build_py
|
|
|
|
|
from wheel.bdist_wheel import bdist_wheel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parent
|
|
|
|
|
VERSION = tomllib.loads((ROOT / "Cargo.toml").read_text())["package"]["version"]
|
2026-11-17 15:07:51 -08:00
|
|
|
BUILD_TARGET = os.environ.get("PHEON_BUILD_TARGET")
|
|
|
|
|
WINDOWS_TARGET = "x86_64-pc-windows-gnu"
|
|
|
|
|
|
|
|
|
|
if BUILD_TARGET is not None and BUILD_TARGET != WINDOWS_TARGET:
|
|
|
|
|
raise ValueError(f"PHEON_BUILD_TARGET must be {WINDOWS_TARGET}, got {BUILD_TARGET!r}")
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
|
|
|
|
|
|
2026-11-16 20:44:56 -08:00
|
|
|
if not (ROOT / "Cargo.lock").is_file():
|
|
|
|
|
raise FileNotFoundError("Source builds require the supplied Cargo.lock")
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class CargoBuild(build_py):
|
|
|
|
|
def run(self):
|
|
|
|
|
super().run()
|
2026-11-17 15:07:51 -08:00
|
|
|
command = ["cargo", "build", "--release", "--lib", "--locked", "--message-format=json"]
|
|
|
|
|
if BUILD_TARGET:
|
|
|
|
|
command.extend(["--target", BUILD_TARGET])
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
result = subprocess.run(
|
2026-11-17 15:07:51 -08:00
|
|
|
command,
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
cwd=ROOT, capture_output=True, text=True,
|
|
|
|
|
)
|
|
|
|
|
sys.stderr.write(result.stderr)
|
|
|
|
|
library = None
|
|
|
|
|
for line in result.stdout.splitlines():
|
|
|
|
|
try:
|
|
|
|
|
message = json.loads(line)
|
|
|
|
|
except json.JSONDecodeError:
|
|
|
|
|
print(line, file=sys.stderr)
|
|
|
|
|
continue
|
|
|
|
|
if message.get("reason") == "compiler-message":
|
|
|
|
|
sys.stderr.write(message["message"].get("rendered") or "")
|
|
|
|
|
if (message.get("reason") == "compiler-artifact"
|
|
|
|
|
and message["target"]["name"] == "pheon"
|
|
|
|
|
and "cdylib" in message["target"]["crate_types"]):
|
|
|
|
|
for filename in message["filenames"]:
|
|
|
|
|
if Path(filename).suffix in (".so", ".dylib", ".dll"):
|
|
|
|
|
library = Path(filename)
|
|
|
|
|
result.check_returncode()
|
2026-11-17 15:07:51 -08:00
|
|
|
if library is None or (BUILD_TARGET and library.name != "pheon.dll"):
|
|
|
|
|
raise RuntimeError("Cargo did not produce the expected Pheon shared library")
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
shutil.copy2(library, Path(self.build_lib) / "pheon" / library.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NativeDistribution(Distribution):
|
|
|
|
|
def has_ext_modules(self):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NativeWheel(bdist_wheel):
|
|
|
|
|
def get_tag(self):
|
2026-11-17 15:07:51 -08:00
|
|
|
# CFFI ABI mode needs a platform tag and no CPython extension ABI.
|
|
|
|
|
if BUILD_TARGET == WINDOWS_TARGET:
|
|
|
|
|
return "py3", "none", "win_amd64"
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
_, _, platform = super().get_tag()
|
|
|
|
|
return "py3", "none", platform
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setup(
|
|
|
|
|
version=VERSION,
|
|
|
|
|
distclass=NativeDistribution,
|
2026-11-16 20:44:56 -08:00
|
|
|
cmdclass={"build_py": CargoBuild, "bdist_wheel": NativeWheel},
|
2026-11-17 15:07:51 -08:00
|
|
|
options={"build": {"build_base": f"build/{BUILD_TARGET}"}} if BUILD_TARGET else {},
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
)
|