From b5a82ea22587eb9e540e6aef9ff92c676b412677 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 07:30:53 +0100 Subject: [PATCH 01/39] :art: fix clippy warnings --- src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4658176..bdd6f32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ use pyo3::{prelude::*, types::PyBytes}; use pyo3::exceptions::PyRuntimeError; -use rustls_native_certs; /// Retrieve a list of system DER root CAs #[pyfunction] @@ -13,10 +12,10 @@ fn root_der_certificates(py: Python) -> PyResult>> { } for cert in certs.unwrap() { - roots.push(PyBytes::new_bound(py, &cert.as_ref().to_vec())); + roots.push(PyBytes::new_bound(py, cert.as_ref())); } - return Ok(roots); + Ok(roots) } #[pymodule] From f29cd9174bb21f369556b7b9dad5671869e938b8 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 07:31:33 +0100 Subject: [PATCH 02/39] :bookmark: bump version to 1.1.6 and pyo3 main to 0.22.6 --- Cargo.lock | 34 +++++++++++++++++----------------- Cargo.toml | 4 ++-- wassima/_version.py | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d13633..2944e60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,9 +50,9 @@ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "libc" -version = "0.2.161" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "memoffset" @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d922163ba1f79c04bc49073ba7b32fd5a8d3b76a87c955921234b8e77333c51" +checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" dependencies = [ "cfg-if", "indoc", @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc38c5feeb496c8321091edf3d63e9a6829eab4b863b4a6a65f26f3e9cc6b179" +checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" dependencies = [ "once_cell", "target-lexicon", @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94845622d88ae274d2729fcefc850e63d7a3ddff5e3ce11bd88486db9f1d357d" +checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" dependencies = [ "libc", "pyo3-build-config", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e655aad15e09b94ffdb3ce3d217acf652e26bbc37697ef012f5e5e348c716e5e" +checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1e3f09eecd94618f60a455a23def79f79eba4dc561a97324bf9ac8c6df30ce" +checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" dependencies = [ "heck", "proc-macro2", @@ -214,9 +214,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" dependencies = [ "core-foundation-sys", "libc", @@ -224,9 +224,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -253,7 +253,7 @@ checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" [[package]] name = "wassima" -version = "1.1.5" +version = "1.1.6" dependencies = [ "pyo3", "rustls-native-certs", diff --git a/Cargo.toml b/Cargo.toml index b6d25aa..3a113e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wassima" -version = "1.1.5" +version = "1.1.6" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -9,7 +9,7 @@ name = "wassima" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.22.5", features = ["abi3-py37", "extension-module"] } +pyo3 = { version = "0.22.6", features = ["abi3-py37", "extension-module"] } rustls-native-certs = "0.7.3" [package.metadata.maturin] diff --git a/wassima/_version.py b/wassima/_version.py index 97a7800..30334d2 100644 --- a/wassima/_version.py +++ b/wassima/_version.py @@ -1,4 +1,4 @@ from __future__ import annotations -__version__ = "1.1.5" +__version__ = "1.1.6" VERSION = __version__.split(".") From 08f63fa650ba4fb5f24ff0afb93c7b63144d11f0 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 07:32:04 +0100 Subject: [PATCH 03/39] :arrow_up: upgrade CI.yml dependencies and OS targets --- .github/workflows/CI.yml | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c0a4e16..95e0cfe 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,10 +21,10 @@ jobs: lint: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.11' - run: pip install pre-commit name: Install pre-commit - run: pre-commit run --all @@ -33,12 +33,15 @@ jobs: test: strategy: matrix: - os: [ubuntu-22.04, macos-12, windows-latest ] + os: [ubuntu-22.04, macos-13, windows-latest ] python_version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10'] + exclude: + - python_version: 3.7 + os: macos-13 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} allow-prereleases: true @@ -101,8 +104,8 @@ jobs: target: ppc64le steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Build wheels @@ -138,8 +141,8 @@ jobs: - target: aarch64 python_version: 'pypy-3.10' steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} architecture: x64 @@ -159,15 +162,15 @@ jobs: needs: - test - lint - runs-on: macos-12 + runs-on: macos-13 strategy: fail-fast: false matrix: target: [x86_64, aarch64, universal2] python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10'] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Build wheels @@ -188,7 +191,7 @@ jobs: - lint runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build sdist uses: PyO3/maturin-action@v1 with: @@ -206,8 +209,8 @@ jobs: - lint runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install dependencies From 5bc95c67501d07d4e36addfae8ffd3f399f75866 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 07:43:54 +0100 Subject: [PATCH 04/39] :wrench: add freethreaded build in CI --- .github/workflows/CI.yml | 85 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 95e0cfe..aed6493 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -185,6 +185,89 @@ jobs: name: wheels path: dist + freethreaded_macos: + needs: macos + strategy: + matrix: + target: [x86_64, aarch64, universal2] + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.13t + - run: git apply -f freethreaded.patch + name: Make Wassima FreeThreaded Capable + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --interpreter 3.13t + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + freethreaded_linux: + needs: linux + strategy: + matrix: + target: [x86_64, x86, aarch64, armv7, s390x, ppc64le, ppc64, i686] + manylinux: ['auto', 'musllinux_1_1'] + exclude: + - manylinux: musllinux_1_1 + target: s390x + - manylinux: musllinux_1_1 + target: ppc64 + - manylinux: musllinux_1_1 + target: ppc64le + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.13t + - run: git apply -f freethreaded.patch + name: Make Wassima FreeThreaded Capable + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --interpreter 3.13t + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + freethreaded_windows: + needs: windows + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + target: [ x64, aarch64 ] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.13t + architecture: x64 + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + sdist: needs: - test @@ -228,7 +311,7 @@ jobs: checksum: name: compute hashes runs-on: ubuntu-22.04 - needs: [linux, windows, macos, sdist, universal] + needs: [linux, windows, macos, sdist, universal, freethreaded_linux, freethreaded_macos, freethreaded_windows] if: "startsWith(github.ref, 'refs/tags/')" outputs: hashes: ${{ steps.compute.outputs.hashes }} From feeded8342150b1946d2ef8ebfa0011730630590 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 07:50:08 +0100 Subject: [PATCH 05/39] :sparkle: add freethreaded patch --- freethreaded.patch | 101 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 freethreaded.patch diff --git a/freethreaded.patch b/freethreaded.patch new file mode 100644 index 0000000..2bb90ee --- /dev/null +++ b/freethreaded.patch @@ -0,0 +1,101 @@ +diff --git a/Cargo.lock b/Cargo.lock +index 2944e60..4f98615 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -92,9 +92,8 @@ dependencies = [ + + [[package]] + name = "pyo3" +-version = "0.22.6" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" ++version = "0.23.0-dev" ++source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" + dependencies = [ + "cfg-if", + "indoc", +@@ -110,9 +109,8 @@ dependencies = [ + + [[package]] + name = "pyo3-build-config" +-version = "0.22.6" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" ++version = "0.23.0-dev" ++source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" + dependencies = [ + "once_cell", + "target-lexicon", +@@ -120,9 +118,8 @@ dependencies = [ + + [[package]] + name = "pyo3-ffi" +-version = "0.22.6" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" ++version = "0.23.0-dev" ++source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" + dependencies = [ + "libc", + "pyo3-build-config", +@@ -130,9 +127,8 @@ dependencies = [ + + [[package]] + name = "pyo3-macros" +-version = "0.22.6" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" ++version = "0.23.0-dev" ++source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" + dependencies = [ + "proc-macro2", + "pyo3-macros-backend", +@@ -142,9 +138,8 @@ dependencies = [ + + [[package]] + name = "pyo3-macros-backend" +-version = "0.22.6" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" ++version = "0.23.0-dev" ++source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" + dependencies = [ + "heck", + "proc-macro2", +diff --git a/Cargo.toml b/Cargo.toml +index 3a113e0..e89bfc2 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -9,8 +9,11 @@ name = "wassima" + crate-type = ["cdylib"] + + [dependencies] +-pyo3 = { version = "0.22.6", features = ["abi3-py37", "extension-module"] } ++pyo3 = { version = "0.23.0-dev", features = ["extension-module"] } + rustls-native-certs = "0.7.3" + ++[patch.crates-io] ++pyo3 = { git = 'https://github.com/PyO3/pyo3.git', branch = 'main' } ++ + [package.metadata.maturin] + python-source = "wassima" +diff --git a/src/lib.rs b/src/lib.rs +index bdd6f32..a8ed1d8 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -12,13 +12,13 @@ fn root_der_certificates(py: Python) -> PyResult>> { + } + + for cert in certs.unwrap() { +- roots.push(PyBytes::new_bound(py, cert.as_ref())); ++ roots.push(PyBytes::new(py, cert.as_ref())); + } + + Ok(roots) + } + +-#[pymodule] ++#[pymodule(gil_used = false)] + fn _rustls(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { + m.add_function(wrap_pyfunction!(root_der_certificates, m)?)?; + Ok(()) From 7fcf4ba6f427d8aa4e41b553d67cd54429a0d5dd Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 07:50:18 +0100 Subject: [PATCH 06/39] :pencil: write changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80d5820..b915d7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,15 @@ All notable changes to wassima will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## 1.1.6 (2024-11-11) + +### Changed +- pyo3 updated from 0.22.5 to 0.22.6 +- minor improvements in Rust code. + +### Added +- Initial support for Python 3.13 freethreaded experimental build using pyo3 0.23-dev + ## 1.1.5 (2024-10-27) ### Changed From 7949e85ebd77e30f73375b896f022def360e7d51 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 07:55:46 +0100 Subject: [PATCH 07/39] :wrench: ignore freethreaded patch for pre-commit lints --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ca81f96..2fd46f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -exclude: 'docs/|src/' +exclude: 'docs/|src/|freethreaded.patch' repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 From 9aaf617ed5d499784c63fba9bf37baa792fa37f7 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 07:57:12 +0100 Subject: [PATCH 08/39] :wrench: stop upgrading embedded pip in CI --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index aed6493..a6df642 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -46,7 +46,7 @@ jobs: python-version: ${{ matrix.python_version }} allow-prereleases: true - name: Setup dependencies - run: pip install --upgrade pip pytest + run: pip install pytest - name: Install mkcert (Linux) if: matrix.os == 'ubuntu-22.04' run: sudo apt-get install mkcert From 0ea3cb696295a780f430ec8a26e31351372e9a69 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 08:25:37 +0100 Subject: [PATCH 09/39] :wrench: change freethreaded setup methods across mac, linux and windows --- .github/workflows/CI.yml | 56 ++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a6df642..2ba600c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -193,9 +193,30 @@ jobs: runs-on: macos-13 steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.13t + - name: Install Python FreeThreaded + run: | + curl -O https://www.python.org/ftp/python/3.13.0/python-3.13.0-macos11.pkg + cat > ./choicechanges.plist < + + + + + attributeSetting + 1 + choiceAttribute + selected + choiceIdentifier + org.python.Python.PythonTFramework-3.13 + + + + EOF + + sudo installer -pkg ./python-3.13.0-macos11.pkg \ + -applyChoiceChangesXML ./choicechanges.plist \ + -target / + rm -f python-3.13.0-macos11.pkg - run: git apply -f freethreaded.patch name: Make Wassima FreeThreaded Capable - name: Build wheels @@ -214,21 +235,14 @@ jobs: needs: linux strategy: matrix: - target: [x86_64, x86, aarch64, armv7, s390x, ppc64le, ppc64, i686] - manylinux: ['auto', 'musllinux_1_1'] - exclude: - - manylinux: musllinux_1_1 - target: s390x - - manylinux: musllinux_1_1 - target: ppc64 - - manylinux: musllinux_1_1 - target: ppc64le - runs-on: macos-13 + target: [x86_64, aarch64] + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: deadsnakes/action@v3.2.0 with: - python-version: 3.13t + python-version: 3.13 + nogil: true - run: git apply -f freethreaded.patch name: Make Wassima FreeThreaded Capable - name: Build wheels @@ -252,10 +266,14 @@ jobs: target: [ x64, aarch64 ] steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.13t - architecture: x64 + - name: Install Python FreeThreaded + shell: pwsh + run: | + $pythonInstallerUrl = "https://www.python.org/ftp/python/3.13.0/python-3.13.0-amd64.exe" + Invoke-WebRequest $pythonInstallerUrl -OutFile setup-python.exe + Start-Process "setup-python.exe" -argumentlist "/quiet PrependPath=1 TargetDir=C:\Python313 Include_freethreaded=1" -wait + C:\Python313\python3.13t.exe -m pip install -r requirements.txt + C:\Python313\python3.13t.exe -c "import sys; print(sys._is_gil_enabled())" - name: Build wheels uses: PyO3/maturin-action@v1 with: From 4d9a0612f6e68a49c1748523ecbda1c76bdfdd09 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 08:35:31 +0100 Subject: [PATCH 10/39] :art: add rust pre-commit hook and reformat lib.rs --- .pre-commit-config.yaml | 18 +++++++++++++++++- src/lib.rs | 8 +++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2fd46f5..3b51bdc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -exclude: 'docs/|src/|freethreaded.patch' +exclude: 'docs/|freethreaded.patch' repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 @@ -29,3 +29,19 @@ repos: - id: mypy args: [--check-untyped-defs] exclude: 'tests/' +- repo: local + hooks: + - id: rust-linting + name: Rust linting + description: Run cargo fmt on files included in the commit. rustfmt should be installed before-hand. + entry: cargo fmt --all -- + pass_filenames: true + types: [file, rust] + language: system + - id: rust-clippy + name: Rust clippy + description: Run cargo clippy on files included in the commit. clippy should be installed before-hand. + entry: cargo clippy --all-targets --all-features -- -Dclippy::all + pass_filenames: false + types: [file, rust] + language: system diff --git a/src/lib.rs b/src/lib.rs index bdd6f32..b359533 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,14 +1,16 @@ -use pyo3::{prelude::*, types::PyBytes}; use pyo3::exceptions::PyRuntimeError; +use pyo3::{prelude::*, types::PyBytes}; /// Retrieve a list of system DER root CAs #[pyfunction] -fn root_der_certificates(py: Python) -> PyResult>> { +fn root_der_certificates(py: Python) -> PyResult>> { let mut roots = Vec::new(); let certs = rustls_native_certs::load_native_certs(); if certs.is_err() { - return Err(PyRuntimeError::new_err("unable to extract root certificates")); + return Err(PyRuntimeError::new_err( + "unable to extract root certificates", + )); } for cert in certs.unwrap() { From 314301b4da9d47c3206c9cdb4f628a44ef00f488 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 08:40:14 +0100 Subject: [PATCH 11/39] :wrench: update freethreaded CI steps --- .github/workflows/CI.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2ba600c..394af36 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -217,7 +217,7 @@ jobs: -applyChoiceChangesXML ./choicechanges.plist \ -target / rm -f python-3.13.0-macos11.pkg - - run: git apply -f freethreaded.patch + - run: git apply freethreaded.patch name: Make Wassima FreeThreaded Capable - name: Build wheels uses: PyO3/maturin-action@v1 @@ -235,7 +235,7 @@ jobs: needs: linux strategy: matrix: - target: [x86_64, aarch64] + target: [x86_64, aarch64, s390x] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -243,7 +243,7 @@ jobs: with: python-version: 3.13 nogil: true - - run: git apply -f freethreaded.patch + - run: git apply freethreaded.patch name: Make Wassima FreeThreaded Capable - name: Build wheels uses: PyO3/maturin-action@v1 @@ -274,11 +274,13 @@ jobs: Start-Process "setup-python.exe" -argumentlist "/quiet PrependPath=1 TargetDir=C:\Python313 Include_freethreaded=1" -wait C:\Python313\python3.13t.exe -m pip install -r requirements.txt C:\Python313\python3.13t.exe -c "import sys; print(sys._is_gil_enabled())" + - run: git apply freethreaded.patch + name: Make Wassima FreeThreaded Capable - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist + args: --release --out dist --interpreter 3.13t sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 From b39fa4e35b5461ab26fe4f5cf6e6ac30ea625769 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 08:56:21 +0100 Subject: [PATCH 12/39] :wrench: update freethreaded CI steps*2 --- .github/workflows/CI.yml | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 394af36..f28b70a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -194,36 +194,14 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install Python FreeThreaded - run: | - curl -O https://www.python.org/ftp/python/3.13.0/python-3.13.0-macos11.pkg - cat > ./choicechanges.plist < - - - - - attributeSetting - 1 - choiceAttribute - selected - choiceIdentifier - org.python.Python.PythonTFramework-3.13 - - - - EOF - - sudo installer -pkg ./python-3.13.0-macos11.pkg \ - -applyChoiceChangesXML ./choicechanges.plist \ - -target / - rm -f python-3.13.0-macos11.pkg + run: brew install python-freethreading - run: git apply freethreaded.patch name: Make Wassima FreeThreaded Capable - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter 3.13t + args: --release --out dist --interpreter 3.13 sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 @@ -239,17 +217,18 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - uses: deadsnakes/action@v3.2.0 - with: - python-version: 3.13 - nogil: true + - run: | + sudo add-apt-repository ppa:deadsnakes + sudo apt-get update + sudo apt-get install python3.13-nogil + name: Install Python FreeThreaded - run: git apply freethreaded.patch name: Make Wassima FreeThreaded Capable - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter 3.13t + args: --release --out dist --interpreter 3.13 sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 @@ -280,7 +259,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter 3.13t + args: --release --out dist --interpreter 3.13 sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 From 6e66325c4fe40673d2a3951e68ca33ce237c9032 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 11:01:04 +0100 Subject: [PATCH 13/39] :wrench: update freethreaded CI steps*3 --- .github/workflows/CI.yml | 89 ++++++++-------------------------------- pyproject.toml | 3 ++ 2 files changed, 21 insertions(+), 71 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f28b70a..89c1e14 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -185,82 +185,29 @@ jobs: name: wheels path: dist - freethreaded_macos: - needs: macos + freethreaded: + needs: + - test + - lint + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: matrix: - target: [x86_64, aarch64, universal2] - runs-on: macos-13 - steps: - - uses: actions/checkout@v4 - - name: Install Python FreeThreaded - run: brew install python-freethreading - - run: git apply freethreaded.patch - name: Make Wassima FreeThreaded Capable - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist --interpreter 3.13 - sccache: 'true' - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist + os: [ ubuntu-latest, windows-latest, macos-13 ] - freethreaded_linux: - needs: linux - strategy: - matrix: - target: [x86_64, aarch64, s390x] - runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 - - run: | - sudo add-apt-repository ppa:deadsnakes - sudo apt-get update - sudo apt-get install python3.13-nogil - name: Install Python FreeThreaded - - run: git apply freethreaded.patch - name: Make Wassima FreeThreaded Capable - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist --interpreter 3.13 - sccache: 'true' - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist + - uses: actions/setup-python@v5 + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.21.3 - freethreaded_windows: - needs: windows - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - target: [ x64, aarch64 ] - steps: - - uses: actions/checkout@v4 - - name: Install Python FreeThreaded - shell: pwsh - run: | - $pythonInstallerUrl = "https://www.python.org/ftp/python/3.13.0/python-3.13.0-amd64.exe" - Invoke-WebRequest $pythonInstallerUrl -OutFile setup-python.exe - Start-Process "setup-python.exe" -argumentlist "/quiet PrependPath=1 TargetDir=C:\Python313 Include_freethreaded=1" -wait - C:\Python313\python3.13t.exe -m pip install -r requirements.txt - C:\Python313\python3.13t.exe -c "import sys; print(sys._is_gil_enabled())" - - run: git apply freethreaded.patch - name: Make Wassima FreeThreaded Capable - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist --interpreter 3.13 - sccache: 'true' + run: python -m cibuildwheel --output-dir dist + env: + CIBW_BUILD_FRONTEND: build + CIBW_BEFORE_BUILD: git apply freethreaded.patch + CIBW_BUILD: cp313t* + - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -310,7 +257,7 @@ jobs: checksum: name: compute hashes runs-on: ubuntu-22.04 - needs: [linux, windows, macos, sdist, universal, freethreaded_linux, freethreaded_macos, freethreaded_windows] + needs: [linux, windows, macos, sdist, universal, freethreaded] if: "startsWith(github.ref, 'refs/tags/')" outputs: hashes: ${{ steps.compute.outputs.hashes }} diff --git a/pyproject.toml b/pyproject.toml index 524b1b6..9ccd08a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,3 +73,6 @@ warn_redundant_casts = true warn_return_any = true warn_unused_configs = true warn_unused_ignores = true + +[tool.cibuildwheel] +free-threaded-support = true From fa222342b1f7ebc86d4e965e991f9a19321d62fd Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 11:15:08 +0100 Subject: [PATCH 14/39] :wrench: update freethreaded CI steps*4 --- .github/workflows/CI.yml | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 89c1e14..eda3cdc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -194,15 +194,39 @@ jobs: strategy: matrix: os: [ ubuntu-latest, windows-latest, macos-13 ] - + qemu: [ '' ] + include: + # Split ubuntu job for the sake of speed-up + - os: ubuntu-latest + qemu: aarch64 + - os: ubuntu-latest + qemu: ppc64le + - os: ubuntu-latest + qemu: s390x steps: - - uses: actions/setup-python@v5 - - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.21.3 + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + submodules: true + - name: Set up QEMU + if: ${{ matrix.qemu }} + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 + with: + platforms: all + id: qemu + - name: Prepare emulation + run: | + if [[ -n "${{ matrix.qemu }}" ]]; then + # Build emulated architectures only if QEMU is set, + # use default "auto" otherwise + echo "CIBW_ARCHS_LINUX=${{ matrix.qemu }}" >> $GITHUB_ENV + fi + shell: bash + - name: Setup Python + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 - name: Build wheels - run: python -m cibuildwheel --output-dir dist + uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3 env: CIBW_BUILD_FRONTEND: build CIBW_BEFORE_BUILD: git apply freethreaded.patch From 65695aab630e10f753866dcc288468dd1b15f758 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 11:15:58 +0100 Subject: [PATCH 15/39] :wrench: update freethreaded CI steps*5 --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index eda3cdc..be0ac31 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -236,7 +236,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: wheels - path: dist + path: ./wheelhouse/*.whl sdist: needs: From 958eb22ba55a352c5d767ae79a1a2442792fad6d Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 11:25:34 +0100 Subject: [PATCH 16/39] :wrench: update freethreaded CI steps*6 --- .github/workflows/CI.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index be0ac31..7667111 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -231,6 +231,9 @@ jobs: CIBW_BUILD_FRONTEND: build CIBW_BEFORE_BUILD: git apply freethreaded.patch CIBW_BUILD: cp313t* + CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y + CIBW_BEFORE_ALL_WINDOWS: rustup target add i686-pc-windows-msvc + CIBW_ENVIRONMENT_LINUX: "PATH=$HOME/.cargo/bin:$PATH" - name: Upload wheels uses: actions/upload-artifact@v3 From db95e61b6a5de9f698972685442724322963169b Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 11:37:28 +0100 Subject: [PATCH 17/39] :wrench: update freethreaded CI steps*7 --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7667111..04ffb91 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -229,7 +229,7 @@ jobs: uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3 env: CIBW_BUILD_FRONTEND: build - CIBW_BEFORE_BUILD: git apply freethreaded.patch + CIBW_BEFORE_ALL: git apply freethreaded.patch CIBW_BUILD: cp313t* CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y CIBW_BEFORE_ALL_WINDOWS: rustup target add i686-pc-windows-msvc From 1aaa0c085124395b166cf01ee1c02256589c89be Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Mon, 11 Nov 2024 11:40:05 +0100 Subject: [PATCH 18/39] :wrench: update freethreaded CI steps*8 --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 04ffb91..384d00d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -234,6 +234,7 @@ jobs: CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y CIBW_BEFORE_ALL_WINDOWS: rustup target add i686-pc-windows-msvc CIBW_ENVIRONMENT_LINUX: "PATH=$HOME/.cargo/bin:$PATH" + CIBW_ARCHS_MACOS: universal2 - name: Upload wheels uses: actions/upload-artifact@v3 From c49fd3190b07b0fe5619cbf9476b98fd0b1b95b6 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 07:02:42 +0100 Subject: [PATCH 19/39] :wrench: update freethreaded CI steps*9 --- .github/workflows/CI.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 384d00d..3a44a0f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -229,7 +229,8 @@ jobs: uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3 env: CIBW_BUILD_FRONTEND: build - CIBW_BEFORE_ALL: git apply freethreaded.patch + CIBW_BEFORE_BUILD: git apply freethreaded.patch || true + CIBW_BEFORE_BUILD_WINDOWS: git apply freethreaded.patch || (exit 0) CIBW_BUILD: cp313t* CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y CIBW_BEFORE_ALL_WINDOWS: rustup target add i686-pc-windows-msvc From 731749ed20ba729afc884ae06101d63bea11b331 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 07:23:18 +0100 Subject: [PATCH 20/39] :wrench: improve test resiliency with real world ssl tests --- tests/test_ctx.py | 68 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/tests/test_ctx.py b/tests/test_ctx.py index c8ab861..54425ba 100644 --- a/tests/test_ctx.py +++ b/tests/test_ctx.py @@ -4,6 +4,7 @@ import threading from os.path import exists from socket import AF_INET, SOCK_STREAM, socket +from socket import timeout as SocketTimeout from ssl import PROTOCOL_TLS_SERVER, SSLContext, SSLError from time import sleep @@ -48,19 +49,42 @@ def test_ctx_use_system_store(host: str, port: int, expect_failure: bool) -> Non s = socket(AF_INET, SOCK_STREAM) s = ctx.wrap_socket(s, server_hostname=host) + s.settimeout(5) - if expect_failure: - with pytest.raises(SSLError) as exc: - s.connect((host, port)) - ssl_err = exc.value.args[1] - assert ( - "self-signed" in ssl_err - or "self signed" in ssl_err - or "unable to get local issuer certificate" in ssl_err - ) - else: - s.connect((host, port)) - assert s.getpeercert() is not None + i = 0 + + while True: + try: + if expect_failure: + with pytest.raises(SSLError) as exc: + s.connect((host, port)) + ssl_err = exc.value.args[1] + assert ( + "self-signed" in ssl_err + or "self signed" in ssl_err + or "unable to get local issuer certificate" in ssl_err + ) + else: + s.connect((host, port)) + assert s.getpeercert() is not None + + break + except ( + ConnectionResetError, + ConnectionRefusedError, + TimeoutError, + SocketTimeout, + ): + i += 1 + if i >= 15: + assert False + + s.close() + s = socket(AF_INET, SOCK_STREAM) + s = ctx.wrap_socket(s, server_hostname=host) + s.settimeout(1) + + continue s.close() @@ -86,22 +110,34 @@ def test_ctx_access_local_trusted_root() -> None: s = socket(AF_INET, SOCK_STREAM) s = ctx.wrap_socket(s, server_hostname="example.test") + s.settimeout(5) i = 0 while True: sleep(1) - if i >= 5: - break + if i >= 10: + assert False try: s.connect(("127.0.0.1", 47476)) - except ConnectionError: + except (ConnectionError, TimeoutError, SocketTimeout): i += 1 - except SSLError: + s.close() + s = socket(AF_INET, SOCK_STREAM) + s = ctx.wrap_socket(s, server_hostname="example.test") + s.settimeout(5) + except SSLError as e: + if "timeout" in str(e): + s.close() + s = socket(AF_INET, SOCK_STREAM) + s = ctx.wrap_socket(s, server_hostname="example.test") + s.settimeout(5) + continue assert False else: break assert s.getpeercert() is not None + s.close() From 5edb6e866d445b266438d814a953b34a8e037220 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 07:23:40 +0100 Subject: [PATCH 21/39] :wrench: add cp313t rustup target aarch64 for macos --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3a44a0f..99d8f35 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -234,6 +234,7 @@ jobs: CIBW_BUILD: cp313t* CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y CIBW_BEFORE_ALL_WINDOWS: rustup target add i686-pc-windows-msvc + CIBW_BEFORE_ALL_MACOS: rustup target add aarch64-apple-darwin CIBW_ENVIRONMENT_LINUX: "PATH=$HOME/.cargo/bin:$PATH" CIBW_ARCHS_MACOS: universal2 From 81f1b85af2daaa472b8542113b72187eeafbd3b2 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 07:46:31 +0100 Subject: [PATCH 22/39] :wrench: change windows archs target for freethreaded --- .github/workflows/CI.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 99d8f35..d475e44 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -212,7 +212,7 @@ jobs: if: ${{ matrix.qemu }} uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 with: - platforms: all + platforms: arm64,s390x,ppc64le id: qemu - name: Prepare emulation run: | @@ -233,10 +233,11 @@ jobs: CIBW_BEFORE_BUILD_WINDOWS: git apply freethreaded.patch || (exit 0) CIBW_BUILD: cp313t* CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y - CIBW_BEFORE_ALL_WINDOWS: rustup target add i686-pc-windows-msvc + CIBW_BEFORE_ALL_WINDOWS: rustup target add aarch64-pc-windows-msvc CIBW_BEFORE_ALL_MACOS: rustup target add aarch64-apple-darwin CIBW_ENVIRONMENT_LINUX: "PATH=$HOME/.cargo/bin:$PATH" CIBW_ARCHS_MACOS: universal2 + CIBW_ARCHS_WINDOWS: AMD64 ARM64 - name: Upload wheels uses: actions/upload-artifact@v3 From 3a362fa0aeb60e44013c27a5cdea364dff6275f1 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 08:11:13 +0100 Subject: [PATCH 23/39] :wrench: change build frontend for freethreaded --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d475e44..fc9bd4f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -228,7 +228,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3 env: - CIBW_BUILD_FRONTEND: build + CIBW_BUILD_FRONTEND: pip CIBW_BEFORE_BUILD: git apply freethreaded.patch || true CIBW_BEFORE_BUILD_WINDOWS: git apply freethreaded.patch || (exit 0) CIBW_BUILD: cp313t* From 48ef56b9c8548fd407a8a3e24baabbe4c1b6d215 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 08:20:33 +0100 Subject: [PATCH 24/39] :wrench: give up on freethreaded windows for now --- .github/workflows/CI.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index fc9bd4f..52d64b4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -193,7 +193,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, windows-latest, macos-13 ] + os: [ ubuntu-latest, macos-13 ] # windows-latest qemu: [ '' ] include: # Split ubuntu job for the sake of speed-up @@ -228,16 +228,16 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3 env: - CIBW_BUILD_FRONTEND: pip + CIBW_BUILD_FRONTEND: build CIBW_BEFORE_BUILD: git apply freethreaded.patch || true CIBW_BEFORE_BUILD_WINDOWS: git apply freethreaded.patch || (exit 0) CIBW_BUILD: cp313t* CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y - CIBW_BEFORE_ALL_WINDOWS: rustup target add aarch64-pc-windows-msvc + # CIBW_BEFORE_ALL_WINDOWS: rustup target add aarch64-pc-windows-msvc CIBW_BEFORE_ALL_MACOS: rustup target add aarch64-apple-darwin CIBW_ENVIRONMENT_LINUX: "PATH=$HOME/.cargo/bin:$PATH" CIBW_ARCHS_MACOS: universal2 - CIBW_ARCHS_WINDOWS: AMD64 ARM64 + # CIBW_ARCHS_WINDOWS: AMD64 ARM64 - name: Upload wheels uses: actions/upload-artifact@v3 From 3f4c70e04a29587a5974ba64f40264e157028a23 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 08:32:55 +0100 Subject: [PATCH 25/39] :wrench: attempt to setup 3.13t within normal linux CI --- .github/workflows/CI.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 52d64b4..50bde25 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -93,7 +93,7 @@ jobs: fail-fast: false matrix: target: [x86_64, x86, aarch64, armv7, s390x, ppc64le, ppc64, i686] - python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10'] + python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10', '3.13t'] manylinux: ['auto', 'musllinux_1_1'] exclude: - manylinux: musllinux_1_1 @@ -106,13 +106,21 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + if: matrix.python_version != '3.13t' with: python-version: ${{ matrix.python_version }} + - uses: Quansight-Labs/setup-python@v5 + if: matrix.python_version == '3.13t' + with: + python-version: '3.13t' + - name: FreeThreaded Patch + if: matrix.python_version == '3.13t' + run: git apply freethreaded.patch - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter ${{ matrix.python_version }} + args: --release --out dist -i ${{ matrix.python_version }} sccache: 'true' manylinux: ${{ matrix.manylinux }} - name: Upload wheels From 300fb9a5601cbc39a8f7b09384f664d3e6e10ef0 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 08:43:12 +0100 Subject: [PATCH 26/39] :wrench: attempt to setup 3.13t within normal CI*2 --- .github/workflows/CI.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 50bde25..ac0ec66 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -120,7 +120,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist -i ${{ matrix.python_version }} + args: --release --out dist -i ${{ matrix.python_version == '3.13t' && 'python' || '' }}${{ matrix.python_version }} sccache: 'true' manylinux: ${{ matrix.manylinux }} - name: Upload wheels @@ -138,7 +138,7 @@ jobs: fail-fast: false matrix: target: [x64, aarch64] - python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10'] + python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10', '3.13t'] exclude: - target: aarch64 python_version: 'pypy-3.7' @@ -151,9 +151,18 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + if: matrix.python_version != '3.13t' with: python-version: ${{ matrix.python_version }} architecture: x64 + - uses: Quansight-Labs/setup-python@v5 + if: matrix.python_version == '3.13t' + with: + python-version: '3.13t' + architecture: x64 + - name: FreeThreaded Patch + if: matrix.python_version == '3.13t' + run: git apply freethreaded.patch - name: Build wheels uses: PyO3/maturin-action@v1 with: From eb622f380fef9f5dbb0e67810d15d2c4730f75fd Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 08:53:18 +0100 Subject: [PATCH 27/39] :wrench: attempt to setup 3.13t within normal CI*3 --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ac0ec66..0400a57 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -120,7 +120,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist -i ${{ matrix.python_version == '3.13t' && 'python' || '' }}${{ matrix.python_version }} + args: --release --out dist # -i ${{ matrix.python_version == '3.13t' && 'python' || '' }}${{ matrix.python_version }} sccache: 'true' manylinux: ${{ matrix.manylinux }} - name: Upload wheels From f7d6824fc330557bde0c892f813af8109488cb0c Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 08:59:11 +0100 Subject: [PATCH 28/39] :wrench: attempt to setup 3.13t within normal CI*5 --- .github/workflows/CI.yml | 81 +++++++++------------------------------- 1 file changed, 18 insertions(+), 63 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0400a57..91963bf 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -148,6 +148,8 @@ jobs: python_version: 'pypy-3.9' - target: aarch64 python_version: 'pypy-3.10' + - target: aarch64 + python_version: '3.13t' steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -164,11 +166,16 @@ jobs: if: matrix.python_version == '3.13t' run: git apply freethreaded.patch - name: Build wheels + env: + PYTHON_GIL: 0 uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} args: --release --out dist sccache: 'true' + - name: Fix Wheel Name + if: matrix.python_version == '3.13t' + run: mv dist\wassima-1.1.6-cp313-none-win_amd64.whl dist\wassima-1.1.6-cp313-cp313t-win_amd64.whl - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -184,17 +191,25 @@ jobs: fail-fast: false matrix: target: [x86_64, aarch64, universal2] - python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10'] + python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10', '3.13t'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + if: matrix.python_version != '3.13t' with: python-version: ${{ matrix.python_version }} + - uses: Quansight-Labs/setup-python@v5 + if: matrix.python_version == '3.13t' + with: + python-version: '3.13t' + - name: FreeThreaded Patch + if: matrix.python_version == '3.13t' + run: git apply freethreaded.patch - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter ${{ matrix.python_version }} + args: --release --out dist sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 @@ -202,66 +217,6 @@ jobs: name: wheels path: dist - freethreaded: - needs: - - test - - lint - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-latest, macos-13 ] # windows-latest - qemu: [ '' ] - include: - # Split ubuntu job for the sake of speed-up - - os: ubuntu-latest - qemu: aarch64 - - os: ubuntu-latest - qemu: ppc64le - - os: ubuntu-latest - qemu: s390x - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: true - - name: Set up QEMU - if: ${{ matrix.qemu }} - uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - with: - platforms: arm64,s390x,ppc64le - id: qemu - - name: Prepare emulation - run: | - if [[ -n "${{ matrix.qemu }}" ]]; then - # Build emulated architectures only if QEMU is set, - # use default "auto" otherwise - echo "CIBW_ARCHS_LINUX=${{ matrix.qemu }}" >> $GITHUB_ENV - fi - shell: bash - - name: Setup Python - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 - - - name: Build wheels - uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3 - env: - CIBW_BUILD_FRONTEND: build - CIBW_BEFORE_BUILD: git apply freethreaded.patch || true - CIBW_BEFORE_BUILD_WINDOWS: git apply freethreaded.patch || (exit 0) - CIBW_BUILD: cp313t* - CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y - # CIBW_BEFORE_ALL_WINDOWS: rustup target add aarch64-pc-windows-msvc - CIBW_BEFORE_ALL_MACOS: rustup target add aarch64-apple-darwin - CIBW_ENVIRONMENT_LINUX: "PATH=$HOME/.cargo/bin:$PATH" - CIBW_ARCHS_MACOS: universal2 - # CIBW_ARCHS_WINDOWS: AMD64 ARM64 - - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: ./wheelhouse/*.whl - sdist: needs: - test @@ -305,7 +260,7 @@ jobs: checksum: name: compute hashes runs-on: ubuntu-22.04 - needs: [linux, windows, macos, sdist, universal, freethreaded] + needs: [linux, windows, macos, sdist, universal] if: "startsWith(github.ref, 'refs/tags/')" outputs: hashes: ${{ steps.compute.outputs.hashes }} From 4f30fba666b1ba2d7cad00dff39ceb5692383519 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Tue, 12 Nov 2024 09:12:55 +0100 Subject: [PATCH 29/39] :wrench: attempt to setup 3.13t within normal CI*6 --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 91963bf..e71b284 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -120,7 +120,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist # -i ${{ matrix.python_version == '3.13t' && 'python' || '' }}${{ matrix.python_version }} + args: --release --out dist -i ${{ matrix.python_version == '3.13t' && '3.13' || matrix.python_version }} sccache: 'true' manylinux: ${{ matrix.manylinux }} - name: Upload wheels From a826a638fcac9f38f875091d3a4b8dc4737fefd0 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Sat, 16 Nov 2024 08:19:39 +0100 Subject: [PATCH 30/39] :wrench: attempt to setup 3.13t within normal CI*7 --- .github/workflows/CI.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e71b284..cba968b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -116,11 +116,14 @@ jobs: - name: FreeThreaded Patch if: matrix.python_version == '3.13t' run: git apply freethreaded.patch + - name: Ensure Python PATH (FreeThreaded) + if: matrix.python_version == '3.13t' + run: echo "/opt/hostedtoolcache/Python/3.13.0/x64-freethreaded/bin" >> "$GITHUB_PATH" - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist -i ${{ matrix.python_version == '3.13t' && '3.13' || matrix.python_version }} + args: --release --out dist sccache: 'true' manylinux: ${{ matrix.manylinux }} - name: Upload wheels From c8a0756fe2566bc46f4452ecc08367a7168f8b27 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Sat, 16 Nov 2024 08:26:22 +0100 Subject: [PATCH 31/39] :wrench: attempt to setup 3.13t within normal CI*8 --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cba968b..6fcdbf4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -118,7 +118,7 @@ jobs: run: git apply freethreaded.patch - name: Ensure Python PATH (FreeThreaded) if: matrix.python_version == '3.13t' - run: echo "/opt/hostedtoolcache/Python/3.13.0/x64-freethreaded/bin" >> "$GITHUB_PATH" + run: echo "/opt/hostedtoolcache/Python/3.13.0/x64-freethreaded" >> "$GITHUB_PATH" - name: Build wheels uses: PyO3/maturin-action@v1 with: From c3e0b7c6ae4146e8d0191d1f14571f23feb3a264 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Wed, 20 Nov 2024 05:34:15 +0100 Subject: [PATCH 32/39] :wrench: attempt to setup 3.13t within normal CI*9 --- .github/workflows/CI.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6fcdbf4..ce35ab2 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -116,9 +116,18 @@ jobs: - name: FreeThreaded Patch if: matrix.python_version == '3.13t' run: git apply freethreaded.patch - - name: Ensure Python PATH (FreeThreaded) - if: matrix.python_version == '3.13t' - run: echo "/opt/hostedtoolcache/Python/3.13.0/x64-freethreaded" >> "$GITHUB_PATH" + - id: resolve-interpreter + name: resolve interpreter + run: | + echo python-path=/opt/python/$(python -c "print({ + '3.8': 'cp38-cp38', + '3.9': 'cp39-cp39', + '3.10': 'cp310-cp310', + '3.11': 'cp311-cp311', + '3.12': 'cp312-cp312', + '3.13': 'cp313-cp313', + '3.13t': 'cp313-cp313t', + }['${{ matrix.python_version }}'])")/bin/python >> $GITHUB_OUTPUT - name: Build wheels uses: PyO3/maturin-action@v1 with: From c894dd9c1e829637709d427e4ea878fcc39f0b16 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Wed, 20 Nov 2024 05:36:36 +0100 Subject: [PATCH 33/39] :wrench: attempt to setup 3.13t within normal CI*10 --- .github/workflows/CI.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ce35ab2..3c96dc7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -116,18 +116,10 @@ jobs: - name: FreeThreaded Patch if: matrix.python_version == '3.13t' run: git apply freethreaded.patch - - id: resolve-interpreter + - if: matrix.python_version == '3.13t' name: resolve interpreter run: | - echo python-path=/opt/python/$(python -c "print({ - '3.8': 'cp38-cp38', - '3.9': 'cp39-cp39', - '3.10': 'cp310-cp310', - '3.11': 'cp311-cp311', - '3.12': 'cp312-cp312', - '3.13': 'cp313-cp313', - '3.13t': 'cp313-cp313t', - }['${{ matrix.python_version }}'])")/bin/python >> $GITHUB_OUTPUT + echo python-path=/opt/python/cp313-cp313t/bin/python >> $GITHUB_OUTPUT - name: Build wheels uses: PyO3/maturin-action@v1 with: From 2dc526bd3855c661eb277d857bbb45e3790b053f Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Wed, 20 Nov 2024 05:39:49 +0100 Subject: [PATCH 34/39] :wrench: attempt to setup 3.13t within normal CI*11 --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3c96dc7..d022993 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -124,7 +124,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist + args: --release --out dist --interpreter ${{ matrix.python_version == '3.13t' && '/opt/python/cp313-cp313t/bin/python' || matrix.python_version }} sccache: 'true' manylinux: ${{ matrix.manylinux }} - name: Upload wheels From 621f763a5c982b62b31d410ed1960529b2e1ffb3 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Wed, 20 Nov 2024 06:31:14 +0100 Subject: [PATCH 35/39] :arrow_up: upgrade to pyo3 0.23.1 --- CHANGELOG.md | 4 ++-- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 2 +- pyproject.toml | 5 +---- src/lib.rs | 2 +- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b915d7c..4eb95ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## 1.1.6 (2024-11-11) ### Changed -- pyo3 updated from 0.22.5 to 0.22.6 +- pyo3 updated from 0.22.5 to 0.23.1 - minor improvements in Rust code. ### Added -- Initial support for Python 3.13 freethreaded experimental build using pyo3 0.23-dev +- Initial support for Python 3.13 freethreaded experimental build. ## 1.1.5 (2024-10-27) diff --git a/Cargo.lock b/Cargo.lock index 2944e60..4ba1e7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,9 +50,9 @@ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "libc" -version = "0.2.162" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "memoffset" @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.6" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" +checksum = "7ebb0c0cc0de9678e53be9ccf8a2ab53045e6e3a8be03393ceccc5e7396ccb40" dependencies = [ "cfg-if", "indoc", @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.6" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" +checksum = "80e3ce69c4ec34476534b490e412b871ba03a82e35604c3dfb95fcb6bfb60c09" dependencies = [ "once_cell", "target-lexicon", @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.6" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" +checksum = "3b09f311c76b36dfd6dd6f7fa6f9f18e7e46a1c937110d283e80b12ba2468a75" dependencies = [ "libc", "pyo3-build-config", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.6" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" +checksum = "fd4f74086536d1e1deaff99ec0387481fb3325c82e4e48be0e75ab3d3fcb487a" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.6" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" +checksum = "9e77dfeb76b32bbf069144a5ea0a36176ab59c8db9ce28732d0f06f096bbfbc8" dependencies = [ "heck", "proc-macro2", @@ -192,9 +192,9 @@ checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 3a113e0..b8b825f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ name = "wassima" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.22.6", features = ["abi3-py37", "extension-module"] } +pyo3 = { version = "0.23.1", features = ["abi3-py37", "extension-module"] } rustls-native-certs = "0.7.3" [package.metadata.maturin] diff --git a/pyproject.toml b/pyproject.toml index 9ccd08a..60bb86b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dependencies = [ "Issue tracker" = "https://github.com/jawah/wassima/issues" [tool.maturin] -features = ["pyo3/extension-module"] +features = ["pyo3/extension-module", "pyo3/abi3-py37"] module-name = "wassima._rustls" [tool.pytest.ini_options] @@ -73,6 +73,3 @@ warn_redundant_casts = true warn_return_any = true warn_unused_configs = true warn_unused_ignores = true - -[tool.cibuildwheel] -free-threaded-support = true diff --git a/src/lib.rs b/src/lib.rs index b359533..fe02367 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ fn root_der_certificates(py: Python) -> PyResult>> { } for cert in certs.unwrap() { - roots.push(PyBytes::new_bound(py, cert.as_ref())); + roots.push(PyBytes::new(py, cert.as_ref())); } Ok(roots) From 5e85c24722b452167b35f5c2147f0c01a54f4e16 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Wed, 20 Nov 2024 06:34:18 +0100 Subject: [PATCH 36/39] :wrench: update freethreaded patch --- freethreaded.patch | 100 +++++++++------------------------------------ 1 file changed, 19 insertions(+), 81 deletions(-) diff --git a/freethreaded.patch b/freethreaded.patch index 2bb90ee..9c23585 100644 --- a/freethreaded.patch +++ b/freethreaded.patch @@ -1,96 +1,34 @@ -diff --git a/Cargo.lock b/Cargo.lock -index 2944e60..4f98615 100644 ---- a/Cargo.lock -+++ b/Cargo.lock -@@ -92,9 +92,8 @@ dependencies = [ - - [[package]] - name = "pyo3" --version = "0.22.6" --source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" -+version = "0.23.0-dev" -+source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" - dependencies = [ - "cfg-if", - "indoc", -@@ -110,9 +109,8 @@ dependencies = [ - - [[package]] - name = "pyo3-build-config" --version = "0.22.6" --source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" -+version = "0.23.0-dev" -+source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" - dependencies = [ - "once_cell", - "target-lexicon", -@@ -120,9 +118,8 @@ dependencies = [ - - [[package]] - name = "pyo3-ffi" --version = "0.22.6" --source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" -+version = "0.23.0-dev" -+source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" - dependencies = [ - "libc", - "pyo3-build-config", -@@ -130,9 +127,8 @@ dependencies = [ - - [[package]] - name = "pyo3-macros" --version = "0.22.6" --source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" -+version = "0.23.0-dev" -+source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" - dependencies = [ - "proc-macro2", - "pyo3-macros-backend", -@@ -142,9 +138,8 @@ dependencies = [ - - [[package]] - name = "pyo3-macros-backend" --version = "0.22.6" --source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" -+version = "0.23.0-dev" -+source = "git+https://github.com/PyO3/pyo3.git?branch=main#be4407cde9a8739f7c1ea4875a0287c08fb90220" - dependencies = [ - "heck", - "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml -index 3a113e0..e89bfc2 100644 +index b8b825f..952e25c 100644 --- a/Cargo.toml +++ b/Cargo.toml -@@ -9,8 +9,11 @@ name = "wassima" +@@ -9,7 +9,7 @@ name = "wassima" crate-type = ["cdylib"] [dependencies] --pyo3 = { version = "0.22.6", features = ["abi3-py37", "extension-module"] } -+pyo3 = { version = "0.23.0-dev", features = ["extension-module"] } +-pyo3 = { version = "0.23.1", features = ["abi3-py37", "extension-module"] } ++pyo3 = { version = "0.23.1", features = ["extension-module"] } rustls-native-certs = "0.7.3" -+[patch.crates-io] -+pyo3 = { git = 'https://github.com/PyO3/pyo3.git', branch = 'main' } -+ [package.metadata.maturin] - python-source = "wassima" +diff --git a/pyproject.toml b/pyproject.toml +index 60bb86b..524b1b6 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -46,7 +46,7 @@ dependencies = [ + "Issue tracker" = "https://github.com/jawah/wassima/issues" + + [tool.maturin] +-features = ["pyo3/extension-module", "pyo3/abi3-py37"] ++features = ["pyo3/extension-module"] + module-name = "wassima._rustls" + + [tool.pytest.ini_options] diff --git a/src/lib.rs b/src/lib.rs -index bdd6f32..a8ed1d8 100644 +index fe02367..75cdafa 100644 --- a/src/lib.rs +++ b/src/lib.rs -@@ -12,13 +12,13 @@ fn root_der_certificates(py: Python) -> PyResult>> { - } - - for cert in certs.unwrap() { -- roots.push(PyBytes::new_bound(py, cert.as_ref())); -+ roots.push(PyBytes::new(py, cert.as_ref())); - } - +@@ -20,7 +20,7 @@ fn root_der_certificates(py: Python) -> PyResult>> { Ok(roots) } From 23ba35f22c35f5fbe22999fd621310c5d8e64114 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Wed, 27 Nov 2024 09:56:01 +0100 Subject: [PATCH 37/39] :arrow_up: upgrade pyo3+maturin for freethreaded support --- .github/workflows/CI.yml | 20 +------------------- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- freethreaded.patch | 39 --------------------------------------- pyproject.toml | 2 +- src/lib.rs | 2 +- 6 files changed, 14 insertions(+), 71 deletions(-) delete mode 100644 freethreaded.patch diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d022993..7b6eff5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -113,18 +113,11 @@ jobs: if: matrix.python_version == '3.13t' with: python-version: '3.13t' - - name: FreeThreaded Patch - if: matrix.python_version == '3.13t' - run: git apply freethreaded.patch - - if: matrix.python_version == '3.13t' - name: resolve interpreter - run: | - echo python-path=/opt/python/cp313-cp313t/bin/python >> $GITHUB_OUTPUT - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter ${{ matrix.python_version == '3.13t' && '/opt/python/cp313-cp313t/bin/python' || matrix.python_version }} + args: --release --out dist --interpreter ${{ matrix.python_version }} sccache: 'true' manylinux: ${{ matrix.manylinux }} - name: Upload wheels @@ -166,20 +159,12 @@ jobs: with: python-version: '3.13t' architecture: x64 - - name: FreeThreaded Patch - if: matrix.python_version == '3.13t' - run: git apply freethreaded.patch - name: Build wheels - env: - PYTHON_GIL: 0 uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} args: --release --out dist sccache: 'true' - - name: Fix Wheel Name - if: matrix.python_version == '3.13t' - run: mv dist\wassima-1.1.6-cp313-none-win_amd64.whl dist\wassima-1.1.6-cp313-cp313t-win_amd64.whl - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -206,9 +191,6 @@ jobs: if: matrix.python_version == '3.13t' with: python-version: '3.13t' - - name: FreeThreaded Patch - if: matrix.python_version == '3.13t' - run: git apply freethreaded.patch - name: Build wheels uses: PyO3/maturin-action@v1 with: diff --git a/Cargo.lock b/Cargo.lock index 4ba1e7f..f450768 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebb0c0cc0de9678e53be9ccf8a2ab53045e6e3a8be03393ceccc5e7396ccb40" +checksum = "f54b3d09cbdd1f8c20650b28e7b09e338881482f4aa908a5f61a00c98fba2690" dependencies = [ "cfg-if", "indoc", @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e3ce69c4ec34476534b490e412b871ba03a82e35604c3dfb95fcb6bfb60c09" +checksum = "3015cf985888fe66cfb63ce0e321c603706cd541b7aec7ddd35c281390af45d8" dependencies = [ "once_cell", "target-lexicon", @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b09f311c76b36dfd6dd6f7fa6f9f18e7e46a1c937110d283e80b12ba2468a75" +checksum = "6fca7cd8fd809b5ac4eefb89c1f98f7a7651d3739dfb341ca6980090f554c270" dependencies = [ "libc", "pyo3-build-config", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4f74086536d1e1deaff99ec0387481fb3325c82e4e48be0e75ab3d3fcb487a" +checksum = "34e657fa5379a79151b6ff5328d9216a84f55dc93b17b08e7c3609a969b73aa0" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e77dfeb76b32bbf069144a5ea0a36176ab59c8db9ce28732d0f06f096bbfbc8" +checksum = "295548d5ffd95fd1981d2d3cf4458831b21d60af046b729b6fd143b0ba7aee2f" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index b8b825f..7d0dc72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ name = "wassima" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.23.1", features = ["abi3-py37", "extension-module"] } +pyo3 = { version = "0.23.2", features = ["abi3-py37", "extension-module"] } rustls-native-certs = "0.7.3" [package.metadata.maturin] diff --git a/freethreaded.patch b/freethreaded.patch deleted file mode 100644 index 9c23585..0000000 --- a/freethreaded.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/Cargo.toml b/Cargo.toml -index b8b825f..952e25c 100644 ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -9,7 +9,7 @@ name = "wassima" - crate-type = ["cdylib"] - - [dependencies] --pyo3 = { version = "0.23.1", features = ["abi3-py37", "extension-module"] } -+pyo3 = { version = "0.23.1", features = ["extension-module"] } - rustls-native-certs = "0.7.3" - - [package.metadata.maturin] -diff --git a/pyproject.toml b/pyproject.toml -index 60bb86b..524b1b6 100644 ---- a/pyproject.toml -+++ b/pyproject.toml -@@ -46,7 +46,7 @@ dependencies = [ - "Issue tracker" = "https://github.com/jawah/wassima/issues" - - [tool.maturin] --features = ["pyo3/extension-module", "pyo3/abi3-py37"] -+features = ["pyo3/extension-module"] - module-name = "wassima._rustls" - - [tool.pytest.ini_options] -diff --git a/src/lib.rs b/src/lib.rs -index fe02367..75cdafa 100644 ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -20,7 +20,7 @@ fn root_der_certificates(py: Python) -> PyResult>> { - Ok(roots) - } - --#[pymodule] -+#[pymodule(gil_used = false)] - fn _rustls(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add_function(wrap_pyfunction!(root_der_certificates, m)?)?; - Ok(()) diff --git a/pyproject.toml b/pyproject.toml index 60bb86b..3be87c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["maturin>=1.2,<2.0"] +requires = ["maturin>=1.7.5,<2.0"] build-backend = "maturin" [project] diff --git a/src/lib.rs b/src/lib.rs index fe02367..75cdafa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ fn root_der_certificates(py: Python) -> PyResult>> { Ok(roots) } -#[pymodule] +#[pymodule(gil_used = false)] fn _rustls(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(root_der_certificates, m)?)?; Ok(()) From cfe2de1f4dc41caa7489599877a7dbf2be52d3f1 Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Wed, 27 Nov 2024 09:58:08 +0100 Subject: [PATCH 38/39] :arrow_up: pyo3 killed pypy 3.7 and 3.8 support --- .github/workflows/CI.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7b6eff5..333d0ed 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -34,7 +34,7 @@ jobs: strategy: matrix: os: [ubuntu-22.04, macos-13, windows-latest ] - python_version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10'] + python_version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.9', 'pypy-3.10'] exclude: - python_version: 3.7 os: macos-13 @@ -93,7 +93,7 @@ jobs: fail-fast: false matrix: target: [x86_64, x86, aarch64, armv7, s390x, ppc64le, ppc64, i686] - python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10', '3.13t'] + python_version: ['3.10', 'pypy-3.9', 'pypy-3.10', '3.13t'] manylinux: ['auto', 'musllinux_1_1'] exclude: - manylinux: musllinux_1_1 @@ -135,7 +135,7 @@ jobs: fail-fast: false matrix: target: [x64, aarch64] - python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10', '3.13t'] + python_version: ['3.10', 'pypy-3.9', 'pypy-3.10', '3.13t'] exclude: - target: aarch64 python_version: 'pypy-3.7' @@ -180,7 +180,7 @@ jobs: fail-fast: false matrix: target: [x86_64, aarch64, universal2] - python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10', '3.13t'] + python_version: ['3.10', 'pypy-3.9', 'pypy-3.10', '3.13t'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 From b2f4e5d3ef06da2c3bee391de8ceb8e2847ad1be Mon Sep 17 00:00:00 2001 From: Ahmed TAHRI Date: Wed, 27 Nov 2024 10:26:02 +0100 Subject: [PATCH 39/39] :arrow_up: linux build force 3.13t location --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 333d0ed..67255f8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -117,7 +117,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter ${{ matrix.python_version }} + args: --release --out dist --interpreter ${{ matrix.python_version == '3.13t' && '/opt/python/cp313-cp313t/bin/python' || matrix.python_version }} sccache: 'true' manylinux: ${{ matrix.manylinux }} - name: Upload wheels