Differences between revisions 40 and 41
Revision 40 as of 2016-09-25 12:42:21
Size: 7573
Editor: berkerpeksag
Comment:
Revision 41 as of 2019-06-22 19:01:22
Size: 799
Comment: remove obsolete information so people will be directed to official guide
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
A short introduction on how to install packages from the [[http://pypi.python.org/pypi|Python Package Index (PyPI)]], and how to make, distribute and upload your own. A short introduction on how to install packages from the [[https://pypi.org/pypi|Python Package Index (PyPI)]], and how to make, distribute and upload your own.
Line 3: Line 3:
'''This guide is no longer being maintained''' - more up to date and complete information is in the [[https://packaging.python.org/|Python Packaging User Guide]].

<<TableOfContents>>

= Installing Distributions =


There are several ways to install packages from PyPI into your Python installation:


=== Pip ===


Pip is a modern, general purpose installation tool for python packages.
Most often it is useful to install it in your system python.

Instructions for installing pip can be found on its relevant [[http://www.pip-installer.org/en/latest/installing.html|documentation page]].

Some example, hopefully self-evident commands:

  . $ pip install requests
  . $ pip search xml
  . $ pip show beautifulsoup4
  . $ pip uninstall requests


=== Python's distutils ===


[[http://docs.python.org/distutils/index.html|distutils]] comes with python and can be used for basic functionality.

Download the distribution, extract it, get to a command prompt and type:

  . $ python setup.py install

The distribution will be installed into 'site-packages' directory of the Python interpreter used to run the 'setup.py install' command.

Note that '''distutils doesn't install any dependencies'''! You will have to do so yourself. Pip will do this for you.

Quite often you may see the following line in install instructions:

 . $ sudo python setup.py install

Be very careful when running this command! Packages and scripts installed with 'sudo' will be placed in a operating system specific location, and this may break your operating system. Furthermore, the *distutils does not have an uninstall command*, so if you do break anything, it may be not that easy to restore it back to working condition!

There are two ways to avoid having to install as the root user:

 1. Per-user site-packages
  .
  If using Python 2.6 or greater, a [[http://docs.python.org/whatsnew/2.6.html#pep-370-per-user-site-packages-directory|per-user 'site-packages' directory]] is available. This may interfere with applications supplied by your operating system, but this interference is limited to only the user account which was used to install these packages with. Other user accounts (including the root user) should be left untouched.


 1. [[http://www.virtualenv.org/en/latest/|VirtualEnv]]
  .
  The [[http://pypi.python.org/pypi/virtualenv|VirtualEnv]] tool allows you to clone your system Python, so that you have a complete, isolated copy of Python available for installing into. Typically you will install the 'virtualenv' distribution as root, but it is possible to extract the virtualenv.py module from the 'virtualenv' distribution and also create virtual environments without having to use the root account at all.


=== Buildout ===


Buildout is a configuration-driven build tool designed for automating application installation. It has a number of recipes that allow you to declare the working set(s) of packages required for a Python application, and automatically install them.

Please see [[http://pypi.python.org/pypi/zc.buildout|Buildout]] for more information.


= What the Package Index Stores =


The Python Package Index stores [[http://docs.python.org/dist/meta-data.html|information about packages of Python software]] and releases themselves. Each package has a name and a number of release versions. The list of release versions will increase as newer versions of the package are submitted to the Package Index.


= Submitting Packages to the Package Index =


If you have some Python modules or packages that you would like to share with the Python community, we'd love to have them included in the Python Package Index! First, if you haven't done so, you will want to get your project organized. You might follow the guidelines at [[ProjectFileAndDirectoryLayout|ProjectFileAndDirectoryLayout]]. After that, you'll want to read the Python documentation regarding creating distributions: http://docs.python.org/distutils/index.html.

There is also an example project http://pypi.python.org/pypi/an_example_pypi_project

There are two types of information that may be submitted to the Package Index:

 1. package meta-data (name, version, description, etc), and

 1. package source and binary distribution files.


=== Package Meta-Data ===


You may submit package meta-data either by:

 1. writing a [[http://docs.python.org/dist/setup-script.html|setup.py file]] and using "python setup.py register" (see [[http://docs.python.org/dist/package-index.html|docs]]),

 1. creating a PKG-INFO file (typically generated from a setup.py file) and uploading it, or
 1. using the [[http://pypi.python.org/pypi?:action=submit_form|web form]] and manually entering the information.


The Package Index assumes that the PKG-INFO file is either ASCII or UTF-8.

If you choose to make use of the [[http://pythonhosted.org/setuptools/|setuptools]] installation system, there are more useful options you can include to aid in the installation of your software, like specifying other
packages that yours depends on before it will install.


=== Selecting Classifiers ===


View the complete [[http://pypi.python.org/pypi?:action=list_classifiers|list of classifiers]] you may choose from.

See the [[http://docs.python.org/dist/meta-data.html|meta-data docs]] for details about how to include them in your setup.py file.

PyPI will attempt to parse the "long_description" from your meta-data as [[reStructuredText|reStructuredText]]. If this fails, it will be presented to users as plain text (all whitespace and formatting retained).


=== Missing Classifier? ===


Is a classifier you need missing from the [[http://pypi.python.org/pypi?:action=list_classifiers|classifiers list]]?

Python frameworks with plugins or packages that target the framework can get their own category. The category should only be added ''after'' such packages exist.

Complementary packages can link to each other from their descriptions, they do not need a category to link them together; only when packages are provided by different people does a category need to be created.

To ask for a category email catalog-sig@python.org .


== Package Distribution Files ==


Note that submitting a package distribution file automatically submits the package's meta-data. You may submit package distribution files either by:

 1. appending the "upload" command to a setup.py [[http://docs.python.org/dist/source-dist.html|source dist]] or [[http://docs.python.org/dist/built-dist.html|built dist]] command, eg "python setup.py sdist upload", or

 1. logging into the Package Index and using the package management interface to manually upload files.

The "upload" command has a number of options, including being able to sign the upload using GPG. See "python setup.py upload --help" for more information.


== Exposing Multiple Releases ==


When a new release of a package is submitted to the Package Index, all previous releases of that package are ''hidden'' from the display. This means that listings and searches will no longer find those releases.

You may use the package admin interface to ''un-hide'' releases. This may be useful if you have both a ''stable'' and a ''development'' release active at the same time. These will be hidden again on the next submission of meta-data.
'''This guide is no longer being maintained''' - more up-to-date and complete information is in the [[https://packaging.python.org/|Python Packaging User Guide]]. To see what was previously in this page, please visit [[https://wiki.python.org/moin/CheeseShopTutorial?action=recall&rev=40|the previous edit]] in [[https://wiki.python.org/moin/CheeseShopTutorial?action=info|the wiki page history]]. Thank you to the writers who created this documentation! If you believe anything that was this page is missing from the current Python Packaging User Guide, please file [[https://github.com/pypa/packaging.python.org/issues/|an issue]]!

A short introduction on how to install packages from the Python Package Index (PyPI), and how to make, distribute and upload your own.

This guide is no longer being maintained - more up-to-date and complete information is in the Python Packaging User Guide. To see what was previously in this page, please visit the previous edit in the wiki page history. Thank you to the writers who created this documentation! If you believe anything that was this page is missing from the current Python Packaging User Guide, please file an issue!

CheeseShopTutorial (last edited 2019-06-22 19:01:22 by SumanaHarihareswara)

Unable to edit the page? See the FrontPage for instructions.