Skip to content

Commit

Permalink
Merge pull request #195 from pyocd/maturin
Browse files Browse the repository at this point in the history
Replace Milksnake by Maturin
  • Loading branch information
flit authored Dec 17, 2022
2 parents c3fab8c + b12790f commit f7bb31c
Show file tree
Hide file tree
Showing 14 changed files with 1,913 additions and 122 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/ci-build-wheel-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,34 @@ jobs:
matrix:
os: [ubuntu-latest]
env:
CIBW_ARCHS_LINUX: auto aarch64
CIBW_SKIP: "cp27-* cp34-* cp35-* pp* *-win32"
CIBW_ARCHS_LINUX: auto # aarch64
CIBW_BUILD: "cp39-*"
CIBW_ENVIRONMENT: 'PATH="$PATH:/usr/share/rust/.cargo/bin:$HOME/.cargo/bin"'
CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel"
CIBW_BEFORE_BUILD: "python -m pip install --upgrade pip wheel setuptools setuptools_scm"
CIBW_BEFORE_ALL_LINUX: >
yum install -y libffi-devel openssl-devel &&
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.63.0 -y --profile=minimal &&
rustup show &&
cargo install empty-library || true
CIBW_BUILD_VERBOSITY: 1

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
with:
platforms: arm64

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.9'
python-version: 3.9

- name: Build wheels
uses: pypa/cibuildwheel@v2.1.3
uses: pypa/cibuildwheel@v2.11.2

- uses: actions/upload-artifact@v2
with:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci-build-wheel-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ jobs:
os: [macos-latest]
env:
CIBW_ARCHS_MACOS: x86_64 universal2
CIBW_SKIP: "cp27-* cp34-* cp35-* cp36-* pp* *-win32"
CIBW_BUILD: "cp39-*"
CIBW_ENVIRONMENT: 'PATH="$PATH:/usr/share/rust/.cargo/bin:$HOME/.cargo/bin"'
CIBW_BEFORE_BUILD: "python -m pip install --upgrade pip wheel setuptools setuptools_scm"
CIBW_BUILD_VERBOSITY: 1

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.63.0
profile: minimal

- name: Install Rust aarch64-apple-darwin target
run: rustup target add aarch64-apple-darwin

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.7'
python-version: 3.9

- name: Build wheels
uses: pypa/cibuildwheel@v2.1.3
uses: pypa/cibuildwheel@v2.11.2

- uses: actions/upload-artifact@v2
with:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci-build-wheel-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ jobs:
matrix:
os: [windows-latest]
env:
CIBW_SKIP: "cp27-* cp34-* cp35-* cp36-* pp* *-win32"
CIBW_BEFORE_BUILD: "python -m pip install --upgrade pip wheel setuptools setuptools_scm"
CIBW_BUILD: "cp39-*"
CIBW_BUILD_VERBOSITY: 1
RUSTFLAGS: "-Ctarget-feature=+crt-static"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.63.0
profile: minimal

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.7'
python-version: 3.9

- name: Build wheels
uses: pypa/cibuildwheel@v2.1.3
uses: pypa/cibuildwheel@v2.11.2

- uses: actions/upload-artifact@v2
with:
Expand Down
173 changes: 159 additions & 14 deletions .github/workflows/ci-build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,190 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
CIBW_ARCHS_LINUX: auto aarch64
CIBW_ARCHS_LINUX: auto # aarch64
CIBW_ARCHS_MACOS: x86_64 universal2
CIBW_ARCHS_WINDOWS: auto
CIBW_ENVIRONMENT_LINUX: 'PATH="$PATH:/usr/share/rust/.cargo/bin:$HOME/.cargo/bin"'
CIBW_ENVIRONMENT_MACOS: 'PATH="$PATH:/usr/share/rust/.cargo/bin:$HOME/.cargo/bin"'
CIBW_ENVIRONMENT_WINDOWS: 'RUSTFLAGS="-Ctarget-feature=+crt-static"'
CIBW_SKIP: "cp27-* cp34-* cp35-* pp*"
CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel"
CIBW_BEFORE_BUILD: "python -m pip install --upgrade pip wheel setuptools setuptools_scm"
CIBW_BUILD: "cp39-*"
CIBW_SKIP: "cp39-musl*"
CIBW_BEFORE_ALL_LINUX: >
yum install -y libffi-devel openssl-devel &&
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.63.0 --profile=minimal -y &&
rustup show &&
cargo install empty-library || true
CIBW_BUILD_VERBOSITY: 1

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Rust
if: runner.os != 'Linux'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.63.0
profile: minimal

- name: Install Rust aarch64-apple-darwin target
if: runner.os == 'macOS'
run: rustup target add aarch64-apple-darwin

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
with:
platforms: arm64
# - name: Set up QEMU
# if: runner.os == 'Linux'
# uses: docker/setup-qemu-action@v2
# with:
# platforms: arm64,arm

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.7'
python-version: 3.9

- name: Build wheels
uses: pypa/cibuildwheel@v2.1.3
uses: pypa/cibuildwheel@v2.11.2

- uses: actions/upload-artifact@v2
with:
name: wheels
path: ./wheelhouse/*.whl

linux-armv6:
name: Cross-build wheels for linux-armv6
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.63.0
profile: minimal
target: arm-unknown-linux-gnueabihf
default: true
- name: Install cross toolchain and build
run: |
brew tap messense/macos-cross-toolchains
brew install arm-unknown-linux-gnueabihf
export CC_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-gcc
export CXX_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-g++
export AR_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-ar
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-unknown-linux-gnueabihf-gcc
pip3 install maturin cffi
maturin build --release --target arm-unknown-linux-gnueabihf --out wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./wheelhouse/*.whl

linux-armv7:
name: Cross-build wheels for linux-armv7
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.63.0
profile: minimal
target: armv7-unknown-linux-gnueabihf
default: true
- name: Install cross toolchain and build
run: |
brew tap messense/macos-cross-toolchains
brew install armv7-unknown-linux-gnueabihf
export CC_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-gcc
export CXX_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-g++
export AR_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-ar
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=armv7-unknown-linux-gnueabihf-gcc
pip3 install maturin cffi
maturin build --release --target armv7-unknown-linux-gnueabihf --out wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./wheelhouse/*.whl

linux-aarch64:
name: Cross-build wheels for linux-aarch64
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.63.0
profile: minimal
target: aarch64-unknown-linux-gnu
default: true
- name: Install cross toolchain and build
run: |
brew tap messense/macos-cross-toolchains
brew install aarch64-unknown-linux-gnu
export CC_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnu-gcc
export CXX_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnu-g++
export AR_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnu-ar
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-unknown-linux-gnu-gcc
pip3 install maturin cffi
maturin build --release --target aarch64-unknown-linux-gnu --out wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./wheelhouse/*.whl

test-cross:
name: Test cross-built wheels (${{ matrix.platform.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- distro: ubuntu22.04
arch: aarch64
# - distro: bullseye
# arch: armv7
- distro: bullseye
arch: armv6
needs: [linux-armv6, linux-armv7, linux-aarch64]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: wheels
path: ./wheelhouse
- uses: uraimo/[email protected]
name: Install built wheel
with:
arch: ${{ matrix.platform.arch }}
distro: ${{ matrix.platform.distro }}
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y --no-install-recommends python3 python3-pip
pip3 install -U pip
run: |
pip3 install -U 'appdirs>=1.4,<2.0' cffi 'pyyaml>=6.0,<7.0' 'pytest>=6.0' hypothesis jinja2
pip3 install cmsis-pack-manager --no-index --find-links ./wheelhouse
rm -rf cmsis_pack_manager
python3 -c "import cmsis_pack_manager"
pytest --cache-clear
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
name: "${{ matrix.python-version }}"
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache Python modules
Expand All @@ -32,13 +32,14 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Install dependencies
run: |
rm -rf .cache .eggs rust_fst/_ffi.py build *.egg-info
find ./ -name "__pycache__" -type d -print0 |xargs -0 rm -rf
find ./ -name "*.pyc" -type f -print0 |xargs -0 rm -rf
find ./ -name "*.so" -type f -print0 |xargs -0 rm -rf
pip install -U setuptools pip wheel
pip install -U pip maturin
sudo apt install libffi-dev
- name: Compile
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/rust/Cargo.lock
/rust/target/
/rust/*/target/
/target/
!/target/header.h
/build
/dist
/cmsis_pack_manager/_version.py
Expand Down
Loading

0 comments on commit f7bb31c

Please sign in to comment.