Reputation: 1878
One should provide to the setup function in the file setup.py both the version string and the development status (see https://python-packaging-user-guide.readthedocs.org/en/latest/tutorial.html and the project given as example https://github.com/pypa/sampleproject/blob/master/setup.py)
Here a simpler example:
from setuptools import setup
import os
here = os.path.abspath(os.path.dirname(__file__))
# Get the version from the relevant file
with open(os.path.join(here, 'namepackage/_version.py')) as f:
exec(f.read())
# In namepackage/_version.py, there is just something like
# __version__= '1.1a2', where 'a' means alpha (see
# http://legacy.python.org/dev/peps/pep-0386/).
setup(
name='namepackage',
version=__version__,
# skip arguments for clarity
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 4 - Beta'
]
)
In this case, the version string is written in the file namepackage/_version.py and it also contains the information on the development status, so there should be a way to get the development status as a string ('3 - Alpha' in this example) from the version string. Otherwise, one has to change in a consistent way both _version.py and setup.py, which does not seem very clever (and it's so easy to forget, which would lead to inconsistent informations, as in the example!).
Is there a function to do that in the Python standard library? Otherwise, what would be a clever way to do that?
Upvotes: 0
Views: 973
Reputation: 1122022
There is no real standard for how alpha or beta is designated in a version string, nor is the classifier required to correlate. I might mark a 0.x
release beta or even alpha status, for example, because I wanted to evolve the APIs still, and not move to production/stable until 1.x
.
So it depends on your own project release policies when to switch classifiers, and if that is correlated to the version string, to implement some string parsing yourself.
This can be as simple as:
devstatus = ''Development Status :: 5 - Production/Stable'
if 'b' in __version__:
devstatus = ''Development Status :: 4 - Beta'
elif 'a' in __version__:
devstatus = ''Development Status :: 3 - Alpha'
Upvotes: 1