pstatix
pstatix

Reputation: 3848

What does setuptools.setup do with all the metadata keywords?

Getting to a point with my project that I want to distribute it, so I am reading the docs to better familiarize myself with all the information. Eventually I found myself looking at distutils.core.setup and all the keywords associated with it and it got me wondering:

What are the keywords used for, where do they go and why do we need them?

After running sdist on some temporary scaffolding project, I noticed that a PKG-INFO appeared with some of this metadata in it. But thats the only place I could find them after running the command. There is the upload command (or I could use twine) to get the source distribution onto PyPI, so I suppose maybe its a convention used to pass information that is then parsed and loaded onto the PyPI web page for the distribution?

Upvotes: 1

Views: 341

Answers (1)

Dustin Ingram
Dustin Ingram

Reputation: 21520

so I suppose maybe its a convention used to pass information that is then parsed and loaded onto the PyPI web page for the distribution?

You're precisely right. Most of these keywords represent various core metadata fields that define all Python package distributions.

These path of this data is roughly this:

  • You specify the keywords to the setup function;
  • This is written to the PKG-INFO file when building a distribution;
  • When uploading, twine reads from PKG-INFO to determine all the metadata about your distribution;
  • twine uploads this metadata along with your .zip, .tar.gz or .whl file
  • PyPI stores this metadata in it's database for your project.

Upvotes: 2

Related Questions