Difference between revisions of "Python setuptools"

From Exterior Memory
Jump to: navigation, search
(Created page with "The most common way to distribute Python modules is using [https://pypi.python.org/pypi '''PyPI''', the Python Package Index] (formerly known as the Cheese shop). The tool to...")
 
(Release Steps)
Line 17: Line 17:
 
# Make sure the repository is up-to date.
 
# Make sure the repository is up-to date.
 
# Ensure the version is incremented:
 
# Ensure the version is incremented:
#* ``setup.py``  must be updated
+
#* <code>setup.py</code> must be updated
#* ``doc/config.py``  must be updated
+
#* <code>libary/__init__.py</code> must be updated
#* ``CHANGES.txt``  must contain a summary of the changes
+
#* <code>doc/changes.rst</code> must contain a summary of the changes
 
# Make sure all changes are committed, including the version number changes.
 
# Make sure all changes are committed, including the version number changes.
# Tag the sources with ``hg tag -m 'Tag aafig-X.Y' mymodule-X.Y``.
+
# Tag the sources with <code>hg tag -m 'Tag mymodule-X.Y' mymodule-X.Y</code> or <code>git tag mymodule-X.Y</code>.
# Don't forget to ``hg push`` or git push
+
# Push the code and tag: <code>hg push</code> or <code>git push --tags origin</code>
# Temporarily modify the ``setup.cfg`` file to comment out the variables ``tag_build = dev`` and ``tag_date = true`` (do **not** commit this change).
+
# Temporarily modify <code>setup.cfg</code> file to comment out the variables <code>tag_build = dev</code> and <code>tag_date = true</code> (do '''not''' commit this change).
# Register and upload the new release ``python setup.py register sdist upload``.
+
# Register and upload the new release <codde>python setup.py register sdist upload</code>.
# Generate the documentation with ``make -C doc zip``.
+
# Generate the documentation with <code>cd doc; make</code>.
# Upload the new documentation (``doc/_build/sphinxcontrib-aafig-doc.zip``) to PyPi: http://pypi.python.org/pypi?%3Aaction=pkg_edit&name=mypackage
+
# Upload the new documentation ([http://pypi.python.org/pypi?%3Aaction=pkg_edit&name=mypackage to PyPi] or to github mypackage.wiki repository.

Revision as of 01:21, 26 August 2013

The most common way to distribute Python modules is using PyPI, the Python Package Index (formerly known as the Cheese shop).

The tool to download and install packages is pip. Predecessors like EasyInstall are no longer recommended, with only a few exceptions.

There are tool to build and upload packages is or setuptools. Make sure to use version 0.7 or later.

There are a few alternatives to setuptools: distutils is a tool in the standard library with limited functionality. The downside of both distutils and setuptools is that they use a script rather than a file format to store metadata, and force the developer an end-user to use the same tool to build and install the software. distutils2 (the module will be named `package`) is an attempt to move to a modern packaging system for Python, but has not been included as of Python 3.4.

Release Steps

This article is unfinished.

Credits: These steps are taken from the sphinxcontrib-aafig package.

In order to make a PyPi release, do the following steps:

  1. Make sure the repository is up-to date.
  2. Ensure the version is incremented:
    • setup.py must be updated
    • libary/__init__.py must be updated
    • doc/changes.rst must contain a summary of the changes
  3. Make sure all changes are committed, including the version number changes.
  4. Tag the sources with hg tag -m 'Tag mymodule-X.Y' mymodule-X.Y or git tag mymodule-X.Y.
  5. Push the code and tag: hg push or git push --tags origin
  6. Temporarily modify setup.cfg file to comment out the variables tag_build = dev and tag_date = true (do not commit this change).
  7. Register and upload the new release <codde>python setup.py register sdist upload</code>.
  8. Generate the documentation with cd doc; make.
  9. Upload the new documentation (to PyPi or to github mypackage.wiki repository.