Skip to content

Commit 380f8ec

Browse files
authored
fix: prevent unnecessary pyo3 build step and fix cargo workspace build (#85)
* Disable default pyo3 features and enable macros Rename Python binding crate and fix macOS linking Add macOS linker flag for pyo3 dynamic symbol resolution * Update pyo3 dependency to version 0.27.2 * Update jingle dependency to version 0.3.6 * Update GitHub workflow to add Python 3.14 support * Update documented Python support to include 3.14 and drop 3.10
1 parent a668409 commit 380f8ec

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

.github/workflows/python.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
- main
1515
workflow_dispatch:
1616
release:
17-
types: [ published ]
17+
types: [published]
1818

1919
permissions:
2020
contents: read
@@ -38,7 +38,7 @@ jobs:
3838
uses: PyO3/maturin-action@v1
3939
with:
4040
target: ${{ matrix.platform.target }}
41-
args: --release --out dist --interpreter python3.10 python3.11 python3.12 python3.13 python3.13t pypy3.10 pypy3.11 --auditwheel skip
41+
args: --release --out dist --interpreter python3.11 python3.12 python3.13 python3.14 python3.13t python3.14t --auditwheel skip
4242
working-directory: crackers_python
4343
manylinux: manylinux2_28
4444
before-script-linux: |
@@ -68,7 +68,7 @@ jobs:
6868
platform:
6969
- runner: windows-latest
7070
target: x64
71-
python: [ '3.11', '3.12', '3.13' ]
71+
python: ["3.11", "3.12", "3.13", "3.14"]
7272
steps:
7373
- uses: actions/checkout@v4
7474
with:
@@ -112,7 +112,7 @@ jobs:
112112
platform:
113113
- runner: macos-14
114114
target: aarch64
115-
python: [ '3.11', '3.12', '3.13' ]
115+
python: ["3.11", "3.12", "3.13", "3.14"]
116116
steps:
117117
- uses: actions/checkout@v4
118118
with:
@@ -156,7 +156,7 @@ jobs:
156156
name: Release
157157
runs-on: ubuntu-latest
158158
if: ${{ (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'crackers_python')) || github.event_name == 'workflow_dispatch' }}
159-
needs: [ linux, macos, sdist ]
159+
needs: [linux, macos, sdist]
160160
permissions:
161161
# Use to sign the release artifacts
162162
id-token: write
@@ -169,7 +169,7 @@ jobs:
169169
- name: Generate artifact attestation
170170
uses: actions/attest-build-provenance@v2
171171
with:
172-
subject-path: 'wheels-*/*'
172+
subject-path: "wheels-*/*"
173173
- name: Publish to PyPI
174174
uses: PyO3/maturin-action@v1
175175
env:

crackers/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ toml = ["dep:toml_edit"]
2424
z3-gh-release = ["z3/gh-release"]
2525

2626
[dependencies]
27-
jingle = { version = "0.3.2", features = ["gimli"] }
27+
jingle = { version = "0.3.6", features = ["gimli"] }
2828
z3 = "0.19.0"
2929
serde = { version = "1.0.203", features = ["derive"] }
3030
thiserror = "2.0"
@@ -38,4 +38,4 @@ rand = "0.9.2"
3838
derive_builder = "0.20"
3939
anyhow = { version = "1.0", optional = true }
4040
tracing-indicatif = { version = "0.3", optional = true }
41-
pyo3 = { version = "0", optional = true }
41+
pyo3 = { version = "0.27.2", optional = true, default-features = false, features = ["macros"] }

crackers_python/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ edition = "2024"
66
description = "pyo3 bindings for crackers"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88
[lib]
9-
name = "crackers"
9+
name = "crackers_python"
1010
crate-type = ["cdylib"]
1111

1212
[dependencies]
13-
pyo3 = { version = "0.26", features = ["extension-module", "py-clone"] }
13+
pyo3 = { version = "0.27.2", features = ["extension-module", "py-clone"] }
1414
crackers = {path = "../crackers", features = ["pyo3"], version = "0.6.3" }
15-
jingle = { version = "0.3.2", features = ["pyo3"]}
15+
jingle = { version = "0.3.6", features = ["pyo3"]}
1616
toml_edit = { version = "0.23.4", features = ["serde"] }
1717
z3 = "0.19.0"
1818
serde_json = "1.0.140"

crackers_python/PYTHON_README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ For more details, please refer to the [GitHub project](https://github.com/toolCH
1818

1919
[![PyPI](https://img.shields.io/pypi/v/crackers)](https://pypi.org/project/crackers/)
2020

21-
The easiest way to use `crackers` is through the [PyPI](https://pypi.org/project/crackers/) package. For every release, we provide wheels for `[MacOS, Windows, Linux] x [3.10, 3.11, 3.12, 3.13]`.
21+
The easiest way to use `crackers` is through the [PyPI](https://pypi.org/project/crackers/) package. For every release, we provide wheels for `[MacOS, Windows, Linux] x [3.11, 3.12, 3.13, 3.14]`.
2222

2323
A simple usage looks like the following:
2424

crackers_python/build.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ fn main() {
1717
std::env::set_var("Z3_PATH", z3_python_lib);
1818
}
1919
}
20+
21+
// For pyo3 extension-modules on macOS, allow undefined symbols to be resolved
22+
// dynamically by the Python interpreter at load time. This avoids linker errors
23+
// when building a cdylib that depends on the Python C API (pyo3).
24+
//
25+
// We only add these flags on macOS to avoid affecting other platforms.
26+
if cfg!(target_os = "macos") {
27+
// Preferred form for passing to the linker; some toolchains accept either
28+
// -Wl,-undefined,dynamic_lookup or two separate args. Using -Wl,... is more
29+
// explicit and portable across macOS linker invocations.
30+
println!("cargo:rustc-link-arg=-Wl,-undefined,dynamic_lookup");
31+
}
32+
2033
println!("cargo:rerun-if-changed=build.rs");
2134
println!("cargo:rerun-if-env-changed=Z3_PATH")
2235
}

0 commit comments

Comments
 (0)