From 0c75af4977ff1f3b71dda67f141935c297f420eb Mon Sep 17 00:00:00 2001 From: Bas Schoenmaeckers Date: Tue, 7 Jan 2025 14:03:33 +0100 Subject: [PATCH] Moved jiff support to `jiff-01` feature --- .github/workflows/ci.yml | 2 +- Cargo.toml | 5 ++++- noxfile.py | 12 ++++++------ src/conversions/jiff.rs | 4 +++- src/types/datetime.rs | 4 ++-- src/types/mod.rs | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fa39c7baaa..ea044a5f8a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -439,7 +439,7 @@ jobs: - uses: dtolnay/rust-toolchain@nightly with: components: rust-src - - run: cargo rustdoc --lib --no-default-features --features full,jiff -Zunstable-options --config "build.rustdocflags=[\"--cfg\", \"docsrs\"]" + - run: cargo rustdoc --lib --no-default-features --features full,jiff-01 -Zunstable-options --config "build.rustdocflags=[\"--cfg\", \"docsrs\"]" coverage: if: ${{ github.event_name != 'merge_group' }} diff --git a/Cargo.toml b/Cargo.toml index ac937ae2f9c..442398d1be8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ either = { version = "1.9", optional = true } eyre = { version = ">= 0.6.8, < 0.7", optional = true } hashbrown = { version = ">= 0.14.5, < 0.16", optional = true } indexmap = { version = ">= 2.5.0, < 3", optional = true } -jiff = { version = "0.1.18", optional = true } +jiff-01 = { package = "jiff", version = "0.1.18", optional = true } num-bigint = { version = "0.4.2", optional = true } num-complex = { version = ">= 0.4.6, < 0.5", optional = true } num-rational = {version = "0.4.1", optional = true } @@ -113,6 +113,9 @@ py-clone = [] # Optimizes PyObject to Vec conversion and so on. nightly = [] +_jiff = [] +jiff-01 = ["_jiff", "dep:jiff-01"] + # Activates all additional features # This is mostly intended for testing purposes - activating *all* of these isn't particularly useful. full = [ diff --git a/noxfile.py b/noxfile.py index 0122deda823..a786a40b0d1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -55,9 +55,9 @@ def test_rust(session: nox.Session): if not FREE_THREADED_BUILD: _run_cargo_test(session, features="abi3") if "skip-full" not in session.posargs: - _run_cargo_test(session, features="full jiff") + _run_cargo_test(session, features="full jiff-01") if not FREE_THREADED_BUILD: - _run_cargo_test(session, features="abi3 full jiff") + _run_cargo_test(session, features="abi3 full jiff-01") @nox.session(name="test-py", venv_backend="none") @@ -131,7 +131,7 @@ def clippy(session: nox.Session) -> bool: def _clippy(session: nox.Session, *, env: Dict[str, str] = None) -> bool: success = True env = env or os.environ - jiff_features_set = (("--features=jiff",), ("--features=jiff abi3",)) + jiff_features_set = (("--features=jiff-01",), ("--features=jiff-01 abi3",)) for feature_set in _get_feature_sets() + jiff_features_set: try: _run_cargo( @@ -388,7 +388,7 @@ def docs(session: nox.Session) -> None: "doc", "--lib", "--no-default-features", - "--features=full,jiff", + "--features=full,jiff-01", "--no-deps", "--workspace", *cargo_flags, @@ -761,8 +761,8 @@ def update_ui_tests(session: nox.Session): env["TRYBUILD"] = "overwrite" command = ["test", "--test", "test_compile_error"] _run_cargo(session, *command, env=env) - _run_cargo(session, *command, "--features=full,jiff", env=env) - _run_cargo(session, *command, "--features=abi3,full,jiff", env=env) + _run_cargo(session, *command, "--features=full,jiff-01", env=env) + _run_cargo(session, *command, "--features=abi3,full,jiff-01", env=env) def _build_docs_for_ffi_check(session: nox.Session) -> None: diff --git a/src/conversions/jiff.rs b/src/conversions/jiff.rs index 4d9855bbbf8..d0147c7eedd 100644 --- a/src/conversions/jiff.rs +++ b/src/conversions/jiff.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "jiff")] +#![cfg(feature = "_jiff")] use crate::exceptions::{PyTypeError, PyValueError}; use crate::pybacked::PyBackedStr; @@ -19,6 +19,8 @@ use crate::{intern, Bound, FromPyObject, IntoPyObject, Py, PyAny, PyErr, PyResul use jiff::civil::{Date, DateTime, Time}; use jiff::tz::{Offset, TimeZone}; use jiff::{SignedDuration, Span, Timestamp, Zoned}; +#[cfg(feature = "jiff-01")] +use jiff_01 as jiff; #[cfg(not(Py_LIMITED_API))] fn datetime_to_pydatetime<'py>( diff --git a/src/types/datetime.rs b/src/types/datetime.rs index e70f862a253..5a3da2242d9 100644 --- a/src/types/datetime.rs +++ b/src/types/datetime.rs @@ -27,7 +27,7 @@ use crate::types::any::PyAnyMethods; use crate::types::PyTuple; use crate::{Bound, IntoPyObject, PyAny, PyErr, Python}; use std::os::raw::c_int; -#[cfg(any(feature = "chrono", feature = "jiff"))] +#[cfg(any(feature = "chrono", feature = "_jiff"))] use std::ptr; fn ensure_datetime_api(py: Python<'_>) -> PyResult<&'static PyDateTime_CAPI> { @@ -698,7 +698,7 @@ pub fn timezone_utc_bound(py: Python<'_>) -> Bound<'_, PyTzInfo> { /// Equivalent to `datetime.timezone` constructor /// /// Only used internally -#[cfg(any(feature = "chrono", feature = "jiff"))] +#[cfg(any(feature = "chrono", feature = "_jiff"))] pub(crate) fn timezone_from_offset<'py>( offset: &Bound<'py, PyDelta>, ) -> PyResult> { diff --git a/src/types/mod.rs b/src/types/mod.rs index 26fbf14df60..69e6260b139 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -239,7 +239,7 @@ mod code; pub(crate) mod complex; #[cfg(not(Py_LIMITED_API))] pub(crate) mod datetime; -#[cfg(all(Py_LIMITED_API, any(feature = "jiff", feature = "chrono")))] +#[cfg(all(Py_LIMITED_API, any(feature = "chrono", feature = "_jiff")))] pub(crate) mod datetime_abi; pub(crate) mod dict; mod ellipsis;