diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7e17eb7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install package + run: | + python -m pip install --upgrade pip + pip install -e ".[pandas]" + + - name: Run tests + run: python -m unittest discover -s tests -p 'test*.py' -v + + wheels: + needs: test + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + - os: ubuntu-24.04-arm + - os: macos-15-intel + - os: macos-15 + - os: windows-latest + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.21 + + - uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.os }} + path: wheelhouse/*.whl + + sdist: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: sdist + path: dist/*.tar.gz diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 92c2c38..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Tests - -on: - push: - workflow_dispatch: - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install package - run: | - python -m pip install --upgrade pip - pip install -e ".[pandas]" - - - name: Run tests - run: python -m unittest discover -s tests -p 'test*.py' -v diff --git a/pyproject.toml b/pyproject.toml index 0de2d7c..3ed04a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,12 @@ [build-system] requires = ["setuptools>=61.0", "setuptools-rust>=1.0"] build-backend = "setuptools.build_meta" + +[tool.cibuildwheel] +build = "cp312-*" +environment = { NSV_BUILD_RUST = "1" } + +[tool.cibuildwheel.linux] +archs = ["auto64"] +before-all = "curl -sSf https://sh.rustup.rs | sh -s -- -y" +environment = { NSV_BUILD_RUST = "1", PATH = "$HOME/.cargo/bin:$PATH" } diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 328b24a..d4efb96 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -8,5 +8,5 @@ name = "_rust" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.29", features = ["extension-module"] } +pyo3 = { version = "0.29", features = ["extension-module", "abi3-py38"] } nsv = "0.0.12" diff --git a/setup.py b/setup.py index 37f3e9f..c928281 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,20 @@ +import os + from setuptools import setup, find_packages -try: +build_rust = os.environ.get("NSV_BUILD_RUST", "0") == "1" +if build_rust: from setuptools_rust import Binding, RustExtension - rust_extensions = [RustExtension("nsv._rust", path="rust/Cargo.toml", binding=Binding.PyO3, optional=True)] -except ImportError: + rust_extensions = [RustExtension("nsv._rust", path="rust/Cargo.toml", binding=Binding.PyO3, optional=False, py_limited_api=True)] + options = {"bdist_wheel": {"py_limited_api": "cp38"}} +else: rust_extensions = [] + options = {} setup( name="nsv", version="0.2.3", - packages=find_packages(), + packages=find_packages(exclude=["tests", "tests.*"]), description="Python implementation of the NSV (Newline-Separated Values) format", long_description=open("README.md").read(), long_description_content_type="text/markdown", @@ -45,6 +50,5 @@ "pandas": ["pandas"], }, rust_extensions=rust_extensions, - setup_requires=["setuptools-rust>=1.0"] if rust_extensions else [], - zip_safe=False, + options=options, )