From b323b1f6cb486324f4652846f13f6a69ce120eb6 Mon Sep 17 00:00:00 2001 From: Bo Bayles Date: Fri, 19 May 2023 11:12:29 -0500 Subject: [PATCH 1/3] Build wheels with cibuildwheel --- .github/workflows/build.yml | 39 +++++++++++++++++++ .../{build_test.yml => unit-tests.yml} | 21 +++------- Makefile | 7 +++- pyproject.toml | 16 ++++++++ 4 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{build_test.yml => unit-tests.yml} (56%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2da3ff3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: Build + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths-ignore: + - '**.rst' + - 'docs/**' + push: + branches: + - main + paths-ignore: + - '**.rst' + - 'docs/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build_wheels: + strategy: + matrix: + os: ["ubuntu-20.04", "macos-11"] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + make requirements c_lib + - name: Build wheels + uses: pypa/cibuildwheel@v2.12.3 + - name: Upload packages + uses: actions/upload-artifact@v3 + with: + name: ada-url-packages + path: wheelhouse/* diff --git a/.github/workflows/build_test.yml b/.github/workflows/unit-tests.yml similarity index 56% rename from .github/workflows/build_test.yml rename to .github/workflows/unit-tests.yml index 0ebcc24..5a2f907 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/unit-tests.yml @@ -1,4 +1,4 @@ -name: Build and test +name: Unit tests on: pull_request: @@ -21,38 +21,27 @@ jobs: build_test: strategy: matrix: - os: ["ubuntu-20.04", "macos-latest"] + os: ["ubuntu-20.04", "macos-11"] python: ["3.8", "3.9", "3.10", "3.11"] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python }} + - name: Set up Python 3.8 uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python }} + python-version: "3.8" - name: Install dependencies run: | make requirements - name: Build packages run: | make package - - name: Repair wheels - if: "matrix.os == 'ubuntu-20.04'" - run: | - pip install -U auditwheel patchelf - auditwheel repair --plat manylinux_2_24_x86_64 --wheel-dir dist dist/ada_url-*linux*.whl - name: Run tests run: | pip install -e . make coverage - - name: Build docs with sphinx - if: "matrix.python == '3.8' && matrix.os == 'ubuntu-20.04'" + - name: Check docs run: | make docs - - name: Upload packages - uses: actions/upload-artifact@v3 - with: - name: ada-url-packages - path: dist/* diff --git a/Makefile b/Makefile index 72bbd0f..d901402 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,11 @@ clean: $(RM) ada_url/_ada_wrapper.abi3.so $(RM) ada_url/ada.o -.PHONY: package -package: +.PHONY: c_lib +c_lib: $(CXX) -c "ada_url/ada.cpp" -fPIC -std="c++17" -O2 -o "ada_url/ada.o" + +.PHONY: package +package: c_lib python -m build --no-isolation twine check dist/* diff --git a/pyproject.toml b/pyproject.toml index a8254a9..9009b5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,3 +15,19 @@ exclude = [ ".git", ".ruff_cache", ] + +[tool.cibuildwheel] +build = [ + "cp38-*", + "cp39-*", + "cp310-*", + "cp311-*", + "pp38-*", + "pp39-*", +] + +[tool.cibuildwheel.linux] +archs = ["x86_64"] + +[tool.cibuildwheel.macos] +archs = ["x86_64", "universal2", "arm64"] From f6a84a4df08125683ca0bd7f1633ed6946d60e35 Mon Sep 17 00:00:00 2001 From: Bo Bayles Date: Fri, 19 May 2023 15:12:03 -0500 Subject: [PATCH 2/3] Drop python from matrix --- .github/workflows/unit-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 5a2f907..d476848 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -22,7 +22,6 @@ jobs: strategy: matrix: os: ["ubuntu-20.04", "macos-11"] - python: ["3.8", "3.9", "3.10", "3.11"] runs-on: ${{ matrix.os }} From d2667469b0ac8beda9235bb9ebbc018e7a8a8f2d Mon Sep 17 00:00:00 2001 From: Bo Bayles Date: Fri, 19 May 2023 15:26:01 -0500 Subject: [PATCH 3/3] Don't gather artifacts for PRs --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2da3ff3..aadbc72 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.12.3 - name: Upload packages + if: github.event_name == 'push' uses: actions/upload-artifact@v3 with: name: ada-url-packages