PEP 621 Project metadata#
PDM reads the project's metadata following the standardized format of PEP 621.
View the PEP for the detailed specification. These metadata are stored in [project]
table of pyproject.toml
.
In the following part of this document, metadata should be written under [project]
table if not given explicitly.
Multiline description#
You can split a long description onto multiple lines, thanks to TOML support for multiline strings. Just remember to escape new lines, so the final description appears on one line only in your package metadata. Indentation will be removed as well when escaping new lines:
1 2 3 4 5 6 |
|
See TOML's specification on strings.
Determine the package version dynamically#
The package version can be retrieved from the __version__
variable of a given file. To do this, put the following
under the [tool.pdm]
table:
1 2 |
|
Remember set dynamic = ["version"]
in [project]
metadata.
PDM can also read version from SCM tags. If you are using git or hg as the version control system, define the
version
as follows:
1 2 |
|
In either case, you MUST delete the version
field from the [project]
table, and include version
in the dynamic
field, or the backend will raise an error:
1 |
|
Dependency specification#
The project.dependencies
is an array of dependency specification strings following the PEP 440
and PEP 508.
Examples:
1 2 3 4 5 6 7 8 9 10 |
|
Editable requirement#
Beside of the normal dependency specifications, one can also have some packages installed in editable mode. The editable specification string format is the same as Pip's editable install mode.
Examples:
1 2 3 4 5 |
|
About editable installation
One can have editable installation and normal installation for the same package. The one that comes at last wins. However, editable dependencies WON'T be included in the metadata of the built artifacts since they are not valid PEP 508 strings. They only exist for development purpose.
Optional dependencies#
You can have some requirements optional, which is similar to setuptools
' extras_require
parameter.
1 2 3 4 5 6 7 |
|
To install a group of optional dependencies:
1 |
|
-G
option can be given multiple times to include more than one group.
Console scripts#
The following content:
1 2 |
|
will be translated to setuptools
style:
1 2 3 4 5 |
|
Also, [project.gui-scripts]
will be translated to gui_scripts
entry points group in setuptools
style.
Entry points#
Other types of entry points are given by [project.entry-points.<type>]
section, with the same
format of [project.scripts]
:
1 2 |
|