Python 3.2: How to set up a version for a project

Ok, so I look around and I saw a couple of different options, although I'm new to python, so I'm a bit confused. Here is what I am looking for:

I have a project with several .py files. I have files and a lib directory for the libraries that I created. My question is: how do I configure a project for a version? I see a lot of articles that I put the version in setup.py. Where is setup.py going? what else is needed in this setup.py file? Am I just importing setup.py into my python files? How can I check if this works? How can I check the version of each .py file to make sure it is imported correctly?

+4
source share
2 answers

Read the hitchhiking guide on packaging to learn good practice for developing a Python project

The setup.py file is at the heart of the Python project. It describes all the metadata about your project. There are many fields that you can add to the project to give it a rich set of metadata describing the project. However, there are only three required fields: name, version, and packages. The name field must be unique if you want to publish your package in the Python Package Index (PyPI). In the version field, different versions of the project are tracked. The package field describes where you put the Python source code in your project.

Our initial setup.py file will also contain license information and will reuse the README.txt file for the long_description field. It will look like this:

from distutils.core import setup setup( name='TowelStuff', version='0.1dev', packages=['towelstuff',], license='Creative Commons Attribution-Noncommercial-Share Alike license', long_description=open('README.txt').read(), ) 
+4
source

Typically, a project will include this version as an __version__ attribute in its top-level namespace.

For instance:

 >>> import myproject >>> print myproject.__version__ '3.2.0' 

See http://www.python.org/dev/peps/pep-0396/ for more information and ways to access __version__ from your setup.py .

+1
source

All Articles