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

Having recently looked at several projects, I noticed that some of them use the platforms argument for setup() in setup.py , although with only one value of any , i.e.

 #setup.py file in project package folder ... setup( ..., platforms=['any'], ... ) 

OR

 #setup.py file in project package folder ... setup( ..., platforms='any', ... ) 

On behalf of the platform, I can guess what this argument means, and it seems that the list option is the correct use.

So, I googled, looked through setuptools docs , but I could not find an explanation of the possible values ​​of platforms and that it really / affects the package exactly.

Please explain or provide a link to explain what it does exactly and what values ​​does it take?

PS I also tried to provide various values ​​in my OS-independent package and see what changes were made when creating the wheels, but it seems that it does nothing.

+7
python setuptools pypi setup.py python-wheel
source share
2 answers

platforms is the argument that the setuptools package inherits from distutils ; see the optional metadata section in the distutils documentation:

Metadata: platforms
Description: list of platforms
Value: list of strings

So yes, using a list is the correct syntax.

The field provides only metadata; which platforms are targeted at the package. Use this to communicate with tools or people about where you expect the package to be used.

There is no additional information about the contents of this list; it is unstructured and free. If you want to use something more structured, use the available tag classifier lines in the classifiers field, where the tags under Operating System , Environment and others allow you to more strictly define the platform.

Wheels do not use this field, except to include it in the metadata, like other fields, such as author or license .

+3
source share

Just update to provide more information for anyone interested.

I found an exact description of platforms in PEP .

So, “There's a PEP for this!”:

PEP-0345 lists all possible setup() arguments in setup.py , but it's a bit old.

PEP-0426 and PEP-0459 are new versions that describe metadata for Python packages.

+3
source share

All Articles