Skip to content

Commit c8ea46c

Browse files
authored
Merge pull request #9 from lutzfischer/build_cp313t
make it build for 3.13 and 3.14 freethreaded
2 parents 495b66d + 2edf956 commit c8ea46c

4 files changed

Lines changed: 73 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,53 @@ jobs:
1616
rid: linux-x64
1717
target: x86_64-unknown-linux-gnu
1818
ext: .so
19+
python-version: '3.9'
20+
- os: ubuntu-latest
21+
rid: linux-x64
22+
target: x86_64-unknown-linux-gnu
23+
ext: .so
24+
python-version: '3.13t'
25+
freethreaded: true
26+
- os: ubuntu-latest
27+
rid: linux-x64
28+
target: x86_64-unknown-linux-gnu
29+
ext: .so
30+
python-version: '3.14t'
31+
freethreaded: true
32+
- os: macos-latest
33+
rid: universal2
34+
target: universal2-apple-darwin
35+
ext: .dylib
36+
python-version: '3.9'
1937
- os: macos-latest
2038
rid: universal2
2139
target: universal2-apple-darwin
2240
ext: .dylib
41+
python-version: '3.13t'
42+
freethreaded: true
43+
- os: macos-latest
44+
rid: universal2
45+
target: universal2-apple-darwin
46+
ext: .dylib
47+
python-version: '3.14t'
48+
freethreaded: true
49+
- os: windows-latest
50+
rid: win-x64
51+
target: x86_64-pc-windows-msvc
52+
ext: .dll
53+
python-version: '3.9'
54+
- os: windows-latest
55+
rid: win-x64
56+
target: x86_64-pc-windows-msvc
57+
ext: .dll
58+
python-version: '3.13t'
59+
freethreaded: true
2360
- os: windows-latest
2461
rid: win-x64
2562
target: x86_64-pc-windows-msvc
2663
ext: .dll
64+
python-version: '3.14t'
65+
freethreaded: true
2766

2867
steps:
2968
- uses: actions/checkout@v4
@@ -75,7 +114,7 @@ jobs:
75114
- name: Set up Python
76115
uses: actions/setup-python@v5
77116
with:
78-
python-version: '3.9'
117+
python-version: ${{ matrix.python-version }}
79118

80119
- name: Copy README
81120
run: cp README.md native_fisher_py/
@@ -84,13 +123,13 @@ jobs:
84123
uses: PyO3/maturin-action@v1
85124
with:
86125
command: build
87-
args: --release --out dist --manifest-path native_fisher_py/Cargo.toml
126+
args: --release --out dist --manifest-path native_fisher_py/Cargo.toml ${{ matrix.freethreaded && '--no-default-features' || '' }}
88127
target: ${{ matrix.target }}
89128

90129
- name: Upload wheels
91130
uses: actions/upload-artifact@v4
92131
with:
93-
name: wheels-${{ matrix.os }}
132+
name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
94133
path: dist/*.whl
95134

96135
publish:

build.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ fi
1818

1919
echo "Building for RID: $RID"
2020

21+
# Some networks (e.g. VPNs with broken IPv6 routing) advertise an IPv6 route to
22+
# nuget.org that is actually black-holed, causing NuGet restores to hang for
23+
# minutes before failing with NU1301. Force IPv4 to avoid this.
24+
export DOTNET_SYSTEM_NET_DISABLEIPV6=1
25+
2126
# 1. Build C# NativeAOT
2227
cd native/ThermoNativeReader
2328
dotnet publish -r $RID -c Release -p:PublishAot=true
@@ -36,14 +41,27 @@ export THERMO_NATIVE_LIB=$(pwd)/python/native_fisher_py/$LIB_NAME
3641

3742
# Check for maturin
3843
cp ../README.md README.md
44+
MATURIN_ARGS="develop"
45+
for arg in "$@"; do
46+
case $arg in
47+
--wheel) MATURIN_ARGS="build --release --out ../dist" ;;
48+
# Free-threaded builds can't use the abi3 stable ABI, so this must be run
49+
# with a free-threaded interpreter (e.g. python3.13t) active/first on PATH.
50+
--freethreaded) MATURIN_ARGS="build --release --out ../dist --no-default-features" ;;
51+
esac
52+
done
3953
if command -v maturin >/dev/null 2>&1; then
40-
maturin develop
54+
maturin $MATURIN_ARGS
4155
elif command -v pipenv >/dev/null 2>&1 && pipenv run maturin --version >/dev/null 2>&1; then
42-
pipenv run maturin develop
56+
pipenv run maturin $MATURIN_ARGS
4357
else
4458
echo "Error: maturin not found. Please install it with 'pip install maturin' or 'pipenv install maturin'."
4559
exit 1
4660
fi
4761
cd ..
4862

49-
echo "Build complete. native-fisher-py is installed in your current environment."
63+
if [[ "$MATURIN_ARGS" == build* ]]; then
64+
echo "Build complete. Wheel written to dist/."
65+
else
66+
echo "Build complete. native-fisher-py is installed in your current environment."
67+
fi

native_fisher_py/Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,13 @@ name = "native_fisher_py_backend"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.27.0", features = ["abi3-py39"] }
12+
pyo3 = "0.27.0"
1313
libloading = "0.8"
14+
15+
# abi3 (the stable ABI) is not compatible with free-threaded Python builds, so
16+
# it's exposed as an opt-out feature: the release workflow builds the default
17+
# abi3 wheel normally, and builds version-specific cp313t/cp314t wheels with
18+
# `--no-default-features`.
19+
[features]
20+
default = ["abi3"]
21+
abi3 = ["pyo3/abi3-py39"]

native_fisher_py/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ classifiers = [
1111
"Programming Language :: Rust",
1212
"Programming Language :: Python :: Implementation :: CPython",
1313
"Programming Language :: Python :: Implementation :: PyPy",
14+
"Programming Language :: Python :: Free Threading",
1415
]
1516
license = { text = "MIT" }
1617
dynamic = ["version"]

0 commit comments

Comments
 (0)