Skip to content

Commit 3410def

Browse files
authored
Run python unit tests in multiple Python versions (#84)
* Run Python unit tests in multiple Python versions in CI * fix * fix windows * forgor * try to debug windows a bit * Maybe fix? * Try to make old python versions work in ci * more fixes * more fixes? * aaaaaa * bbbbbb * more fixes! * some github environment variables * Rewrite test file to make it compatible with older python * I give up with python 3.4 and fix macos + python3.7 * Try to fix macos again * whoopsie * changelog
1 parent c18738c commit 3410def

4 files changed

Lines changed: 516 additions & 3 deletions

File tree

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
name: Python unit tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
unit_tests_modern:
9+
name: Python ${{ matrix.py_version }} unit tests on '${{ matrix.os.name }}' (modern)
10+
runs-on: ${{ matrix.os.runner }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [
15+
{
16+
name: linux,
17+
runner: ubuntu-latest,
18+
find_wheel_cmd: find ./dist/ -name "rabbitizer-*.whl"
19+
},
20+
{
21+
name: macos-arm,
22+
runner: macos-latest,
23+
find_wheel_cmd: find ./dist/ -name "rabbitizer-*.whl"
24+
},
25+
{
26+
name: macos-intel,
27+
runner: macos-15-intel,
28+
find_wheel_cmd: find ./dist/ -name "rabbitizer-*.whl"
29+
},
30+
{
31+
name: windows,
32+
runner: windows-latest,
33+
find_wheel_cmd: Get-ChildItem -Path .\dist\ -Recurse -Filter "rabbitizer-*.whl"
34+
},
35+
]
36+
py_version:
37+
- '3.8'
38+
- '3.9'
39+
- '3.10'
40+
- '3.11'
41+
- '3.12'
42+
- '3.13'
43+
- '3.14'
44+
- '3.14t'
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@main
49+
50+
- name: Print Python version
51+
run: |
52+
python3 --version
53+
54+
- name: Set up Python ${{ matrix.py_version }}
55+
uses: actions/setup-python@v6
56+
with:
57+
python-version: ${{ matrix.py_version }}
58+
59+
- name: Install uv
60+
uses: astral-sh/setup-uv@v7
61+
62+
- name: Setup Python venv
63+
run: |
64+
python3 --version
65+
uv venv .venv --no-config -p ${{ matrix.py_version }}
66+
uv run --no-config --no-build --no-sync python --version
67+
68+
- name: Check Python version
69+
shell: bash
70+
run: |
71+
uv run --no-config --no-build --no-sync python --version
72+
# Ensure the installed version is the version we are expecting
73+
# The version check needs to be `in` to account for free threaded python
74+
uv run --no-config --no-build --no-sync python -c "import sys; exit(not (str(sys.version_info[0])+'.'+str(sys.version_info[1]) in '${{ matrix.py_version }}'))"
75+
76+
- name: Build wheel
77+
run: |
78+
uv build --wheel
79+
80+
- name: Install wheel
81+
run: |
82+
${{ matrix.os.find_wheel_cmd }}
83+
uv pip install --force-reinstall $(${{ matrix.os.find_wheel_cmd }})
84+
85+
- name: Run the test
86+
run: |
87+
uv run --no-config --no-build --no-sync python tests/python/disasm_test.py
88+
89+
unit_tests_old:
90+
name: Python ${{ matrix.py_version }} unit tests on '${{ matrix.os.name }}' (old)
91+
runs-on: ${{ matrix.os.runner }}
92+
strategy:
93+
fail-fast: false
94+
matrix:
95+
os: [
96+
{
97+
name: linux,
98+
runner: ubuntu-latest,
99+
},
100+
{
101+
name: macos-intel,
102+
runner: macos-15-intel,
103+
},
104+
{
105+
name: windows,
106+
runner: windows-latest,
107+
},
108+
]
109+
py_version:
110+
- '3.5'
111+
- '3.6'
112+
- '3.7'
113+
114+
steps:
115+
- name: Checkout
116+
uses: actions/checkout@main
117+
118+
- name: Print Python version
119+
run: |
120+
python3 --version
121+
122+
- name: Set up Python ${{ matrix.py_version }} (windows)
123+
uses: actions/setup-python@v6
124+
if: ${{ matrix.os.name == 'windows' }}
125+
with:
126+
python-version: ${{ matrix.py_version }}
127+
128+
- name: Set up pyenv (unix)
129+
if: ${{ matrix.os.name != 'windows' }}
130+
run: |
131+
curl -fsSL https://pyenv.run | bash
132+
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> $GITHUB_ENV
133+
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> $GITHUB_ENV
134+
135+
- name: Set up Python ${{ matrix.py_version }} (unix)
136+
shell: bash
137+
if: ${{ matrix.os.name != 'windows' }}
138+
run: |
139+
echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV
140+
echo "$HOME/.pyenv/bin" >> $GITHUB_PATH
141+
echo "$HOME/.pyenv/shims" >> $GITHUB_PATH
142+
143+
export PYENV_ROOT="$HOME/.pyenv"
144+
export PATH="$PYENV_ROOT/bin:$PATH"
145+
146+
eval "$(pyenv init -)"
147+
148+
# macos legacy fixes
149+
export PYTHON_CONFIGURE_OPTS="--without-ensurepip"
150+
export TMPDIR=/tmp
151+
152+
if [[ "$RUNNER_OS" == "macOS" ]]; then
153+
brew install openssl@1.1 || true
154+
155+
OPENSSL_PREFIX="$(brew --prefix openssl@1.1)"
156+
157+
export LDFLAGS="-L$OPENSSL_PREFIX/lib"
158+
export CPPFLAGS="-I$OPENSSL_PREFIX/include"
159+
export PKG_CONFIG_PATH="$OPENSSL_PREFIX/lib/pkgconfig"
160+
161+
export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --with-openssl=$OPENSSL_PREFIX"
162+
fi
163+
# macos legacy fixes
164+
165+
pyenv install -s ${{ matrix.py_version }}
166+
pyenv global ${{ matrix.py_version }}
167+
pyenv local ${{ matrix.py_version }}
168+
169+
python --version
170+
171+
- name: Check Python version
172+
shell: bash
173+
run: |
174+
python --version
175+
# Ensure the installed version is the version we are expecting
176+
python -c "import sys; exit(not (str(sys.version_info[0])+'.'+str(sys.version_info[1]) == '${{ matrix.py_version }}'))"
177+
178+
# We can't use ensure pip because it breaks macos + python 3.7
179+
- name: Install pip manually
180+
shell: bash
181+
run: |
182+
curl -sS https://bootstrap.pypa.io/pip/${{ matrix.py_version }}/get-pip.py -o get-pip.py
183+
python get-pip.py "pip<24" "setuptools<68" "wheel"
184+
185+
- name: Build and install wheel
186+
shell: bash
187+
run: |
188+
python -m pip install .
189+
190+
- name: Run the test
191+
shell: bash
192+
run: |
193+
python tests/python/disasm_test.py

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- This allows us to build a single wheel that can work in multiple Python
1414
versions, instead of needing to build a wheel for each Python version.
1515
- The minimum Python version for `abi3` compatibility is 3.4 now.
16-
- Install the built wheels in CI to make sure they work corrently in multiple
17-
versions.
16+
- CI:
17+
- Install the built wheels in CI to make sure they work corrently in multiple
18+
versions.
19+
- CI now tests compatibility with Python versions from 3.5 to 3.14 on Linux,
20+
Macos Intel, Macos Arm and Windows.
21+
22+
### Changed
23+
24+
- The minimum Python version has been lowered from 3.9 to 3.4.
25+
- CI: Python unit tests are now tested in multiple Python versions in CI.
1826

1927
## [1.14.3] - 2025-10-12
2028

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ authors = [
1818
"Bug Tracker" = "https://github.com/Decompollaborate/rabbitizer/issues"
1919

2020
[build-system]
21-
requires = ["setuptools>=65.0", "wheel"]
21+
requires = ["setuptools>=43.0", "wheel"]
2222
build-backend = "setuptools.build_meta"
2323

2424
[tool.setuptools]

0 commit comments

Comments
 (0)