Require PyArrow in the Python package

Keep the arrow extra available for existing requirements. Update wheel checks and install instructions, and verify that integer packing leaves PyArrow unloaded.
This commit is contained in:
Jan Petykiewicz 2026-11-18 12:36:58 -08:00
commit f474e9848c
9 changed files with 20 additions and 23 deletions

View file

@ -56,7 +56,6 @@ jobs:
CIBW_ARCHS: native CIBW_ARCHS: native
CIBW_ENVIRONMENT_LINUX: 'CARGO_HOME=/tmp/pheon-cargo RUSTUP_HOME=/tmp/pheon-rustup PATH=/tmp/pheon-cargo/bin:$PATH' CIBW_ENVIRONMENT_LINUX: 'CARGO_HOME=/tmp/pheon-cargo RUSTUP_HOME=/tmp/pheon-rustup PATH=/tmp/pheon-cargo/bin:$PATH'
CIBW_BEFORE_ALL_LINUX: 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable' CIBW_BEFORE_ALL_LINUX: 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable'
CIBW_TEST_EXTRAS: arrow
CIBW_TEST_COMMAND: 'python -I {project}/tools/check_installed.py' CIBW_TEST_COMMAND: 'python -I {project}/tools/check_installed.py'
- name: Check wheel ABI tags - name: Check wheel ABI tags
shell: python shell: python
@ -91,7 +90,7 @@ jobs:
path: wheelhouse path: wheelhouse
- name: Install the same artifact on another Python version - name: Install the same artifact on another Python version
shell: bash shell: bash
run: python -m pip install wheelhouse/*.whl pyarrow run: python -m pip install wheelhouse/*.whl
- run: python -I tools/check_installed.py - run: python -I tools/check_installed.py
cli: cli:

View file

@ -32,7 +32,7 @@ comparisons. Start with the [CLI guide](docs/cli.md), then set up
Python 3.11 or newer is required. From a source checkout: Python 3.11 or newer is required. From a source checkout:
```sh ```sh
python -m pip install '.[arrow]' python -m pip install .
``` ```
Run Python outside the source checkout to use the installed package: Run Python outside the source checkout to use the installed package:

View file

@ -13,7 +13,7 @@ the tracked `Cargo.lock`; update dependencies explicitly with Cargo.
cargo test --locked cargo test --locked
cargo test --release --locked cargo test --release --locked
cargo build --release --locked cargo build --release --locked
python -m pip install '.[arrow]' python -m pip install .
python -I tools/check_installed.py python -I tools/check_installed.py
``` ```
@ -27,7 +27,7 @@ Unset this override when checking installed artifacts with `check_installed.py`.
## Check upstream layouts ## Check upstream layouts
The [GDSII corpus](../contrib/gds-corpus.toml) pins open-source fixtures and cell The [GDSII corpus](../contrib/gds-corpus.toml) pins open-source fixtures and cell
libraries. After installing `.[arrow]` and building the release CLI, run: libraries. After installing Pheon and building the release CLI, run:
```sh ```sh
python -I tools/check_gds_corpus.py --fetch python -I tools/check_gds_corpus.py --fetch

View file

@ -6,16 +6,15 @@ Python 3.11 or newer is required.
## Install ## Install
To install a PyPI release with Arrow support: To install a PyPI release:
```sh ```sh
python -m pip install 'pheon[arrow]' python -m pip install pheon
``` ```
For a local wheel, pass its file path followed by `[arrow]` in the same quotes. The package installs PyArrow for layout reads. Existing `pheon[arrow]`
Prebuilt wheels bundle the native library. From a source checkout, use requirements still work. Prebuilt wheels bundle the native library. From a
`python -m pip install '.[arrow]'` with Rust 1.88 or newer. The base `pheon` source checkout, use `python -m pip install .` with Rust 1.88 or newer.
package is enough for integer packing.
Run Python outside the source checkout to use the installed package. Run Python outside the source checkout to use the installed package.
@ -89,7 +88,7 @@ errors use Python's normal I/O exceptions.
## Use from Klamath or Masque ## Use from Klamath or Masque
Klamath's `native` extra installs Pheon's packing helpers. Masque's `arrow` extra Klamath's `native` extra installs Pheon's packing helpers. Masque's `arrow` extra
installs Pheon with Arrow support. Use the same Python environment as the installs Pheon for layout reads. Use the same Python environment as the
companion package. companion package.
See [development](development.md) to test a locally built native library from See [development](development.md) to test a locally built native library from

View file

@ -55,7 +55,6 @@ export CIBW_CONTAINER_ENGINE="podman; disable_host_mount: true; create_args: \
export CIBW_MANYLINUX_X86_64_IMAGE=localhost/pheon-manylinux:2.28-2026.10.26-1 export CIBW_MANYLINUX_X86_64_IMAGE=localhost/pheon-manylinux:2.28-2026.10.26-1
export CIBW_ENVIRONMENT_LINUX='PATH=/rust-toolchain/bin:$PATH CARGO_HOME=/pheon-cache/cargo CARGO_NET_OFFLINE=true PIP_CACHE_DIR=/pheon-cache/pip' export CIBW_ENVIRONMENT_LINUX='PATH=/rust-toolchain/bin:$PATH CARGO_HOME=/pheon-cache/cargo CARGO_NET_OFFLINE=true PIP_CACHE_DIR=/pheon-cache/pip'
export CIBW_BUILD='cp31{1,2,3,4}-manylinux_x86_64' export CIBW_BUILD='cp31{1,2,3,4}-manylinux_x86_64'
export CIBW_TEST_EXTRAS=arrow
export CIBW_TEST_COMMAND='python -I {project}/tools/check_installed.py' export CIBW_TEST_COMMAND='python -I {project}/tools/check_installed.py'
unset PHEON_LIBRARY unset PHEON_LIBRARY
python -m cibuildwheel --platform linux --archs x86_64 \ python -m cibuildwheel --platform linux --archs x86_64 \
@ -93,12 +92,12 @@ Wheel filenames use `py3-none` plus a platform tag, such as
`manylinux_2_28_x86_64` or `win_amd64`. Use repaired `manylinux_*` wheels for `manylinux_2_28_x86_64` or `win_amd64`. Use repaired `manylinux_*` wheels for
Linux releases. Linux releases.
To test a wheel manually, install it with its `arrow` extra in a test To test a wheel manually, install it in a test environment on the target OS.
environment on the target OS. Clear `PHEON_LIBRARY` so the checks load the Clear `PHEON_LIBRARY` so the checks load the bundled library. Replace the
bundled library. Replace the example path with the wheel you built. example path with the wheel you built.
```sh ```sh
python -m pip install "path/to/pheon-wheel.whl[arrow]" python -m pip install "path/to/pheon-wheel.whl"
python -I tools/check_installed.py python -I tools/check_installed.py
``` ```

View file

@ -1,4 +1,4 @@
"""Native GDSII helpers. Install pheon[arrow] for the pheon.arrow readers.""" """Native GDSII helpers. Use pheon.arrow to read layouts into PyArrow."""
from importlib.metadata import version as _version from importlib.metadata import version as _version

View file

@ -1,7 +1,6 @@
"""GDSII readers returning a one-row Arrow StructArray for the library. """GDSII readers returning a one-row Arrow StructArray for the library.
The returned arrays own their buffers independently of the input. This module The returned arrays own their buffers independently of the input.
requires the optional ``arrow`` extra; integer packing does not import PyArrow.
""" """
from __future__ import annotations from __future__ import annotations

View file

@ -26,10 +26,11 @@ dynamic = ["version"]
dependencies = [ dependencies = [
"cffi", "cffi",
"numpy", "numpy",
"pyarrow>=14",
] ]
[project.optional-dependencies] [project.optional-dependencies]
arrow = ["pyarrow>=14"] arrow = [] # Compatibility with existing requirements for pheon[arrow].
[project.urls] [project.urls]
Homepage = "https://mpxd.net/code/jan/pheon" Homepage = "https://mpxd.net/code/jan/pheon"

View file

@ -7,7 +7,7 @@ import unittest
ROOT = Path(__file__).resolve().parents[1] ROOT = Path(__file__).resolve().parents[1]
# A separate interpreter verifies that base packing does not import PyArrow. # A separate interpreter checks that PyArrow stays unloaded during packing.
subprocess.run( subprocess.run(
[sys.executable, "-I", "-c", """ [sys.executable, "-I", "-c", """
import sys import sys
@ -15,9 +15,9 @@ from importlib.metadata import version
import pheon import pheon
from pheon._native import library from pheon._native import library
assert pheon.__version__ == version('pheon') assert pheon.__version__ == version('pheon')
assert 'pyarrow' not in sys.modules
assert library.parent == __import__('pathlib').Path(pheon.__file__).parent assert library.parent == __import__('pathlib').Path(pheon.__file__).parent
assert pheon.pack_int2([1, -2]) == bytes.fromhex('0001fffe') assert pheon.pack_int2([1, -2]) == bytes.fromhex('0001fffe')
assert 'pyarrow' not in sys.modules
"""], """],
check=True, check=True,
) )