From 7c5222799e3f2077e13f3538bc06cea7dfac9c12 Mon Sep 17 00:00:00 2001 From: Arie Bovenberg Date: Fri, 2 Aug 2024 10:15:51 +0200 Subject: [PATCH] add python 3.13 wheels, now that its ABI is stable --- .github/workflows/wheels.yml | 6 ++++-- CHANGELOG.rst | 6 ++++++ pyproject.toml | 2 +- pysrc/whenever/_pywhenever.py | 2 +- src/lib.rs | 24 +++++++++++++----------- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index f809884f..ec0ecf62 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -61,9 +61,11 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + if : ${{ matrix.os == 'windows' }} with: - python-version: '3.12' + python-version: '3.13' architecture: ${{ matrix.python-architecture || 'x64' }} + allow-prereleases: true - run: pip install -U twine - name: Generate third-party license information run: | @@ -73,7 +75,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --strip --out dist --interpreter '3.9 3.10 3.11 3.12' + args: --release --strip --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' manylinux: ${{ matrix.manylinux || 'auto' }} sccache: 'true' rust-toolchain: "1.79" diff --git a/CHANGELOG.rst b/CHANGELOG.rst index eaf3900b..5383d7de 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ 🚀 Changelog ============ +0.6.7 (2024-08-02) +------------------ + +- Add Python 3.13 binary wheels, now that its ABI is stable +- Small improvements to import speed + 0.6.6 (2024-07-27) ------------------ diff --git a/pyproject.toml b/pyproject.toml index 3fd62b23..c060aa8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ authors = [ {name = "Arie Bovenberg", email = "a.c.bovenberg@gmail.com"}, ] readme = "README.md" -version = "0.6.6" +version = "0.6.7rc0" description = "Modern datetime library for Python, written in Rust" requires-python = ">=3.9" classifiers = [ diff --git a/pysrc/whenever/_pywhenever.py b/pysrc/whenever/_pywhenever.py index a61578ac..63e7cd99 100644 --- a/pysrc/whenever/_pywhenever.py +++ b/pysrc/whenever/_pywhenever.py @@ -32,7 +32,7 @@ # - It saves some overhead from __future__ import annotations -__version__ = "0.6.6" +__version__ = "0.6.7rc0" import enum import re diff --git a/src/lib.rs b/src/lib.rs index d623c7f2..d01953c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -440,22 +440,24 @@ unsafe extern "C" fn module_exec(module: *mut PyObject) -> c_int { // Making time patcheable results in a performance hit. // Only enable it if the time_machine module is available. - state.time_machine_exists = match PyImport_ImportModule(c"time_machine".as_ptr()).as_result() { - Ok(m) => { - Py_DecRef(m); - true - } - Err(_) => { - PyErr_Clear(); - false - } - }; - + state.time_machine_exists = unwrap_or_errcode!(time_machine_installed()); state.time_patch = TimePatch::Unset; 0 } +unsafe fn time_machine_installed() -> PyResult { + // Important: we don't import the `time_machine` here, + // because that would be slower. We only need to check its existence. + let find_spec = PyObject_GetAttrString( + steal!(PyImport_ImportModule(c"importlib.util".as_ptr()).as_result()?), + c"find_spec".as_ptr(), + ); + let spec = call1(find_spec, steal!("time_machine".to_py()?))?; + defer_decref!(spec); + Ok(!((spec as *mut PyObject) == Py_None())) +} + unsafe fn do_visit(target: *mut PyObject, visit: visitproc, arg: *mut c_void) { let obj: *mut PyObject = target.cast(); if !obj.is_null() {