Skip to content

Commit f5791b3

Browse files
authored
Many wheel changes (#52)
* Test adding 3.14t and other wheels to ci * Change Python tests to run with different Python versions * bump to 3.8 * fix * get rid of dry run * changelog
1 parent 4fcb7f9 commit f5791b3

16 files changed

Lines changed: 766 additions & 112 deletions

.github/scripts/ci_check_wheel.ps1

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# A Powershell port of `ci_check_wheel.sh`. Refer to that script instead.
2+
3+
# Any change made here should be made in `ci_check_wheel.sh` too.
4+
5+
param (
6+
[Parameter(Mandatory = $true)]
7+
[string]$PYTHON_VERSION,
8+
9+
[Parameter(Mandatory = $true)]
10+
[string]$KEY,
11+
12+
[string]$EXTRA
13+
)
14+
15+
# Equivalent to `set -e`
16+
$ErrorActionPreference = "Stop"
17+
18+
if (Test-Path ".venv") {
19+
Remove-Item -Recurse -Force ".venv"
20+
}
21+
22+
# When $EXTRA is empty powershell passes the argument as an empty argument to
23+
# uv, so we need to explicitly check the argument and only pass it if it is not
24+
# empty to avoid uv from erroring
25+
if ($EXTRA) {
26+
uv venv --no-project .venv -p $PYTHON_VERSION $EXTRA
27+
} else {
28+
uv venv --no-project .venv -p $PYTHON_VERSION
29+
}
30+
31+
uv run --no-sync python --version
32+
33+
$WHEEL = $(Get-ChildItem -Path .\dist\ -Recurse -Filter "mapfile_parser-*-abi3-*")
34+
if ([string]::IsNullOrEmpty($WHEEL)) {
35+
Write-Host "Wheel not found"
36+
exit 1
37+
}
38+
uv pip install --no-cache --no-config $WHEEL
39+
40+
uv run --no-sync python -c "import mapfile_parser; print(mapfile_parser.__version__)"

.github/scripts/ci_check_wheel.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This script checks a given Python wheel inside the `dist` is installable in a
2+
# given Python version.
3+
#
4+
# It recieves the following arguments:
5+
# - The python version to check, it must be compatible with uv.
6+
# - A key value to allow searching for the wheel in the `dist` folder. Only a
7+
# single wheel in the folder must contain this value in its name.
8+
# Recommended values: abi3, cp314t, pypy39 and similar values.
9+
# - (OPTIONAL) A single aditional flag to pass to `uv venv`.
10+
# Usually `--managed-python`.
11+
12+
# Any change made here should be made in `ci_check_wheel.ps1` too.
13+
14+
PYTHON_VERSION=$1
15+
KEY=$2
16+
EXTRA=$3
17+
18+
# Exit with an error value if any command produces an error.
19+
set -e
20+
21+
# We make a venv with the Python version we were told to.
22+
rm -rf .venv
23+
uv venv --no-project -p $PYTHON_VERSION $EXTRA
24+
# Allows us to check we are actually using the requested Python version.
25+
# --no-sync avoids building the wheel from source
26+
uv run --no-sync python --version
27+
28+
# We install the wheel by looking it up in the dist folder.
29+
# We need to do a `find` command here because we don't know the exact name of
30+
# the wheel (it can be affected by package version, arch, python version, etc.).
31+
WHEEL=$(find ./dist/ -name "mapfile_parser-*-$KEY*")
32+
if [ -z "$WHEEL" ]; then
33+
echo "Wheel not found"
34+
exit 1
35+
fi
36+
uv pip install --no-cache --no-config "$WHEEL"
37+
# Check something basic to make sure it was installed correctly.
38+
uv run --no-sync python -c "import mapfile_parser; print(mapfile_parser.__version__)"

.github/workflows/linting.yml

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,87 @@
1-
name: Linting
1+
name: Python linting
22

33
# Build on every branch push, tag push, and pull request change:
44
on: [push, pull_request]
55

66
jobs:
77
mypy:
88
name: mypy
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-22.04
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
py_version:
14+
- '3.8'
15+
1016
steps:
1117
- name: Checkout reposistory
1218
uses: actions/checkout@main
1319

14-
- name: Set up Python 3.9
20+
- name: Set up Python ${{ matrix.py_version }}
1521
uses: actions/setup-python@main
1622
with:
17-
python-version: 3.9
23+
python-version: ${{ matrix.py_version }}
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v7
1827

28+
# Setup venv and install dependencies without building the project from source.
1929
- name: Install Dependencies
2030
run: |
21-
python3 -m pip install -r requirements.txt
22-
python3 -m pip install -U maturin
23-
python3 -m pip install -U mypy
31+
uv venv --no-project --python ${{ matrix.py_version }}
32+
uv sync --no-install-project
33+
uv pip install -U mypy
2434
2535
- name: mypy
26-
run: mypy --show-column-numbers --hide-error-context .
36+
run: |
37+
uv run --no-sync mypy --show-column-numbers --hide-error-context .
2738
2839
ruff:
29-
runs-on: ubuntu-latest
3040
name: ruff
41+
runs-on: ubuntu-22.04
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
py_version:
46+
- '3.8'
47+
3148
steps:
3249
- name: Checkout repository
3350
uses: actions/checkout@main
3451

35-
- name: Set up Python 3.9
52+
- name: Set up Python ${{ matrix.py_version }}
3653
uses: actions/setup-python@main
3754
with:
38-
python-version: '3.9'
55+
python-version: ${{ matrix.py_version }}
3956

40-
- name: Setup venv
41-
run: |
42-
python3 -m venv .venv
43-
44-
- name: Install Dependencies
45-
run: |
46-
. .venv/bin/activate
47-
python3 -m pip install -U -r requirements.txt
48-
python3 -m pip install -U ruff
57+
- name: Install uv
58+
uses: astral-sh/setup-uv@v7
4959

50-
- name: mypy
60+
- name: ruff
5161
run: |
52-
. .venv/bin/activate
53-
ruff check
62+
uvx ruff check src/
5463
5564
ruff_format:
5665
name: ruff format
57-
runs-on: ubuntu-latest
66+
runs-on: ubuntu-22.04
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
py_version:
71+
- '3.8'
72+
5873
steps:
5974
- name: Checkout repository
6075
uses: actions/checkout@main
6176

62-
- name: Set up Python 3.9
77+
- name: Set up Python ${{ matrix.py_version }}
6378
uses: actions/setup-python@main
6479
with:
65-
python-version: 3.9
80+
python-version: ${{ matrix.py_version }}
6681

67-
- name: Setup venv
68-
run: |
69-
python3 -m venv .venv
82+
- name: Install uv
83+
uses: astral-sh/setup-uv@v7
7084

71-
- name: Install dependencies
72-
run: |
73-
. .venv/bin/activate
74-
python3 -m pip install -U ruff
75-
76-
- name: mypy
85+
- name: ruff
7786
run: |
78-
. .venv/bin/activate
79-
ruff format src/ --check
87+
uvx ruff format src/ --check

0 commit comments

Comments
 (0)