Build and publish crates with pyo3 bindings as python packages.
You can install pyo3-pack with
shell
cargo install pyo3-pack
The publish
subcommand builds the crate into python packages and publishes the wheels to pypi. The build
subcommand builds the packages and stores them in a folder, but doesn't upload them.
The name of the package will be the name field of the [lib]
section in the Cargot.toml, which defaults to the name of the package.
You can add console scripts in a section [package.metadata.pyo3-pack.scripts]
. The keys are the script names while the values are the path to the function in the format some.module.path:class.function
, where the class
part is optional. Example:
toml
[package.metadata.pyo3-pack.scripts]
get_42 = "get_fourtytwo:DummyClass.get_42"
pyo3-pack can only build packages for installed python versions, so you might need to use e.g. deadsnakes or docker for building.
``` USAGE: pyo3-pack build [FLAGS] [OPTIONS]
FLAGS: -d, --debug Do a debug build (don't pass --release to cargo) -h, --help Prints help information --skip-auditwheel Don't check for manylinux compliance --use-cached Don't rebuild if a wheel with the same name is already present -V, --version Prints version information
OPTIONS:
-b, --bindings-crate
``` USAGE: pyo3-pack publish [FLAGS] [OPTIONS]
FLAGS: -d, --debug Do a debug build (don't pass --release to cargo) -h, --help Prints help information --skip-auditwheel Don't check for manylinux compliance --use-cached Don't rebuild if a wheel with the same name is already present -V, --version Prints version information
OPTIONS:
-b, --bindings-crate
This repository consists of the main pyo3-pack crate, which is a library with a single binary target that is mostly handling username and password for the pypi upload, a get_fourtytwo
crate with python bindings and some dummy functionally (such as returning 42) and the integration test folder with some basic testing utilities.
You might want to have look into my blog post which explains all the nitty-gritty details on building python packages.