Python Project Metadata

maturin supports PEP 621, you can specify python package metadata in pyproject.toml. maturin merges metadata from Cargo.toml and pyproject.toml, pyproject.toml take precedence over Cargo.toml.

Here is a pyproject.toml example from PEP 621 for reference purpose:

name = "spam"
version = "2020.0.0"
description = "Lovely Spam! Wonderful Spam!"
readme = "README.rst"
requires-python = ">=3.8"
license = {file = "LICENSE.txt"}
keywords = ["egg", "bacon", "sausage", "tomatoes", "Lobster Thermidor"]
authors = [
  {email = ""},
  {name = "Tzu-Ping Chung"}
maintainers = [
  {name = "Brett Cannon", email = ""}
classifiers = [
  "Development Status :: 4 - Beta",
  "Programming Language :: Python"

dependencies = [
  "django>2.1; os_name != 'nt'",
  "django>2.0; os_name == 'nt'"

test = [
  "pytest < 5.0.0",

homepage = ""
documentation = ""
repository = ""
changelog = ""

spam-cli = "spam:main_cli"

spam-gui = "spam:main_gui"

tomatoes = "spam:main_tomatoes"

Add Python dependencies

To specify python dependencies, add a list dependencies in a [project] section in the pyproject.toml. This list is equivalent to install_requires in setuptools:

name = "my-project"
dependencies = ["flask~=1.1.0", "toml==0.10.0"]

Add console scripts

Pip allows adding so called console scripts, which are shell commands that execute some function in you program. You can add console scripts in a section [project.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. The function is called with no arguments. Example:

get_42 = "my_project:DummyClass.get_42"

Add trove classifiers

You can also specify trove classifiers under project.classifiers:

name = "my-project"
classifiers = ["Programming Language :: Python"]

Add SPDX license expressions

A practical string value for the license key has been purposefully left out by PEP 621 to allow for a future PEP to specify support for SPDX expressions.

To use SPDX license expressions, you can specify it in Cargo.toml instead:

name = "my-project"
license = "MIT OR Apache-2.0"