What is the full list of keyword arguments that the setuptools.setup() function accepts? (Please include a description of what each argument means, if possible.)
I have looked all over the web and I can't believe this isn't documented.
I found these documents:
- https://docs.python.org/3.7/distutils/setupscript.html#additional-meta-data
- https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords
But even when I combine these, they are missing other arguments such as
- scripts
- packages
- provides
- obsoletes
...and I don't know how many more arguments are missing.
What is the full list of keyword arguments that the setuptools.setup() function accepts?
Update (January 2024):
The Setup Tools maintainers have largely fixed the documentation gap that existed in late 2019 and a year or two thereafter.
The official documentation should be the preferred reference for this information going forward, although this post is still accurate (in January 2024) as both documents are based on the same sources.
Original Answer:
setuptools.setup()callsdistutils.core.setup()and passes it's own**kwargsas the only parameter, so any keywords thatdistutilsaccepts will also be accepted bysetuptools. If we go look atdistutilsMost of these are documented here but some are not included in the table: packages, package_dir, package_data, scripts, obsoletes, provides, py_modules and data_files.
Some of these are also missing from the
setup_keywordstuple. And if you grep forsetup_keywordsit doesn't look like that it's actually referenced anywhere.... But that's a story for another day. Anyway, here is the (hopefully complete) list for Python 3.10.distutils.core.setup() keyword arguments
(Required: name, version, and at least one of author or maintainer)
author:
author_email:
classifiers:
data_files:
description:
download_url:
keywords:
license:
long_description:
maintainer:
maintainer_email:
name:
obsoletes:
package_data:
package_dir:
packages:
platforms:
provides:
py_modules:
scripts:
url:
version:
setuptools.setup() keyword arguments
There are even more arguments that
setuptools.setup()will accept, beyond those which are used bydistutils.Although it's called "New and Changed Setup Keywords" (which to me suggests a version changelog), the intro text says these are "keyword arguments to setup() [that are] added or changed by setuptools" so I believe the link actually provides a complete list. I will add it here for completeness.
(Since
setuptools.setup()callsdistutils.core.setup(), the same parameters are Required: name, version, and at least one of author or maintainer)convert_2to3_doctests:
dependency_links:
eager_resources:
entry_points:
exclude_package_data:
extras_require:
NOTE: For the
extras_requiredictionarhy, in versions prior to 54.1.0 if dashes were used in keys, the were converted to underscores. Later versions allow dashes and warn users if they use an alias containing dashes that should use underscores (eg.author-emailinstead ofauthor_email), and in such cases the conversion is still performed. In the future this conversion will no longer be done automatically.include_package_data:
install_requires:
namespace_packages:
package_data:
project_urls:
python_requires:
setup_requires:
test_loader:
test_suite:
tests_require:
use_2to3:
use_2to3_exclude_fixers:
use_2to3_fixers:
zip_safe:
Extensions
Building an extension (rather than a pure Python module) is more complicated, since it essentially requires you to specify the necessary parameters and arguments to successfully build the extension from C source files. This is done through the
ext_moduleskeyword, which is nothing but a list ofExtensioninstances (importable fromdistutils.core). The keyword arguments accepted by theExtensionclass constructor are the input vector for specifying the build steps to compile the extension.Since this question is about
setuptools.setup()specifically, I will only include the definition ofext_modules, but the documentation for theExtensionclass provides full details. For completeness, this is the list of accepted keywords for theExtensionconstructor:ext_modules:
Misc.
Finally, there are even more kwargs which can be found implemented in
setuptools.distand elsewhere, but for some reason were never added to any of the main setuptools/distutils documentation:features (deprecated):
long_description_content_type (Per Making a PyPI-friendly README):
provides_extras (Per PEP566, listed as "Provides-Extra"):