Warning

This document hasn't been checked for compatibility with current versions of Plone. Use at your own risk.

Setting up .pypirc

by Tarek Ziade last modified Feb 12, 2013 04:54 PM
explains how to setup your .pypirc file to work with Plone.org and PyPI

Distutils allows you to register and upload your package to the Python Package Index (PyPI) if you use the conventional setup.py file.

A typical usage is to get in the package root in a shell and type :

$ python setup.py register sdist upload

This command will register the package to PyPI, using the arguments passed to the setup function in setup.py. These arguments are the meta-data of the package, like the name of the package, its version etc. (see the Distutils documentation for the meta-data list). After it's registered, a source distribution is created locally, using the sdist command, then uploaded to PyPI.

For Python versions older than 2.6 you also need collective.dist, as detailed later in this document

To make these commands work, a .pypirc file has to be added in your home, as described in the Distutils documentation.

The Plone.org Products section, based on PloneSoftwareCenter, is now compatible with this protocol, and you can register and upload your packages there using the same command, as long as you configure properly your .pypirc file :

[distutils]
index-servers =
pypi
plone.org

[pypi]
username:user
password:password

[plone.org]
repository:http://plone.org/products
username:ploneuser
password:password

With this configuration, you will be able to publish your work to PyPI and/or Plone.org. The -r option will let you point the server to use. If your want to push your package to Plone.org, the command is:

$ python setup.py register sdist upload -r plone.org

And for PyPI :

$ python setup.py register sdist upload -r pypi

These commands will create an entry for your package, create a .tar.gz and upload it to whichever repository you chose.  Only the register and upload commands are affected by the -r flag; you can use any other commands as normal regardless of which package index you're uploading to.

N.B.: If no repository is specified PyPI will be used, not Plone.org


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.