Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ 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 }
rust_decimal = { version = "1.15", default-features = false, optional = true }
time = { version = "0.3.38", default-features = false, optional = true }
serde = { version = "1.0", optional = true }
smallvec = { version = "1.0", optional = true }
uuid = { version = "1.11.0", optional = true }
Expand Down
11 changes: 11 additions & 0 deletions guide/src/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ Adds a dependency on [num-rational](https://docs.rs/num-rational) and enables co

Adds a dependency on [rust_decimal](https://docs.rs/rust_decimal) and enables conversions into its [`Decimal`](https://docs.rs/rust_decimal/latest/rust_decimal/struct.Decimal.html) type.

### `time`

Adds a dependency on [time](https://docs.rs/time) and requires MSRV 1.67.1. Enables conversions between [time](https://docs.rs/time)'s types and Python:
- [Date](https://docs.rs/time/0.3.38/time/struct.Date.html) -> [`PyDate`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDate.html)
- [Time](https://docs.rs/time/0.3.38/time/struct.Time.html) -> [`PyTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTime.html)
- [OffsetDateTime](https://docs.rs/time/0.3.38/time/struct.OffsetDateTime.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)
- [PrimitiveDateTime](https://docs.rs/time/0.3.38/time/struct.PrimitiveDateTime.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)
- [Duration](https://docs.rs/time/0.3.38/time/struct.Duration.html) -> [`PyDelta`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDelta.html)
- [UtcOffset](https://docs.rs/time/0.3.38/time/struct.UtcOffset.html) -> [`PyTzInfo`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTzInfo.html)
- [UtcDateTime](https://docs.rs/time/0.3.38/time/struct.UtcDateTime.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)

### `serde`

Enables (de)serialization of `Py<T>` objects via [serde](https://serde.rs/).
Expand Down
1 change: 1 addition & 0 deletions newsfragments/5057.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Integrate `time` crate into PyO3
16 changes: 12 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,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-02")
_run_cargo_test(session, features="full jiff-02 time")
if not FREE_THREADED_BUILD:
_run_cargo_test(session, features="abi3 full jiff-02")
_run_cargo_test(session, features="abi3 full jiff-02 time")


@nox.session(name="test-py", venv_backend="none")
Expand Down Expand Up @@ -429,6 +429,10 @@ def docs(session: nox.Session) -> None:

features = "full"

if get_rust_version()[:2] >= (1, 67):
# time needs MSRC 1.67+
features += ",time"

if get_rust_version()[:2] >= (1, 70):
# jiff needs MSRC 1.70+
features += ",jiff-02"
Expand Down Expand Up @@ -819,8 +823,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-02", env=env)
_run_cargo(session, *command, "--features=abi3,full,jiff-02", env=env)
_run_cargo(session, *command, "--features=full,jiff-02,time", env=env)
_run_cargo(session, *command, "--features=abi3,full,jiff-02,time", env=env)


@nox.session(name="test-introspection")
Expand Down Expand Up @@ -891,6 +895,10 @@ def _get_feature_sets() -> Generator[Tuple[str, ...], None, None]:
# multiple-pymethods not supported on wasm
features += ",multiple-pymethods"

if get_rust_version()[:2] >= (1, 67):
# time needs MSRC 1.67+
features += ",time"

if get_rust_version()[:2] >= (1, 70):
# jiff needs MSRC 1.70+
features += ",jiff-02"
Expand Down
1 change: 1 addition & 0 deletions src/conversions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ pub mod rust_decimal;
pub mod serde;
pub mod smallvec;
mod std;
pub mod time;
pub mod uuid;
Loading
Loading