Cargo Features
[dependencies]
cpython = { version = "0.7.2", default-features = false, features = ["serde-convert", "nonnull", "nightly", "extension-module", "extension-module-2-7", "py-link-mode-default", "py-link-mode-unresolved-static", "python-3-11", "python-3-10", "python-3-9", "python-3-8", "python-3-7", "python-3-6", "python-3-5", "python-3-4", "no-auto-initialize", "py2-no-auto-unicode-promotion"] }
- default = python3-sys
-
The
python3-sys
feature is set by default whenevercpython
is added without
somewhere in the dependency tree.default-features = false - serde-convert = serde
-
Enable serde support that converts between a serde type and PyObject.
Affects
cpython::serde
… - nonnull
-
Deprecated: nonnull feature no longer has any effect;
std::ptr::NonNull is now used unconditionally. - nightly
-
Enable additional features that require nightly rust
- extension-module
-
Use this feature when building an extension module.
It tells the linker to keep the python symbols unresolved,
so that the module can also be used with statically linked python interpreters.Enables extension-module of python3-sys
- extension-module-2-7
-
Unfortunately we can't use the forward the same feature to either python27-sys or python3-sys. (honestly, we should probably merge both crates into 'python-sys')
Enables extension-module of python27-sys
- py-link-mode-default
-
Use these features to explicitly control linking for Python 3.
(See the documentation in python3-sys/Cargo.toml for more info.)Enables link-mode-default of python3-sys
- py-link-mode-unresolved-static
-
Enables link-mode-unresolved-static of python3-sys
python3-sys:
This feature forces Python symbols to be unresolved by emitting a
rustc-link-lib=static-nobundle=pythonXY
directive on Windows (which is the only platform where it makes sense).This mode is useful for scenarios where you want another crate to emit the linker directives that define the location of a static Python library.
This mode is typically not needed, as Python distributions on Windows rarely use a static Python library.
- python-3-11
-
Optional features to support explicitly specifying python minor version.
If you don't care which minor version, just specify python3-sys as a feature.Enables python-3-11 of python3-sys
- python-3-10
-
Enables python-3-10 of python3-sys
- python-3-9
-
Enables python-3-9 of python3-sys
- python-3-8
-
Enables python-3-8 of python3-sys
- python-3-7
-
Enables python-3-7 of python3-sys
- python-3-6
-
Enables python-3-6 of python3-sys
- python-3-5
-
Enables python-3-5 of python3-sys
- python-3-4
-
Enables python-3-4 of python3-sys
python3-sys:
Or, bind to a particular minor version.
- no-auto-initialize
-
When set, do not call prepare_freethreaded_python() when calling GILGuard::acquire(). This effectively prevents the crate from automatically calling Py_Initialize() and other functions that attempt to automatically initialize the Python interpreter.
This feature can be useful for programs embedding Python, which can guarantee Python interpreter initialization and don't need the automatic-by-default behavior or don't want the behavior coded into this crate.
The feature may also be necessary if this crate's code executes as part of Python interpreter initialization, before the Py_Initialize() call completes.
This scenario should be rare. - py2-no-auto-unicode-promotion
-
Only affect Python 2. Once set,
PyString
andString
converts to onlybytes
(aka.str
on Python 2). Non-ascii string will no longer be converted tounicode
.
Features from optional dependencies
In crates that don't use the dep:
syntax, optional dependencies automatically become Cargo features. These features may have been created by mistake, and this functionality may be removed in the future.
- serde serde-convert?
- python27-sys extension-module-2-7?
-
Affects
cpython::Py_hash_t
,cpython::py_module_initializer_impl
,objectprotocol::ObjectProtocol.unistr
,objects::oldstyle
,num::PyInt
,string::PyUnicode
,slots::TPFLAGS_DEFAULT
… - python3-sys default extension-module? py-link-mode-default? py-link-mode-unresolved-static? python-3-10? python-3-11? python-3-4? python-3-5? python-3-6? python-3-7? python-3-8? python-3-9?
-
Affects
cpython::Py_hash_t
,cpython::py_module_initializer_impl
,number::NumberProtocol.matrix_multiply
,slots::TPFLAGS_DEFAULT
…