Skip to content

Commit

Permalink
Moved jiff support to jiff-01 feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Jan 7, 2025
1 parent 1950ec1 commit 0c75af4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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 = [
Expand Down
12 changes: 6 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/conversions/jiff.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(feature = "jiff")]
#![cfg(feature = "_jiff")]

use crate::exceptions::{PyTypeError, PyValueError};
use crate::pybacked::PyBackedStr;
Expand All @@ -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>(
Expand Down
4 changes: 2 additions & 2 deletions src/types/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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<Bound<'py, PyTzInfo>> {
Expand Down
2 changes: 1 addition & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0c75af4

Please sign in to comment.