Reputation: 13913
I am developing a project using Setuptools, and in a couple of places (e.g. scripts, the Sphinx docs) I want to be able to use pieces of project metadata, such as the version, name, authors, etc. I want to avoid hard-coding these values, as they are all subject to change.
I am using pyproject.toml
to define metadata containing some dynamic
values, and I also have a setup.py
that builds some Cython extensions.
I am aware that importlib.metadata
gives you access to metadata of installed distributions, but for team-specific reasons I cannot necessarily assume that my project is installed into any particular environment.
I also want to avoid manually parsing pyproject.toml
and ad-hoc reimplementing the Setuptools logic.
Does Setuptools have a stable Python API for this purpose?
Ideally I would be able to pass a directory (maybe just '.'
) to some function, and get a distutils.core.Distribution
that I can work with and get information from, which contains the metadata extracted from pyproject.toml
, setup.cfg
, and/or setup.py
.
Upvotes: 2
Views: 39