diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index d49a42b..059da55 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -13,7 +13,7 @@ permissions: env: UV_FROZEN: true UV_PYTHON: 3.14 - RUST_VERSION: "1.90.0" + RUST_VERSION: "1.95.0" jobs: benchmark: diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index 2d902ec..d1262f1 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -13,7 +13,7 @@ permissions: env: UV_FROZEN: true UV_PYTHON: 3.14 - RUST_VERSION: "1.90.0" + RUST_VERSION: "1.95.0" jobs: benchmarks: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 349fb27..041ef3e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,6 +7,7 @@ permissions: env: RUSTFLAGS: "-Dwarnings" # treat warnings as errors + RUST_VERSION: "1.95.0" jobs: lint: @@ -16,6 +17,12 @@ jobs: - name: Checkout repository. uses: actions/checkout@v6 + - name: Install rust. + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} + components: clippy, rustfmt + - name: Run Clippy. run: cargo clippy --all-targets --all-features diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 059a864..0ee1ba3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ permissions: contents: read env: - RUST_VERSION: "1.90.0" + RUST_VERSION: "1.95.0" jobs: build: diff --git a/Cargo.toml b/Cargo.toml index 998a1d8..574a664 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,11 +13,11 @@ name = "libipld" crate-type = ["rlib", "cdylib"] [dependencies] -pyo3 = { version = "0.27.1", features = ["generate-import-lib", "anyhow"] } -python3-dll-a = "0.2.14" -anyhow = "1.0.100" -cid = "0.11.1" -cbor4ii = { version = "1.2.1" } +pyo3 = { version = "0.28.3", features = ["generate-import-lib", "anyhow"] } +python3-dll-a = "0.2.15" +anyhow = "1.0.102" +cid = "0.11.3" +cbor4ii = { version = "1.2.2" } [workspace] members = [ "profiling" ] diff --git a/profiling/Cargo.toml b/profiling/Cargo.toml index 112b828..680016c 100644 --- a/profiling/Cargo.toml +++ b/profiling/Cargo.toml @@ -11,4 +11,4 @@ structopt = "0.3.26" clap = "4.5.29" [dependencies.pyo3] -version = "0.27.1" +version = "0.28.3" diff --git a/profiling/src/profiles/decode_car.rs b/profiling/src/profiles/decode_car.rs index b43fe8f..1b881ad 100644 --- a/profiling/src/profiles/decode_car.rs +++ b/profiling/src/profiles/decode_car.rs @@ -6,12 +6,17 @@ pub fn exec(iterations: u64) { let bench_file_name = "benchmarks/repo.car"; let car_bytes = fs::read(bench_file_name) - .expect(&format!("Could not open bench file '{}'", bench_file_name)); + .unwrap_or_else(|_| panic!("Could not open bench file '{}'", bench_file_name)); - pyo3::prepare_freethreaded_python(); + Python::initialize(); + + Python::attach(|gil| { + unsafe { pyo3::ffi::Py_SetRecursionLimit(10_000) }; + let _ = gil; + }); for _ in 0..iterations { - Python::with_gil(|gil| { + Python::attach(|gil| { println!("{}", libipld::decode_car(gil, &car_bytes).is_ok()); }); } diff --git a/profiling/src/profiles/decode_dag_cbor.rs b/profiling/src/profiles/decode_dag_cbor.rs index a9c37d3..ed5a524 100644 --- a/profiling/src/profiles/decode_dag_cbor.rs +++ b/profiling/src/profiles/decode_dag_cbor.rs @@ -6,12 +6,12 @@ pub fn exec(iterations: u64) { let bench_file_name = "benchmarks/decode.dagcbor"; let dag_cbor_bytes = fs::read(bench_file_name) - .expect(&format!("Could not open bench file '{}'", bench_file_name)); + .unwrap_or_else(|_| panic!("Could not open bench file '{}'", bench_file_name)); - pyo3::prepare_freethreaded_python(); + Python::initialize(); for _ in 0..iterations { - Python::with_gil(|gil| { + Python::attach(|gil| { println!("{}", libipld::decode_dag_cbor(gil, &dag_cbor_bytes).is_ok()); }); } diff --git a/profiling/src/profiles/encode_dag_cbor.rs b/profiling/src/profiles/encode_dag_cbor.rs index e310463..1d27c69 100644 --- a/profiling/src/profiles/encode_dag_cbor.rs +++ b/profiling/src/profiles/encode_dag_cbor.rs @@ -7,13 +7,13 @@ pub fn exec(iterations: u64) { let bench_file_name = "benchmarks/encode.json"; let json_data = fs::read_to_string(bench_file_name) - .expect(&format!("Could not open bench file '{}'", bench_file_name)); + .unwrap_or_else(|_| panic!("Could not open bench file '{}'", bench_file_name)); let json_str = json_data.as_str(); - pyo3::prepare_freethreaded_python(); + Python::initialize(); for _ in 0..iterations { - Python::with_gil(|gil| { + Python::attach(|gil| { println!( "{}", libipld::encode_dag_cbor(gil, &PyString::new(gil, json_str)).is_ok() diff --git a/pytests/test_decode_car.py b/pytests/test_decode_car.py index 15d40c5..ac5bd62 100644 --- a/pytests/test_decode_car.py +++ b/pytests/test_decode_car.py @@ -42,7 +42,7 @@ def test_decode_car_invalid_header_type() -> None: header_obj = libipld.encode_dag_cbor('strInsteadOfObj') libipld.decode_car(header_len + header_obj) - assert "cannot be cast as 'dict'" in str(exc_info.value) + assert "is not an instance of 'dict'" in str(exc_info.value) def test_decode_car_invalid_header_version_key() -> None: @@ -78,7 +78,7 @@ def test_decode_car_invalid_header_roots_value_type() -> None: header_obj = libipld.encode_dag_cbor({'version': 1, 'roots': 123}) libipld.decode_car(header_len + header_obj) - assert "cannot be cast as 'list'" in str(exc_info.value) + assert "is not an instance of 'list'" in str(exc_info.value) def test_decode_car_invalid_header_roots_value_empty_list() -> None: