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
2 changes: 1 addition & 1 deletion guide/src/distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ or providing any Windows Python library files.

```toml
[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module", "generate-import-lib"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should still point out extension-module feature is required for pyo3 < 0.27.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added it back to the tutorial: 5a2a40f Not sure if it's the best place though

pyo3 = { version = "0.27.0", features = ["generate-import-lib"] }
```

It uses an external [`python3-dll-a`](https://docs.rs/python3-dll-a/latest/python3_dll_a/) crate to
Expand Down
8 changes: 5 additions & 3 deletions guide/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ version = "0.27.0"
features = ["abi3-py38"]
```

Add a `pyproject.toml` to configure [PEP 518](https://peps.python.org/pep-0518/) build system requirements
and enable the `extension-module` feature of pyo3.
Add a `pyproject.toml` to configure [PEP 518](https://peps.python.org/pep-0518/) build system requirements.

```toml
[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"
```

If you are using pyo3 0.26 or earlier you need to enable the `extension-module` feature of pyo3 to skip linking against libpython.so (this is automatically done in pyo3 0.27):

```toml
[tool.maturin]
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
features = ["pyo3/extension-module"]
```

Expand Down
5 changes: 1 addition & 4 deletions src/templates/pyproject.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ tests = [
]
{% endif -%}

{% if bindings in ["bin", "cffi", "pyo3"] or mixed_non_src -%}
{% if bindings in ["bin", "cffi"] or mixed_non_src -%}
[tool.maturin]
{% if bindings == "cffi" or bindings == "bin" -%}
bindings = "{{ bindings }}"
{% endif -%}
{% if mixed_non_src -%}
python-source = "python"
{% endif -%}
{% if bindings == "pyo3" -%}
features = ["pyo3/extension-module"]
{% endif -%}
{% endif -%}
2 changes: 1 addition & 1 deletion test-crates/lib_with_disallowed_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ crate-type = ["cdylib"]

[dependencies]
libz-sys = { version = "1.1.2", default-features = false }
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"
2 changes: 1 addition & 1 deletion test-crates/lib_with_path_dep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"
some_path_dep = { path = "../some_path_dep" }
2 changes: 1 addition & 1 deletion test-crates/pyo3-abi3-without-version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["konstin <konstin@mailbox.org>"]
edition = "2021"

[dependencies]
pyo3 = { version = "0.27.0", features = ["abi3", "extension-module"] }
pyo3 = { version = "0.27.0", features = ["abi3"] }

[lib]
name = "pyo3_abi3_without_version"
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-ffi-pure/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "1.0.0"
edition = "2021"

[dependencies]
pyo3-ffi = { version = "0.18.1", features = ["abi3-py37", "extension-module"] }
pyo3-ffi = { version = "0.18.1", features = ["abi3-py37"] }

[lib]
name = "pyo3_ffi_pure"
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed-implicit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
edition = "2021"

[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"

[lib]
name = "pyo3_mixed_implicit"
Expand Down
1 change: 0 additions & 1 deletion test-crates/pyo3-mixed-implicit/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ classifiers = [
dynamic = ["version"]

[tool.maturin]
features = ["pyo3/extension-module"]
module-name = "pyo3_mixed_implicit.some_rust.rust"
python-source = "python"
5 changes: 1 addition & 4 deletions test-crates/pyo3-mixed-include-exclude/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ description = "Implements a dummy function combining rust and python"
edition = "2021"

[dependencies]
pyo3 = { version = "0.27.0", features = [
"extension-module",
"generate-import-lib",
] }
pyo3 = { version = "0.27.0", features = ["generate-import-lib"] }

[lib]
name = "pyo3_mixed_include_exclude"
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed-py-subdir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
edition = "2021"

[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"

[lib]
name = "pyo3_mixed_py_subdir"
Expand Down
5 changes: 1 addition & 4 deletions test-crates/pyo3-mixed-src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ description = "Implements a dummy function combining rust and python"
edition = "2021"

[dependencies]
pyo3 = { version = "0.27.0", features = [
"extension-module",
"generate-import-lib",
] }
pyo3 = { version = "0.27.0", features = ["generate-import-lib"] }

[lib]
name = "pyo3_mixed_src"
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed-submodule/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
edition = "2021"

[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"

[lib]
name = "pyo3_mixed_submodule"
Expand Down
5 changes: 1 addition & 4 deletions test-crates/pyo3-mixed-with-path-dep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ version = "2.1.3"
edition = "2021"

[dependencies]
pyo3 = { version = "0.27.0", features = [
"extension-module",
"generate-import-lib",
] }
pyo3 = { version = "0.27.0", features = ["generate-import-lib", ] }
some_path_dep = { path = "../some_path_dep" }

[lib]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ edition = "2021"

[dependencies]
pyo3-mixed-workspace = { path = "../../pyo3-mixed-workspace" }
pyo3 = { version = "0.27.0", features = [
"extension-module",
"generate-import-lib",
] }
pyo3 = { version = "0.27.0", features = ["generate-import-lib", ] }

[lib]
name = "pyo3_mixed_workspace_py"
Expand Down
5 changes: 1 addition & 4 deletions test-crates/pyo3-mixed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ description = "Implements a dummy function combining rust and python"
edition = "2021"

[dependencies]
pyo3 = { version = "0.27.0", features = [
"extension-module",
"generate-import-lib",
] }
pyo3 = { version = "0.27.0", features = ["generate-import-lib"] }

[lib]
name = "pyo3_mixed"
Expand Down
1 change: 0 additions & 1 deletion test-crates/pyo3-pure/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ license = "MIT"
[dependencies]
pyo3 = { version = "0.27.0", features = [
"abi3-py37",
"extension-module",
"generate-import-lib",
] }

Expand Down
3 changes: 0 additions & 3 deletions test-crates/readme-duplication/readme-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ build-backend = "maturin"
[project]
name = "readme-py"
version = "0.2.0"

[tool.maturin]
features = ["pyo3/extension-module"]
2 changes: 1 addition & 1 deletion test-crates/sdist_with_path_dep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"
some_path_dep = { path = "../some_path_dep" }
2 changes: 1 addition & 1 deletion test-crates/sdist_with_target_path_dep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"

[target.'cfg(not(target_endian = "all-over-the-place"))'.dependencies]
some_path_dep = { path = "../some_path_dep" }
2 changes: 1 addition & 1 deletion test-crates/workspace-inheritance/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "workspace_inheritance"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"
generic_lib.workspace = true

[dependencies.libc]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ top_level = { path = "../" }
pyo3 = { version = "0.27.0", features = [
"abi3",
"abi3-py38",
"extension-module",
] }
2 changes: 1 addition & 1 deletion test-crates/workspace_with_path_dep/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"
generic_lib = { path = "../generic_lib" }
3 changes: 1 addition & 2 deletions tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ fn workspace_members_non_local_dep_sdist() {
[dependencies]
pyo3 = { version = "0.27.0", features = [
"abi3-py37",
"extension-module",
"generate-import-lib",
] }

Expand Down Expand Up @@ -720,7 +719,7 @@ fn lib_with_target_path_dep_sdist() {
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.27.0", features = ["extension-module"] }
pyo3 = "0.27.0"

[target.'cfg(not(target_endian = "all-over-the-place"))'.dependencies]
some_path_dep = { path = "../some_path_dep" }
Expand Down
Loading