Which fields are required for a setup.py? Especially, is author required?

Hi,
what is the absolute minimum of a setup.py for a package to upload to PyPi?

I could not find a dedicated list.

Background:
I ported a very old Python package back from 2003 to Python 3 and I’d like to release it on PyPi.

Obviously, now I am the maintainer, but not the author.

I tried to add author to setup.py, but then both python setup.py check and pep517 warn me about the missing author_email field which I do not know - and most probably the author does not want to get involved in this very old package any more.

❯ python setup.py check
running check
warning: Check: missing meta-data: if 'author' supplied, 'author_email' must be supplied too

All “minimal” setup.py guides on the net list author and author_email as required.

Is it viable to leave out both author fields?

Thank you!

From what I understand, both author and author_email fields are optional. It’s just Setuptools really wants you to supply one :stuck_out_tongue:

I believe all fields in setup.py are actually “optional” in the sense that a package can be built successfully without any of them. You at least need a name to upload to PyPI (unless your package is named UNKNOWN which is the default).

1 Like

Technically, the required fields are defined in the metadata spec (Metadata-Version, Name and Version).

Setuptools may have its own rules beyond that, but if so, I don’t know where they are documented.

1 Like

To preserve the original author credit and still keep all the tooling happy, you could set author_email to a fake address under the .invalid TLD, like this maybe:

setup(
    # Original author is no longer involved in development.
    # Their current contact information is unknown.
    author           = 'John Dough',
    author_email     = 'current.address@unknown.invalid',
    maintainer       = 'Jürgen Gmach',
    maintainer_email = 'jugmac00@your.real.email.example',
    # ...
)
1 Like

Thank you very much for your answers!

Providing an invalid email address just to please the tooling feels a bit weird, though.

I just created a test package and uploaded it to the test instance of PyPi and it seems author_email is not really required - PyPi renders the name of the author nicely.

I created an issue at pep517’s issue tracker, as in regard to the warning text - if it was a must requirement, the build should fail.

1 Like

The misleading warning comes form distutils within cpython.

I created an issue at their bug tracker and a pr:

Cross your fingers! :slight_smile:

1 Like