Skip to content
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

feat: Add windows support #157

Merged
merged 1 commit into from
Jan 26, 2024
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
72 changes: 61 additions & 11 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ on:
pull_request:
types: [opened, synchronize, reopened]

env:
MIN_PYTHON_VERSION: "3.8"


defaults:
run:
# Prevents windows runners from running on powershell
shell: bash

jobs:
linux:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
python-version: "${{ env.MIN_PYTHON_VERSION }}"
- name: Set up rust toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -40,21 +46,65 @@ jobs:
source .venv/bin/activate
make lint

- name: Test
# GitHub provides only x86_64 runners, so we cannot test on arm architecture
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

# Maturin requires a venv to be activated, that's why we have to create one here
- name: Create virtualenv
env:
BIN: ${{ matrix.os == 'windows-latest' && 'Scripts' || 'bin' }}
run: |
source .venv/bin/activate
make test-ci
python -m venv .venv
echo "${{ github.workspace }}/.venv/${{ env.BIN }}" >> $GITHUB_PATH

- name: Install dependencies
run: |
echo "PATH IS $PATH"
make install-test-requirements

macos:
runs-on: macos-latest
- name: Test
run: make test-ci

check-wheel-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
architecture: [x86-64, aarch64]
exclude:
- os: windows-latest
architecture: aarch64
steps:
- uses: actions/checkout@v4
- name: Set Rust target for aarch64
if: matrix.architecture == 'aarch64'
id: target
run: |
TARGET=${{ matrix.os == 'macos-latest' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu'}}
echo "target=$TARGET" >> $GITHUB_OUTPUT

- name: build (fast)
uses: messense/maturin-action@v1
with:
manylinux: auto
command: build
target: universal2-apple-darwin
args: "-o dist --interpreter python${{ matrix.python-version }}"
target: ${{ steps.target.outputs.target }}
47 changes: 46 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ jobs:
name: "wheels-macos-python-${{ matrix.python-version }}"
path: dist

windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: build (release)
uses: messense/maturin-action@v1
with:
command: build
args: "--release -o dist --interpreter python${{ matrix.python-version }}"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: "wheels-windows-python-${{ matrix.python-version }}"
path: dist

# NOTE: Cannot use a matrix here, as we only want a single release
release:
name: Release
Expand Down Expand Up @@ -103,13 +121,39 @@ jobs:
name: "wheels-macos-python-3.12"
path: wheels-macos

- name: Download Windows 3.8 wheels
uses: actions/download-artifact@v4
with:
name: "wheels-windows-python-3.8"
path: wheels-windows
- name: Download Windows 3.9 wheels
uses: actions/download-artifact@v4
with:
name: "wheels-windows-python-3.9"
path: wheels-windows
- name: Download Windows 3.10 wheels
uses: actions/download-artifact@v4
with:
name: "wheels-windows-python-3.10"
path: wheels-windows
- name: Download Windows 3.11 wheels
uses: actions/download-artifact@v4
with:
name: "wheels-windows-python-3.11"
path: wheels-windows
- name: Download Windows 3.12 wheels
uses: actions/download-artifact@v4
with:
name: "wheels-windows-python-3.12"
path: wheels-windows

- name: Publish to PyPI
uses: messense/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: "--skip-existing wheels-linux/*.whl wheels-macos/*.whl"
args: "--skip-existing wheels-linux/*.whl wheels-macos/*.whl wheels-windows/*.whl"

- name: Release
uses: softprops/action-gh-release@v1
Expand All @@ -118,3 +162,4 @@ jobs:
files: |
wheels-linux/*.whl
wheels-macos/*.whl
wheels-windows/*.whl
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ruff = ruff python/ *.py
format = ruff format python/ *.py
mypy = mypy python/ *.py
pytest = python -m pytest
pytest = pytest
## Rust
clippy = cargo clippy
fmt = cargo fmt
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ testpaths = [

[tool.ruff]
line-length = 100

target-version = "py38"
# Enable Pyflakes `E` and `F` codes by default.
select = ["E", "F", "I", "Q", "FA102"]
Loading