From 7d767c14d2924d307247219a8c0ba060cf8a1ca5 Mon Sep 17 00:00:00 2001 From: synodriver Date: Wed, 27 Mar 2024 00:48:09 +0800 Subject: [PATCH] add ci build wheel --- .github/workflows/build_wheel_ci.yml | 40 +++++++++++++++++++++++++++ .github/workflows/upload_wheel_ci.yml | 39 ++++++++++++++++++++++++++ requirements.txt | 2 ++ setup.py | 7 +++-- 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build_wheel_ci.yml create mode 100644 .github/workflows/upload_wheel_ci.yml create mode 100644 requirements.txt diff --git a/.github/workflows/build_wheel_ci.yml b/.github/workflows/build_wheel_ci.yml new file mode 100644 index 0000000..054442b --- /dev/null +++ b/.github/workflows/build_wheel_ci.yml @@ -0,0 +1,40 @@ +name: build wheel with ci + +on: + workflow_dispatch: + +jobs: + build: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04, windows-2019, macos-13, macos-14] + fail-fast: false + env: + CIBW_BEFORE_BUILD: pip install -r requirements.txt + CIBW_ARCHS_LINUX: "x86_64 aarch64" + CIBW_ARCHS_WINDOWS: "AMD64 x86" + CIBW_ARCHS_MACOS: "x86_64 universal2 arm64" + CIBW_ENVIRONMENT: USE-CYTHON="1" USE-CFFI="1" + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" + steps: + - uses: actions/checkout@v4 + - name: Check out recursively + run: git submodule update --init --recursive + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 + with: + platforms: all + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.17.0 + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl \ No newline at end of file diff --git a/.github/workflows/upload_wheel_ci.yml b/.github/workflows/upload_wheel_ci.yml new file mode 100644 index 0000000..4313560 --- /dev/null +++ b/.github/workflows/upload_wheel_ci.yml @@ -0,0 +1,39 @@ +name: upload wheel with ci + +on: + workflow_dispatch: + +jobs: + build: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04, windows-2019, macos-13, macos-14] + fail-fast: false + env: + CIBW_BEFORE_BUILD: pip install -r requirements.txt + CIBW_ARCHS_LINUX: "x86_64 aarch64" + CIBW_ARCHS_WINDOWS: "AMD64 x86" + CIBW_ARCHS_MACOS: "x86_64 universal2 arm64" + CIBW_ENVIRONMENT: USE-CYTHON="1" USE-CFFI="1" + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8" + steps: + - uses: actions/checkout@v4 + - name: Check out recursively + run: git submodule update --init --recursive + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 + with: + platforms: all + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.17.0 twine + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + - name: Publish package + run: | + twine upload ./wheelhouse/*.whl -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1ec535a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +Cython>=3.0.9 +cffi>=1.0.0 diff --git a/setup.py b/setup.py index 621eeec..c034883 100644 --- a/setup.py +++ b/setup.py @@ -67,6 +67,9 @@ def has_option(name: str) -> bool: if name in sys.argv[1:]: sys.argv.remove(name) return True + name = name.strip("-").upper() + if os.environ.get(name, None) is not None: + return True return False @@ -75,7 +78,7 @@ def has_option(name: str) -> bool: setup_kw = {} if has_option("--use-cython"): print("building cython") - setup_requires.append("cython") + setup_requires.append("Cython>=3.0.9") setup_kw["ext_modules"] = cythonize( extensions, compiler_directives={ @@ -119,8 +122,6 @@ def main(): "Programming Language :: C", "Programming Language :: Cython", "Programming Language :: Python", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10",