From c436fe3d2f30ce7bcc268a2fa51cb975e7adcb06 Mon Sep 17 00:00:00 2001 From: Delio Vicini Date: Wed, 25 Dec 2024 13:59:11 +0100 Subject: [PATCH] update github actions --- .github/workflows/macOS_arm64_toolchain.cmake | 4 - .github/workflows/pip.yml | 38 +++++++++ .github/workflows/tag_wheel_manylinux.py | 77 ----------------- .github/workflows/wheels.yml | 84 ++++--------------- 4 files changed, 55 insertions(+), 148 deletions(-) delete mode 100644 .github/workflows/macOS_arm64_toolchain.cmake create mode 100644 .github/workflows/pip.yml delete mode 100755 .github/workflows/tag_wheel_manylinux.py diff --git a/.github/workflows/macOS_arm64_toolchain.cmake b/.github/workflows/macOS_arm64_toolchain.cmake deleted file mode 100644 index da5ec5e..0000000 --- a/.github/workflows/macOS_arm64_toolchain.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(CMAKE_SYSTEM_NAME Darwin) -set(CMAKE_SYSTEM_PROCESSOR arm64) -set(HAS_LIBCPP_EXITCODE 0) -set(HAS_LIBCPP_EXITCODE__TRYRUN_OUTPUT \"\") diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml new file mode 100644 index 0000000..9d12698 --- /dev/null +++ b/.github/workflows/pip.yml @@ -0,0 +1,38 @@ +name: Pip + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + +jobs: + build: + name: Build with Pip + runs-on: ${{ matrix.platform }} + strategy: + fail-fast: false + matrix: + platform: [windows-latest, macos-latest, ubuntu-latest] + python-version: ["3.8", "3.12"] + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Set min macOS version + if: runner.os == 'macOS' + run: | + echo "MACOSX_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV + + - name: Build and install + run: | + python -m pip install pytest numpy drjit + pip install --verbose . + + - name: Test + run: python -m pytest diff --git a/.github/workflows/tag_wheel_manylinux.py b/.github/workflows/tag_wheel_manylinux.py deleted file mode 100755 index 37fbb87..0000000 --- a/.github/workflows/tag_wheel_manylinux.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python -""" -Usage: tag_wheel_manylinux.py {wheel_file} {dest_dir} - -This script manually replaces the '*-linux_x86_64' tag of a Python wheel -`wheel_file` with the following tags: -- '*-manylinux_2_17_x86_64' -- '*-manylinux2014_x86_64' - -The new wheel is written to `dest_dir` with a filename that reflects the new -tags. -""" - -import os -import pathlib -import re -import shutil -import subprocess -import sys - - -def process_wheel_info_file(file): - """ - Modifies the metadata "WHEEL" file given as `file` such to have the - appropriate 'manylinux' platform tags instead of the generic 'linux' one. - """ - metadata_lines = file.read().splitlines() - new_metadata_lines = [] - - for i in range(len(metadata_lines)): - line = metadata_lines[i] - if re.match("^Tag: .*-linux_x86_64$", line): - new_line = line.replace("-linux_x86_64", "-manylinux_2_17_x86_64") - new_metadata_lines.append(new_line) - - new_line = line.replace("-linux_x86_64", "-manylinux2014_x86_64") - new_metadata_lines.append(new_line) - else: - new_metadata_lines.append(line) - - file.seek(0) - file.write("\n".join(new_metadata_lines)) - file.truncate() - - -if __name__ == "__main__": - if len(sys.argv) != 3: - raise RuntimeError("Exactly two arugments are expected: the wheel " - "archive file and the output directory!") - - wheel_loc = sys.argv[1] - output_dir = sys.argv[2] - - wheel_filename = os.path.basename(wheel_loc) - version_begin = wheel_filename.find("-") - wheel_package_prefix = wheel_filename[: wheel_filename.find("-", version_begin + 1)] - - unpack_dir = f"/tmp/{os.path.splitext(os.path.basename(__file__))[0]}/{wheel_package_prefix}" - shutil.rmtree(unpack_dir, ignore_errors=True) - os.makedirs(unpack_dir, exist_ok=False) - os.makedirs(output_dir, exist_ok=True) - - # The `wheel` package drops all file permissions when unpacking - subprocess.check_call(["unzip", "-q", wheel_loc, "-d", unpack_dir]) - - with open( - f"{unpack_dir}/{wheel_package_prefix}.dist-info/WHEEL", - "r+", - ) as wheel_info_file: - process_wheel_info_file(wheel_info_file) - - # The `wheel` package will recompute the hash of every file and modify the RECORD file - # It also renames the packed wheel to reflect the new platform tags - subprocess.check_call([ - sys.executable, "-m", - "wheel", "pack", f"{unpack_dir}", "-d", output_dir, - ]) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index cd0894b..ec7a2e8 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -10,26 +10,14 @@ on: types: - published -env: - CIBW_SKIP: "*-musllinux* pp* cp36-* cp37-*" - CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 - CIBW_ARCHS_WINDOWS: auto64 - CIBW_ARCHS_LINUX: auto64 - CIBW_REPAIR_WHEEL_COMMAND_LINUX: "python .github/workflows/tag_wheel_manylinux.py {wheel} {dest_dir}" - CIBW_REPAIR_WHEEL_COMMAND_MACOS: "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} --ignore-missing-dependencies {wheel}" - CIBW_TEST_COMMAND: "python -c \"import fastsweep\"" - CIBW_TEST_REQUIRES: pytest numpy drjit - CIBW_TEST_SKIP: "*-macosx_arm64" - MACOSX_DEPLOYMENT_TARGET: 10.14 - jobs: build_sdist: name: Build SDist runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: - submodules: recursive + submodules: true - name: Build SDist run: pipx run build --sdist @@ -43,64 +31,24 @@ jobs: path: dist/*.tar.gz build_wheels: - name: > - Build wheels on ${{ matrix.os }} - ${{ (matrix.os == 'macos-latest' && format('({0})', matrix.cibw-arch)) || '' }} + name: Wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: - matrix: - os: [ubuntu-20.04, windows-latest] - include: - - os: macos-latest - cibw-arch: x86_64 - - os: macos-latest - cibw-arch: arm64 fail-fast: false + matrix: + os: [ubuntu-latest, macos-13, macos-14, windows-latest] steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - uses: actions/setup-python@v4 - name: Install Python - with: - python-version: '3.10' - - - name: Prepare compiler environment for Windows - if: runner.os == 'Windows' - uses: ilammy/msvc-dev-cmd@v1 + - uses: actions/checkout@v4 with: - arch: x64 + submodules: true - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.11.2 - - - name: Prepare cibuildwheel environment for macOS - if: runner.os == 'macOS' - run: | - [[ "arm64" == "${{ matrix.cibw-arch }}" ]] && \ - echo "FASTSWEEP_CMAKE_TOOLCHAIN_FILE=$(pwd)/.github/workflows/macOS_arm64_toolchain.cmake" >> $GITHUB_ENV && \ - echo "CIBW_BEFORE_BUILD_MACOS=\ - rm -rf /tmp/drjit_wheel && mkdir -p /tmp/drjit_wheel/ && cd /tmp/drjit_wheel && \ - pip download --platform=macosx_11_0_arm64 --only-binary=:all: drjit && \ - unzip *.whl" >> $GITHUB_ENV && \ - echo "FASTSWEEP_DRJIT_CMAKE_DIR=/tmp/drjit_wheel/drjit/share/cmake/drjit" >> $GITHUB_ENV - - echo "CIBW_ARCHS_MACOS=${{ matrix.cibw-arch }}" >> $GITHUB_ENV - - - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse + - uses: pypa/cibuildwheel@v2.22 - name: Verify clean directory run: git diff --exit-code shell: bash - - name: Check metadata - run: pipx run twine check wheelhouse/* - - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -112,15 +60,17 @@ jobs: needs: [build_wheels, build_sdist] runs-on: ubuntu-latest if: github.event_name == 'release' && github.event.action == 'published' - steps: - - uses: actions/setup-python@v2 - - uses: actions/download-artifact@v2 + steps: + - uses: actions/setup-python@v5 + - uses: actions/download-artifact@v4 with: - name: artifact - path: dist + name: dist + pattern: dist-* + merge-multiple: true - - uses: pypa/gh-action-pypi-publish@v1.5.0 + - uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file + password: ${{ secrets.PYPI_API_TOKEN }} + \ No newline at end of file