Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python project versioning [closed]

Tags:

python

The problem:

I need to set versioning in my pythonproject.
Every time I make a release - I merge my production and development branches in my VCS.
I need to make the least amount of corrections in setting up version of the project and automate the process.

What I`ve done:

  • I`ve read PEP 396 about module versioning (it is not exactly what I need)
  • I figured out how to set up a version for the project with setup.py file in this documentation
  • I figured out how django works with its versions here

My next steps:

I need for my release:

  • release date
  • revision
  • version number

So I plan to make my release number format major.minor.changeset, because keeping the release date in the version makes it pretty long. I want to create version.py file:

MAJOR_VERSION = 1
MINOR_VERSION = 1
RELEASE_DATE = '28 .08.2013 '


def get_revision ():
    ...

def get_version ():
   ....

And import the version from there when I need it (but I'm affraid that someone can forget to set up proper date), and put the file CHANGE.TXT next to it which describes release changes.

The question:

I want to know how do you set versions in your python projects and how should I convert my idea to simplify my scheme.

like image 309
Mansur Fattakhov Avatar asked Aug 28 '13 11:08

Mansur Fattakhov


People also ask

How does Python versioning work?

Versioning is the process of adding unique identifiers to different versions of your package. The unique identifier you use may be name-based or number-based, but most Python packages use semantic versioning.

What is __ version __ in Python?

The special variable __version__ is a convention in Python for adding version numbers to your package. It was introduced in PEP 396.

Does Python follow SemVer?

While Python doesn't fully support SemVer, you can still create three-part versions in the same manner. Semantic Versioning works by structuring each version identifier into three parts, MAJOR, MINOR, and PATCH.


1 Answers

Two related issues: (1) what are good choices for metadata to track at the module level, including versioning, plus other useful information; and (2) what is a good way to represent that metadata.

A general approach for module metadata is explained at http://epydoc.sourceforge.net/manual-fields.html#module-metadata-variables. This basically says, use constants named __author__, __authors__, __contact__, __copyright__, __license__, __date__ and __version__. These are commonly used, so it's a good convention.

Then for how to populate the __version__ constant -- a good model for versioning anything is semantic versioning -- see http://semver.org/. Basically, use 1.2.3 style in which major changes only when there's an incompatible API change, minor changes when there's new functionality, and micro aka patch changes when there's a bug fix. This is also used commonly and therefore a good convention.

like image 118
Chris Johnson Avatar answered Oct 01 '22 23:10

Chris Johnson