Looking through several projects recently, I noticed some of them use platforms
argument to setup()
in setup.py
, though with only one value of any
, i.e.
#setup.py file in project's package folder ... setup( ..., platforms=['any'], ... )
OR
#setup.py file in project's package folder ... setup( ..., platforms='any', ... )
From the name "platforms", I can make a guess about what this argument means, and it seems that the list variant is the right usage.
So I googled, looked through setuptools docs, but I failed to find any explanation to what are the possible values to platforms
and what it does/affects in package exactly.
Please, explain or provide a link to explanation of what it does exactly and what values it accepts?
P.S. Also tried to provide different values to it in my OS independent package and see what changes, when creating wheels, but it seems it does nothing.
setuptools allows you to install a package without copying any files to your interpreter directory (e.g. the site-packages directory). This allows you to modify your source code and have the changes take effect without you having to rebuild and reinstall.
Use of Setup.py It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on. Secondly, it serves as the command line interface via which packaging commands may be executed.
Python packages have a setup.py file that allows to easily install it while handling the dependencies. By default pip is trying to install from the Pypi: The Python Package Index (PyPI) is a repository of software for the Python programming language.
install_requires is a setuptools setup.py keyword that should be used to specify what a project minimally needs to run correctly. When the project is installed by pip, this is the specification that is used to install its dependencies.
platforms
is an argument the setuptools
package inherits from distutils
; see the Additional meta-data section in the distutils
documentation:
Meta-Data:
platforms
Description: a list of platforms
Value: list of strings
So, yes, using a list is the correct syntax.
The field just provides metadata; what platforms does the package target. Use this to communicate to tools or people about where you expect the package to be used.
There is no further specification for the contents of this list, it is unstructured and free-form. If you want to use something more structured, use the available Trove classifier strings in the classifiers
field, where tags under Operating System
, Environment
and others let you more strictly define a platform.
Wheels do not use this field other than to include it in the metadata, just like other fields like author
or license
.
Just an update to provide more information for anyone interested.
I found an accurate description of platforms
in a PEP.
So, "There's a PEP for that!":
PEP-0345 lists all possible arguments to setup()
in setup.py
, but it's a little old.
PEP-0426 and PEP-0459 are newer versions describing metadata for Python packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With