Skip to content

Uses cibuildwheel for releases #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .ci/osx_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e -x

arm64_set_path_and_python_version(){
python_version="$1"
if [[ $(/usr/bin/arch) = arm64 ]]; then
export PATH=/opt/homebrew/bin:$PATH
eval "$(pyenv init --path)"
pyenv install $python_version -s
pyenv global $python_version
export PATH=$(pyenv prefix)/bin:$PATH
fi
}
17 changes: 0 additions & 17 deletions .github/actions/scripts/manylinux_entrypoint.sh

This file was deleted.

266 changes: 186 additions & 80 deletions .github/workflows/create.yml
Original file line number Diff line number Diff line change
@@ -1,100 +1,206 @@
on: create
on:
push:
pull_request:
create:

name: Continuous Delivery
jobs:
PrepareRelease:
name: prepare-release
if: startsWith(github.ref, 'refs/tags/')
build_wheels:
name: cibuildwheel on ${{ matrix.os }} ${{ matrix.architecture }}
if: (github.event_name == 'create' && github.event.ref_type == 'tag') || contains(github.event.head_commit.message, '[build wheel]') || contains(github.event.pull_request.title, '[build wheel]')
env:
CIBW_BEFORE_ALL_LINUX: 'yum install -y java-11-openjdk-devel'
CIBW_ARCHS_MACOS: "x86_64 universal2"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ''
strategy:
matrix:
python:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
java:
- '12'
os:
- 'windows-latest'
- 'macOs-latest'
architecture:
- 'x64'
- 'x86'

# exclude problematic combinations
exclude:
- os: ubuntu-latest
architecture: 'x86'
- os: macOs-latest
architecture: 'x86'

os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
architecture: ['x64']
include:
- os: windows-latest
architecture: 'x86'
cibw_skip: '*_amd64'
- os: windows-latest
architecture: 'x64'
cibw_skip: '*-win32'
- os: ubuntu-latest
architecture: 'x64'
cibw_skip: '*-manylinux_i686'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.architecture }}
- name: Checkout pyjnius
uses: actions/checkout@v3

- name: Setup java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
architecture: ${{ matrix.architecture }}

- name: build sdist
if: matrix.os == 'windows-latest' && matrix.python == '3.8' && matrix.architecture == 'x64'
run: |
pip install -U setuptools
python setup.py sdist

- name: build-wheel-windows
if: matrix.os == 'windows-latest'
run: |
"%VS140COMNTOOLS%../../VC/vcvarsall.bat"
echo "$INCLUDE"
set INCLUDE "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
pip install --timeout=120 -U setuptools wheel cython
python setup.py bdist_wheel

- name: build wheel
if: matrix.os != 'windows-latest'
run: |
pip install -U --timeout=120 -U setuptools wheel cython
python setup.py bdist_wheel

- name: upload wheel
uses: actions/upload-artifact@master
with:
name: dist
path: dist
- name: Setup Python
uses: actions/setup-python@v3

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.6.0

- name: Setup java
# There's no need to setup java on ubuntu-latest, as build is done into a manylinux
# containerized environment. (CIBW_BEFORE_ALL_LINUX) takes care of it.
if: ${{ matrix.os != 'ubuntu-latest' }}
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
architecture: ${{ matrix.architecture }}

PrepareManylinux:
name: prepare-manylinux
if: startsWith(github.ref, 'refs/tags/')
- name: Build wheels
env:
CIBW_SKIP: '*musllinux* ${{ matrix.cibw_skip }}'
run: python -m cibuildwheel --output-dir dist

- name: upload wheels
uses: actions/upload-artifact@v2
with:
name: dist
path: dist

build_sdist:
name: Build sdist
if: (github.event_name == 'create' && github.event.ref_type == 'tag') || contains(github.event.head_commit.message, '[build sdist]') || contains(github.event.pull_request.title, '[build sdist]')
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@master
- name: Checkout pyjnius
uses: actions/checkout@v3

- uses: docker://quay.io/pypa/manylinux2010_x86_64
with:
entrypoint: .github/actions/scripts/manylinux_entrypoint.sh
- name: Setup Python
uses: actions/setup-python@v3

- name: upload wheel
uses: actions/upload-artifact@master
with:
name: dist
path: dist
- name: Build sdist
run: |
pip install -U setuptools
python setup.py sdist

- name: upload sdist
uses: actions/upload-artifact@v2
with:
name: dist
path: dist

test_wheels:
name: Test wheel on ${{ matrix.os }} (${{ matrix.architecture }}) Python ${{ matrix.python }}
if: (github.event_name == 'create' && github.event.ref_type == 'tag') || contains(github.event.head_commit.message, '[build wheel]') || contains(github.event.pull_request.title, '[build wheel]')
needs:
- build_wheels
continue-on-error: true
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python: ['3.7', '3.8', '3.9', '3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9']
include:
# We may would like to introduce tests also on windows-latest on x86 (win32 wheels)?
- os: windows-latest
architecture: 'x64'
- os: macos-latest
architecture: 'x64'
- os: ubuntu-latest
architecture: 'x64'
- os: apple-silicon-m1
architecture: 'aarch64'
python: '3.8.13'
- os: apple-silicon-m1
architecture: 'aarch64'
python: '3.9.11'
- os: apple-silicon-m1
architecture: 'aarch64'
python: '3.10.3'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout pyjnius
uses: actions/checkout@v3

- uses: actions/download-artifact@v2
with:
name: dist
path: dist

- name: Setup Python
# Needs to be skipped on our self-hosted runners tagged as 'apple-silicon-m1'
if: ${{ matrix.os != 'apple-silicon-m1' }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}

- name: Setup java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
architecture: ${{ matrix.architecture }}

- name: Setup ant on macOS
if: (matrix.os == 'macos-latest') || (matrix.os == 'apple-silicon-m1')
run: |
source .ci/osx_ci.sh
arm64_set_path_and_python_version ${{ matrix.python }}
brew install ant

- name: Build test-classes via ant (macOS x64, macOS Apple Silicon)
if: (matrix.os == 'macos-latest') || (matrix.os == 'apple-silicon-m1')
run: |
source .ci/osx_ci.sh
arm64_set_path_and_python_version ${{ matrix.python }}
ant all

- name: Build test-classes via ant (Linux, Windows)
if: (matrix.os == 'ubuntu-latest') || (matrix.os == 'windows-latest')
run: ant all

- name: Install pyjnius wheel + test prerequisites (Windows, Linux, macOS x64)
if: matrix.os != 'apple-silicon-m1'
run: python -m pip install --find-links=dist pyjnius[dev,ci]

- name: Install pyjnius wheel + test prerequisites (Apple Silicon M1)
if: matrix.os == 'apple-silicon-m1'
run: |
source .ci/osx_ci.sh
arm64_set_path_and_python_version ${{ matrix.python }}
python -m pip install --find-links=dist pyjnius[dev,ci]

- name: Test wheel (Linux, macOS x64)
if: (matrix.os == 'ubuntu-latest') || (matrix.os == 'macos-latest')
run: |
cd tests
CLASSPATH=../build/test-classes:../build/classes python -m pytest -v

- name: Test wheel (macOS Apple Silicon)
if: matrix.os == 'apple-silicon-m1'
run: |
source .ci/osx_ci.sh
arm64_set_path_and_python_version ${{ matrix.python }}
cd tests
CLASSPATH=../build/test-classes:../build/classes python -m pytest -v

- name: Test wheel ( Windows + Python == 3.7.x )
# On Python < 3.8.x, we can't use `os.add_dll_directory`, so the jre should be in PATH.
if: (matrix.os == 'windows-latest') && contains(matrix.python, '3.7')
run: |
cd tests
$env:PATH +=";$env:JAVA_HOME\jre\bin\server\;$env:JAVA_HOME\jre\bin\client\;$env:JAVA_HOME\bin\server\"
$env:CLASSPATH ="../build/test-classes;../build/classes"
python -m pytest -v

- name: Test wheel (Windows + Python != 3.7.x )
if: (matrix.os == 'windows-latest') && !contains(matrix.python, '3.7')
run: |
cd tests
$env:CLASSPATH ="../build/test-classes;../build/classes"
python -m pytest -v


Release:
release:
if: (github.event_name == 'create' && github.event.ref_type == 'tag')
name: release
needs:
- PrepareRelease
- PrepareManylinux
- build_wheels
- build_sdist
- test_wheels
runs-on: 'ubuntu-latest'
steps:
- uses: actions/download-artifact@master
- uses: actions/download-artifact@v2
with:
name: dist
path: dist
Expand Down