What does the `platforms` argument to `setup()` in `setup.py` do?

Nikita picture Nikita · Jan 25, 2016 · Viewed 7.2k times · Source

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.

Answer

Martijn Pieters picture Martijn Pieters · Jan 25, 2016

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.