From e65f8ffa48c4703c9e8c501641cbce4ec8c39ec0 Mon Sep 17 00:00:00 2001 From: jianfengmao Date: Mon, 21 Oct 2024 10:18:50 -0600 Subject: [PATCH] Add free-threaded build in GH action --- .github/workflows/build.yml | 1 - .github/workflows/build_ft_wheel.yml | 105 +++++++++++++++++++++++++++ .github/workflows/check.yml | 27 +++++++ 3 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build_ft_wheel.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c82a040..78d1e30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -79,7 +79,6 @@ jobs: distribution: 'temurin' java-version: '8' - - run: pip install setuptools - run: ${{ matrix.info.cmd }} - uses: actions/upload-artifact@v4 diff --git a/.github/workflows/build_ft_wheel.yml b/.github/workflows/build_ft_wheel.yml new file mode 100644 index 0000000..9bee2ba --- /dev/null +++ b/.github/workflows/build_ft_wheel.yml @@ -0,0 +1,105 @@ +name: Build Free-Threaded JPY distributions + +on: + pull_request: + branches: [ 'master', 'release/v*' ] + push: + branches: [ 'master', 'release/v*' ] + +jobs: + bdist-wheels: + runs-on: ${{ matrix.info.machine }} + strategy: + fail-fast: false + matrix: + info: + - { machine: 'ubuntu-20.04', python: '3.13t', arch: 'amd64', cmd: '.github/env/Linux/bdist-wheel.sh' } + - { machine: 'macos-13', python: '3.13t', arch: 'amd64', cmd: '.github/env/macOS/bdist-wheel.sh' } + - { machine: 'macos-latest', python: '3.13t', arch: 'arm64', cmd: '.github/env/macOS/bdist-wheel.sh' } + + steps: + - uses: actions/checkout@v4 + + - uses: astral-sh/setup-uv@v3 + - run: | + uv python install ${{ matrix.info.python }} + uv venv --python ${{ matrix.info.python }} + source .venv/bin/activate + uv pip install pip + echo $JAVA_HOME + echo PATH=$PATH >> $GITHUB_ENV + + - run: ${{ matrix.info.cmd }} + + - uses: actions/upload-artifact@v4 + with: + name: build-${{ matrix.info.python }}-${{ matrix.info.machine }}-${{ matrix.info.arch }} + path: dist/*.whl + retention-days: 1 + + bdist-wheels-windows: + runs-on: ${{ matrix.info.machine }} + strategy: + fail-fast: false + matrix: + info: + - { machine: 'windows-2022', python: '3.13t', arch: 'amd64', cmd: '.\.github\env\Windows\bdist-wheel.ps1' } + + steps: + - uses: actions/checkout@v4 + + - uses: astral-sh/setup-uv@v3 + - run: | + uv python install ${{ matrix.info.python }} + uv venv --python ${{ matrix.info.python }} + .venv\Scripts\Activate.ps1 + uv pip install pip + echo PATH=%PATH% >> $GITHUB_ENV + ${{ matrix.info.cmd }} + + - uses: actions/upload-artifact@v4 + with: + name: build-${{ matrix.info.python }}-${{ matrix.info.machine }}-${{ matrix.info.arch }} + path: dist/*.whl + retention-days: 1 + + bdist-wheels-linux-aarch64: + runs-on: ${{ matrix.info.machine }} + strategy: + fail-fast: false + matrix: + info: + - { machine: 'ubuntu-20.04', python: '3.13t', arch: 'aarch64', cmd: '.github/env/Linux/bdist-wheel.sh' } + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.21.3 + env: + CIBW_FREE_THREADED_SUPPORT: true + CIBW_ARCHS_LINUX: "aarch64" + CIBW_BUILD: "cp313t-*" + CIBW_SKIP: "cp313t-musllinux_aarch64" + CIBW_BEFORE_ALL_LINUX: > + yum install -y java-11-openjdk-devel && + yum install -y wget && + wget https://www.apache.org/dist/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz -P /tmp && + tar xf /tmp/apache-maven-3.8.8-bin.tar.gz -C /opt && + ln -s /opt/apache-maven-3.8.8/bin/mvn /usr/bin/mvn + CIBW_ENVIRONMENT: JAVA_HOME=/etc/alternatives/jre_11_openjdk + CIBW_REPAIR_WHEEL_COMMAND_LINUX: 'auditwheel repair --exclude libjvm.so -w {dest_dir} {wheel}' + + with: + package-dir: . + output-dir: dist + + - uses: actions/upload-artifact@v4 + with: + name: build-${{ matrix.info.python }}-${{ matrix.info.machine }}-${{ matrix.info.arch }} + path: dist/*.whl + retention-days: 1 + diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index dcdf1e5..3e07e41 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -29,3 +29,30 @@ jobs: - name: Run Test run: python setup.py test + + test-free-threaded: + runs-on: ubuntu-22.04 + strategy: + matrix: + java: ['8', '11', '17', '21', '23'] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: ${{ matrix.java }} + + - uses: astral-sh/setup-uv@v3 + - run: | + uv python install 3.13t + uv venv --python 3.13t + source .venv/bin/activate + uv pip install pip + echo PATH=$PATH >> $GITHUB_ENV + + - run: pip install "setuptools < 72" + + - name: Run Free-threaded Test + run: python setup.py test +