Commit 3dde375d authored by Kenneth Reitz's avatar Kenneth Reitz

pip v1.5.4

parent 483e30a5
...@@ -27,7 +27,7 @@ PROFILE_PATH="$BUILD_DIR/.profile.d/python.sh" ...@@ -27,7 +27,7 @@ PROFILE_PATH="$BUILD_DIR/.profile.d/python.sh"
DEFAULT_PYTHON_VERSION="python-2.7.6" DEFAULT_PYTHON_VERSION="python-2.7.6"
PYTHON_EXE="/app/.heroku/python/bin/python" PYTHON_EXE="/app/.heroku/python/bin/python"
PIP_VERSION="1.5.2" PIP_VERSION="1.5.4"
SETUPTOOLS_VERSION="2.1" SETUPTOOLS_VERSION="2.1"
# Setup bpwatch # Setup bpwatch
...@@ -220,7 +220,6 @@ puts-step "Installing dependencies using Pip ($PIP_VERSION)" ...@@ -220,7 +220,6 @@ puts-step "Installing dependencies using Pip ($PIP_VERSION)"
[ ! "$FRESH_PYTHON" ] && bpwatch start pip_install [ ! "$FRESH_PYTHON" ] && bpwatch start pip_install
[ "$FRESH_PYTHON" ] && bpwatch start pip_install_first [ "$FRESH_PYTHON" ] && bpwatch start pip_install_first
/app/.heroku/python/bin/pip install -r requirements.txt --exists-action=w --src=./.heroku/src | cleanup | indent
/app/.heroku/python/bin/pip install -r requirements.txt --exists-action=w --src=./.heroku/src --allow-all-external | cleanup | indent /app/.heroku/python/bin/pip install -r requirements.txt --exists-action=w --src=./.heroku/src --allow-all-external | cleanup | indent
[ ! "$FRESH_PYTHON" ] && bpwatch stop pip_install [ ! "$FRESH_PYTHON" ] && bpwatch stop pip_install
......
.. _`Configuration`:
Configuration
=================
.. _config-file:
Config file
------------
pip allows you to set all command line option defaults in a standard ini
style config file.
The names and locations of the configuration files vary slightly across
platforms.
* On Unix and Mac OS X the configuration file is: :file:`$HOME/.pip/pip.conf`
* On Windows, the configuration file is: :file:`%HOME%\\pip\\pip.ini`
You can set a custom path location for the config file using the environment variable ``PIP_CONFIG_FILE``.
The names of the settings are derived from the long command line option, e.g.
if you want to use a different package index (``--index-url``) and set the
HTTP timeout (``--default-timeout``) to 60 seconds your config file would
look like this:
.. code-block:: ini
[global]
timeout = 60
index-url = http://download.zope.org/ppix
Each subcommand can be configured optionally in its own section so that every
global setting with the same name will be overridden; e.g. decreasing the
``timeout`` to ``10`` seconds when running the `freeze`
(`Freezing Requirements <./#freezing-requirements>`_) command and using
``60`` seconds for all other commands is possible with:
.. code-block:: ini
[global]
timeout = 60
[freeze]
timeout = 10
Boolean options like ``--ignore-installed`` or ``--no-dependencies`` can be
set like this:
.. code-block:: ini
[install]
ignore-installed = true
no-dependencies = yes
Appending options like ``--find-links`` can be written on multiple lines:
.. code-block:: ini
[global]
find-links =
http://download.example.com
[install]
find-links =
http://mirror1.example.com
http://mirror2.example.com
Environment Variables
---------------------
pip's command line options can be set with
environment variables using the format ``PIP_<UPPER_LONG_NAME>`` . Dashes (``-``) have to replaced with underscores (``_``).
For example, to set the default timeout::
export PIP_DEFAULT_TIMEOUT=60
This is the same as passing the option to pip directly::
pip --default-timeout=60 [...]
To set options that can be set multiple times on the command line, just add spaces in between values. For example::
export PIP_FIND_LINKS="http://mirror1.example.com http://mirror2.example.com"
is the same as calling::
pip install --find-links=http://mirror1.example.com --find-links=http://mirror2.example.com
Config Precedence
-----------------
Command line options have precedence over environment variables, which have precedence over the config file.
Within the config file, command specific sections have precedence over the global section.
Examples:
- ``--host=foo`` overrides ``PIP_HOST=foo``
- ``PIP_HOST=foo`` overrides a config file with ``[global] host = foo``
- A command specific section in the config file ``[<command>] host = bar``
overrides the option with same name in the ``[global]`` config file section
Command Completion
------------------
pip comes with support for command line completion in bash and zsh.
To setup for bash::
$ pip completion --bash >> ~/.profile
To setup for zsh::
$ pip completion --zsh >> ~/.zprofile
Alternatively, you can use the result of the ``completion`` command
directly with the eval function of you shell, e.g. by adding the following to your startup file::
eval "`pip completion --bash`"
===========
Other tools
===========
virtualenv
----------
pip is most nutritious when used with `virtualenv
<http://pypi.python.org/pypi/virtualenv>`__. One of the reasons pip
doesn't install "multi-version" eggs is that virtualenv removes much of the need
for it. Because pip is installed by virtualenv, just use
``path/to/my/environment/bin/pip`` to install things into that
specific environment.
To tell pip to only run if there is a virtualenv currently activated,
and to bail if not, use::
export PIP_REQUIRE_VIRTUALENV=true
easy_install
------------
pip was originally written to improve on `easy_install <http://pythonhosted.org/setuptools/easy_install.html>`_ in the following ways:
* All packages are downloaded before installation. Partially-completed
installation doesn't occur as a result.
* Care is taken to present useful output on the console.
* The reasons for actions are kept track of. For instance, if a package is
being installed, pip keeps track of why that package was required.
* Error messages should be useful.
* The code is relatively concise and cohesive, making it easier to use
programmatically.
* Packages don't have to be installed as egg archives, they can be installed
flat (while keeping the egg metadata).
* Native support for other version control systems (Git, Mercurial and Bazaar)
* Uninstallation of packages.
* Simple to define fixed sets of requirements and reliably reproduce a
set of packages.
pip doesn't do everything that easy_install does. Specifically:
* It cannot install from eggs. That’s not a problem anymore though because pip
supports the superior binary `wheel format
<https://wheel.readthedocs.org/en/latest/>`_ since the 1.4 release.
* It is incompatible with some packages that extensively customize distutils
or setuptools in their ``setup.py`` files.
buildout
--------
If you are using `zc.buildout
<http://pypi.python.org/pypi/zc.buildout>`_ you should look at
`gp.recipe.pip <http://pypi.python.org/pypi/gp.recipe.pip>`_ as an
option to use pip and virtualenv in your buildouts.
==========
Usage
==========
pip
---
Usage
*****
::
pip <command> [options]
Options
*******
.. _`General Options`:
**General Options:**
.. pip-general-options::
.. _`Package Index Options`:
**Package Index Options:**
.. pip-index-options::
.. _`pip install`:
pip install
-----------
Usage
********
.. pip-command-usage:: install
Description
***********
.. pip-command-description:: install
Options
*******
**Install Options:**
.. pip-command-options:: install
**Other Options:**
* :ref:`Package Index Options <Package Index Options>`
* :ref:`General Options <General Options>`
.. _`pip install Examples`:
Examples
********
1) Install `SomePackage` and it's dependencies from `PyPI`_ using :ref:`Requirement Specifiers`
::
$ pip install SomePackage # latest version
$ pip install SomePackage==1.0.4 # specific version
$ pip install 'SomePackage>=1.0.4' # minimum version
2) Install a list of requirements specified in a file. See the :ref:`Cookbook entry on Requirements files <Requirements Files>`.
::
$ pip install -r requirements.txt
3) Upgrade an already installed `SomePackage` to the latest from PyPI.
::
$ pip install --upgrade SomePackage
4) Install a local project in "editable" mode. See the section on :ref:`Editable Installs <editable-installs>`.
::
$ pip install -e . # project in current directory
$ pip install -e path/to/project # project in another directory
5) Install a project from VCS in "editable" mode. See the sections on :ref:`VCS Support <VCS Support>` and :ref:`Editable Installs <editable-installs>`.
::
$ pip install -e git+https://git.repo/some_pkg.git#egg=SomePackage # from git
$ pip install -e hg+https://hg.repo/some_pkg.git#egg=SomePackage # from mercurial
$ pip install -e svn+svn://svn.repo/some_pkg/trunk/#egg=SomePackage # from svn
$ pip install -e git+https://git.repo/some_pkg.git@feature#egg=SomePackage # from 'feature' branch
$ pip install -e git+https://git.repo/some_repo.git@egg=subdir&subdirectory=subdir_path # install a python package from a repo subdirectory
6) Install a package with `setuptools extras`_.
::
$ pip install SomePackage[PDF]
$ pip install SomePackage[PDF]==3.0
$ pip install -e .[PDF]==3.0 # editable project in current directory
7) Install a particular source archive file.
::
$ pip install ./downloads/SomePackage-1.0.4.tar.gz
$ pip install http://my.package.repo/SomePackage-1.0.4.zip
8) Install from alternative package repositories.
Install from a different index, and not `PyPI`_::
$ pip install --index-url http://my.package.repo/simple/ SomePackage
Search an additional index during install, in addition to `PyPI`_::
$ pip install --extra-index-url http://my.package.repo/simple SomePackage
Install from a local flat directory containing archives (and don't scan indexes)::
$ pip install --no-index --find-links=file:///local/dir/ SomePackage
$ pip install --no-index --find-links=/local/dir/ SomePackage
$ pip install --no-index --find-links=relative/dir/ SomePackage
9) Find pre-release and development versions, in addition to stable versions. By default, pip only finds stable versions.
::
$ pip install --pre SomePackage
.. _PyPI: http://pypi.python.org/pypi
.. _setuptools extras: http://packages.python.org/setuptools/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
pip uninstall
-------------
Usage
*****
.. pip-command-usage:: uninstall
Description
***********
.. pip-command-description:: uninstall
Options
*******
**Uninstall Options:**
.. pip-command-options:: uninstall
**Other Options:**
* :ref:`General Options <General Options>`
Examples
********
1) Uninstall a package.
::
$ pip uninstall simplejson
Uninstalling simplejson:
/home/me/env/lib/python2.7/site-packages/simplejson
/home/me/env/lib/python2.7/site-packages/simplejson-2.2.1-py2.7.egg-info
Proceed (y/n)? y
Successfully uninstalled simplejson
.. _`pip freeze`:
pip freeze
-----------
Usage
*****
.. pip-command-usage:: freeze
Description
***********
.. pip-command-description:: freeze
Options
*******
**Freeze Options:**
.. pip-command-options:: freeze
**Other Options:**
* :ref:`General Options <General Options>`
Examples
********
1) Generate output suitable for a requirements file.
::
$ pip freeze
Jinja2==2.6
Pygments==1.5
Sphinx==1.1.3
docutils==0.9.1
2) Generate a requirements file and then install from it in another environment.
::
$ env1/bin/pip freeze > requirements.txt
$ env2/bin/pip install -r requirements.txt
pip list
---------
Usage
*****
.. pip-command-usage:: list
Description
***********
.. pip-command-description:: list
Options
*******
**List Options:**
.. pip-command-options:: list
**Other Options:**
* :ref:`Package Index Options <Package Index Options>`
* :ref:`General Options <General Options>`
Examples
********
1) List installed packages.
::
$ pip list
Pygments (1.5)
docutils (0.9.1)
Sphinx (1.1.2)
Jinja2 (2.6)
2) List outdated packages (excluding editables), and the latest version available
::
$ pip list --outdated
docutils (Current: 0.9.1 Latest: 0.10)
Sphinx (Current: 1.1.2 Latest: 1.1.3)
pip show
--------
Usage
*****
.. pip-command-usage:: show
Description
***********
.. pip-command-description:: show
Options
*******
**Show Options:**
.. pip-command-options:: show
**Other Options:**
* :ref:`General Options <General Options>`
Examples
********
1. Show information about a package:
::
$ pip show sphinx
---
Name: Sphinx
Version: 1.1.3
Location: /my/env/lib/pythonx.x/site-packages
Requires: Pygments, Jinja2, docutils
pip search
----------
Usage
*****
.. pip-command-usage:: search
Description
***********
.. pip-command-description:: search
Options
*******
**Search Options:**
.. pip-command-options:: search
**Other Options:**
* :ref:`General Options <General Options>`
Examples
********
1. Search for "peppercorn"
::
$ pip search peppercorn
pepperedform - Helpers for using peppercorn with formprocess.
peppercorn - A library for converting a token stream into [...]
.. _`pip wheel`:
pip wheel
---------
Usage
*****
.. pip-command-usage:: wheel
Description
***********
.. pip-command-description:: wheel
.. warning::
Currently, when ``pip wheel`` finds a wheel for one of your requirements
already on PyPI, it does not rebuild, and it does not place the file in your
wheelhouse dir. There is an issue open to change this
(https://github.com/pypa/pip/issues/1310)
Options
*******
**Wheel Options:**
.. pip-command-options:: wheel
**Other Options:**
* :ref:`Package Index Options <Package Index Options>`
* :ref:`General Options <General Options>`
Examples
********
1. Build wheels for a requirement (and all its dependencies), and then install
::
$ pip wheel --wheel-dir=/tmp/wheelhouse SomePackage
$ pip install --no-index --find-links=/tmp/wheelhouse SomePackage
pip zip
-------
Usage
*****
.. pip-command-usage:: zip
Description
***********
.. pip-command-description:: zip
Options
*******
**Zip Options:**
.. pip-command-options:: zip
**Other Options:**
* :ref:`General Options <General Options>`
Changelog **1.5.4 (2014-02-21)**
=========
* Correct deprecation warning for ``pip install --build`` to only notify when
the `--build` value is different than the default.
**1.5.3 (2014-02-20)**
* **DEPRECATION** ``pip install --build`` and ``pip install --no-clean`` are now
deprecated. See Issue #906 for discussion.
* Fixed #1112. Couldn't download directly from wheel paths/urls, and when wheel
downloads did occur using requirement specifiers, dependencies weren't
downloaded (PR #1527)
* Fixed #1320. ``pip wheel`` was not downloading wheels that already existed (PR
#1524)
* Fixed #1111. ``pip install --download`` was failing using local
``--find-links`` (PR #1524)
* Workaround for Python bug http://bugs.python.org/issue20053 (PR #1544)
* Don't pass a unicode __file__ to setup.py on Python 2.x (PR #1583)
* Verify that the Wheel version is compatible with this pip (PR #1569)
**1.5.2 (2014-01-26)**
1.5.2 (2014-01-26)
------------------
* Upgraded the vendored ``pkg_resources`` and ``_markerlib`` to setuptools 2.1. * Upgraded the vendored ``pkg_resources`` and ``_markerlib`` to setuptools 2.1.
...@@ -13,8 +40,8 @@ Changelog ...@@ -13,8 +40,8 @@ Changelog
part of the URL in a requirements file part of the URL in a requirements file
1.5.1 (2014-01-20) **1.5.1 (2014-01-20)**
------------------
* pip now only requires setuptools (any setuptools, not a certain version) when * pip now only requires setuptools (any setuptools, not a certain version) when
installing distributions from src (i.e. not from wheel). (Pull #1434). installing distributions from src (i.e. not from wheel). (Pull #1434).
...@@ -32,9 +59,8 @@ Changelog ...@@ -32,9 +59,8 @@ Changelog
#1457) #1457)
**1.5 (2014-01-01)**
1.5 (2014-01-01)
----------------
* **BACKWARD INCOMPATIBLE** pip no longer supports the ``--use-mirrors``, * **BACKWARD INCOMPATIBLE** pip no longer supports the ``--use-mirrors``,
``-M``, and ``--mirrors`` flags. The mirroring support has been removed. In ``-M``, and ``--mirrors`` flags. The mirroring support has been removed. In
...@@ -110,11 +136,9 @@ Changelog ...@@ -110,11 +136,9 @@ Changelog
(Pull #1316) (Pull #1316)
**1.4.1 (2013-08-07)**
1.4.1 (2013-08-07)
------------------
* **New Signing Key** Release 1.4.1 is using a different key than normal with * **New Signing Key** Release 1.4.1 is using a different key than normal with
fingerprint: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA fingerprint: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
* Fixed issues with installing from pybundle files (Pull #1116). * Fixed issues with installing from pybundle files (Pull #1116).
...@@ -125,8 +149,8 @@ Changelog ...@@ -125,8 +149,8 @@ Changelog
* Fixes related to recognizing and cleaning global build dirs (Pull #1080). * Fixes related to recognizing and cleaning global build dirs (Pull #1080).
1.4 (2013-07-23) **1.4 (2013-07-23)**
----------------
* **BACKWARD INCOMPATIBLE** pip now only installs stable versions by default, * **BACKWARD INCOMPATIBLE** pip now only installs stable versions by default,
and offers a new ``--pre`` option to also find pre-release and development and offers a new ``--pre`` option to also find pre-release and development
...@@ -174,14 +198,16 @@ Changelog ...@@ -174,14 +198,16 @@ Changelog
* Fixed git VCS backend with git 1.8.3. (Pull #967) * Fixed git VCS backend with git 1.8.3. (Pull #967)
1.3.1 (2013-03-08)
------------------ **1.3.1 (2013-03-08)**
* Fixed a major backward incompatible change of parsing URLs to externally * Fixed a major backward incompatible change of parsing URLs to externally
hosted packages that got accidentily included in 1.3. hosted packages that got accidentily included in 1.3.
1.3 (2013-03-07)
---------------- **1.3 (2013-03-07)**
* SSL Cert Verification; Make https the default for PyPI access. * SSL Cert Verification; Make https the default for PyPI access.
Thanks James Cleveland, Giovanni Bajo, Marcus Smith and many others (Pull #791, CVE-2013-1629). Thanks James Cleveland, Giovanni Bajo, Marcus Smith and many others (Pull #791, CVE-2013-1629).
...@@ -237,15 +263,17 @@ Changelog ...@@ -237,15 +263,17 @@ Changelog
like the same option in distutils but also plays nice with pip's egg-info. like the same option in distutils but also plays nice with pip's egg-info.
Thanks Przemek Wrzos. (Issue #253 / Pull #693) Thanks Przemek Wrzos. (Issue #253 / Pull #693)
1.2.1 (2012-09-06)
------------------ **1.2.1 (2012-09-06)**
* Fixed a regression introduced in 1.2 about raising an exception when * Fixed a regression introduced in 1.2 about raising an exception when
not finding any files to uninstall in the current environment. Thanks for not finding any files to uninstall in the current environment. Thanks for
the fix, Marcus Smith. the fix, Marcus Smith.
1.2 (2012-09-01)
---------------- **1.2 (2012-09-01)**
* **Dropped support for Python 2.4** The minimum supported Python version is * **Dropped support for Python 2.4** The minimum supported Python version is
now Python 2.5. now Python 2.5.
...@@ -313,8 +341,9 @@ Changelog ...@@ -313,8 +341,9 @@ Changelog
* Added a better help formatter. * Added a better help formatter.
1.1 (2012-02-16)
---------------- **1.1 (2012-02-16)**
* Fixed issue #326 - don't crash when a package's setup.py emits UTF-8 and * Fixed issue #326 - don't crash when a package's setup.py emits UTF-8 and
then fails. Thanks Marc Abramowitz. then fails. Thanks Marc Abramowitz.
...@@ -373,8 +402,8 @@ Changelog ...@@ -373,8 +402,8 @@ Changelog
requirements from VCS that have a changed repo URL. requirements from VCS that have a changed repo URL.
1.0.2 (2011-07-16) **1.0.2 (2011-07-16)**
------------------
* Fixed docs issues. * Fixed docs issues.
* Fixed issue #295 - Reinstall a package when using the ``install -I`` option * Fixed issue #295 - Reinstall a package when using the ``install -I`` option
...@@ -383,8 +412,9 @@ Changelog ...@@ -383,8 +412,9 @@ Changelog
* Fixed issue #314 - Correctly handle exceptions on Python3. * Fixed issue #314 - Correctly handle exceptions on Python3.
* Fixed issue #320 - Correctly parse ``--editable`` lines in requirements files * Fixed issue #320 - Correctly parse ``--editable`` lines in requirements files
1.0.1 (2011-04-30)
------------------ **1.0.1 (2011-04-30)**
* Start to use git-flow. * Start to use git-flow.
* Fixed issue #274 - `find_command` should not raise AttributeError * Fixed issue #274 - `find_command` should not raise AttributeError
...@@ -394,8 +424,9 @@ Changelog ...@@ -394,8 +424,9 @@ Changelog
* Fixed issue #44 - multiple CLI searches. * Fixed issue #44 - multiple CLI searches.
* Fixed issue #266 - current working directory when running setup.py clean. * Fixed issue #266 - current working directory when running setup.py clean.
1.0 (2011-04-04)
---------------- **1.0 (2011-04-04)**
* Added Python 3 support! Huge thanks to Vinay Sajip, Vitaly Babiy, Kelsey * Added Python 3 support! Huge thanks to Vinay Sajip, Vitaly Babiy, Kelsey
Hightower, and Alex Gronholm, among others. Hightower, and Alex Gronholm, among others.
...@@ -422,8 +453,9 @@ Changelog ...@@ -422,8 +453,9 @@ Changelog
Make sure you have `distribute <http://pypi.python.org/pypi/distribute>`_ Make sure you have `distribute <http://pypi.python.org/pypi/distribute>`_
installed before using the installer! installed before using the installer!
0.8.3
----- **0.8.3**
* Moved main repository to Github: https://github.com/pypa/pip * Moved main repository to Github: https://github.com/pypa/pip
...@@ -445,8 +477,9 @@ Changelog ...@@ -445,8 +477,9 @@ Changelog
* Fixed bug in version string parsing related to the suffix "-dev". * Fixed bug in version string parsing related to the suffix "-dev".
0.8.2
----- **0.8.2**
* Avoid redundant unpacking of bundles (from pwaller) * Avoid redundant unpacking of bundles (from pwaller)
...@@ -462,8 +495,9 @@ Changelog ...@@ -462,8 +495,9 @@ Changelog
* Added ``git+https://`` scheme to Git VCS backend. * Added ``git+https://`` scheme to Git VCS backend.
0.8.1
----- **0.8.1**
* Added global --user flag as shortcut for --install-option="--user". From * Added global --user flag as shortcut for --install-option="--user". From
Ronny Pfannschmidt. Ronny Pfannschmidt.
...@@ -482,9 +516,8 @@ Changelog ...@@ -482,9 +516,8 @@ Changelog
Thanks Ronny Pfannschmidt and Wil Tan. Thanks Ronny Pfannschmidt and Wil Tan.
**0.8**
0.8
---
* Track which ``build/`` directories pip creates, never remove directories * Track which ``build/`` directories pip creates, never remove directories
it doesn't create. From Hugo Lopes Tavares. it doesn't create. From Hugo Lopes Tavares.
...@@ -510,14 +543,16 @@ Changelog ...@@ -510,14 +543,16 @@ Changelog
* Significant test framework changes, from Hugo Lopes Tavares. * Significant test framework changes, from Hugo Lopes Tavares.
0.7.2
----- **0.7.2**
* Set zip_safe=False to avoid problems some people are encountering where * Set zip_safe=False to avoid problems some people are encountering where
pip is installed as a zip file. pip is installed as a zip file.
0.7.1
----- **0.7.1**
* Fixed opening of logfile with no directory name. Thanks Alexandre Conrad. * Fixed opening of logfile with no directory name. Thanks Alexandre Conrad.
...@@ -526,8 +561,9 @@ Changelog ...@@ -526,8 +561,9 @@ Changelog
* Tests now require at least ScriptTest 1.0.3. * Tests now require at least ScriptTest 1.0.3.
0.7
--- **0.7**
* Fixed uninstallation on Windows * Fixed uninstallation on Windows
* Added ``pip search`` command. * Added ``pip search`` command.
...@@ -568,21 +604,24 @@ Changelog ...@@ -568,21 +604,24 @@ Changelog
--extra-index-url. --extra-index-url.
* Leftover build directories are now removed. Thanks Alexandre Conrad. * Leftover build directories are now removed. Thanks Alexandre Conrad.
0.6.3
----- **0.6.3**
* Fixed import error on Windows with regard to the backwards compatibility * Fixed import error on Windows with regard to the backwards compatibility
package package
0.6.2
----- **0.6.2**
* Fixed uninstall when /tmp is on a different filesystem. * Fixed uninstall when /tmp is on a different filesystem.
* Fixed uninstallation of distributions with namespace packages. * Fixed uninstallation of distributions with namespace packages.
0.6.1
----- **0.6.1**
* Added support for the ``https`` and ``http-static`` schemes to the * Added support for the ``https`` and ``http-static`` schemes to the
Mercurial and ``ftp`` scheme to the Bazaar backend. Mercurial and ``ftp`` scheme to the Bazaar backend.
...@@ -595,8 +634,9 @@ Changelog ...@@ -595,8 +634,9 @@ Changelog
* Fixed issue with ``pip bundle`` and local files (which weren't being * Fixed issue with ``pip bundle`` and local files (which weren't being
copied into the bundle), from Whit Morriss. copied into the bundle), from Whit Morriss.
0.6
--- **0.6**
* Add ``pip uninstall`` and uninstall-before upgrade (from Carl * Add ``pip uninstall`` and uninstall-before upgrade (from Carl
Meyer). Meyer).
...@@ -626,13 +666,15 @@ Changelog ...@@ -626,13 +666,15 @@ Changelog
* Creates download cache directory if not existing. * Creates download cache directory if not existing.
0.5.1
----- **0.5.1**
* Fixed a couple little bugs, with git and with extensions. * Fixed a couple little bugs, with git and with extensions.
0.5
--- **0.5**
* Added ability to override the default log file name (``pip-log.txt``) * Added ability to override the default log file name (``pip-log.txt``)
with the environmental variable ``$PIP_LOG_FILE``. with the environmental variable ``$PIP_LOG_FILE``.
...@@ -684,8 +726,9 @@ Changelog ...@@ -684,8 +726,9 @@ Changelog
* Fixed handling of attempt to checkout editable install to a * Fixed handling of attempt to checkout editable install to a
non-empty, non-repo directory. non-empty, non-repo directory.
0.4
--- **0.4**
* Make ``-e`` work better with local hg repositories * Make ``-e`` work better with local hg repositories
...@@ -713,8 +756,9 @@ Changelog ...@@ -713,8 +756,9 @@ Changelog
* Fixed support for Subversion 1.6. * Fixed support for Subversion 1.6.
0.3.1
----- **0.3.1**
* Improved virtualenv restart and various path/cleanup problems on win32. * Improved virtualenv restart and various path/cleanup problems on win32.
...@@ -726,8 +770,9 @@ Changelog ...@@ -726,8 +770,9 @@ Changelog
* Improve ``pip -h`` * Improve ``pip -h``
0.3
--- **0.3**
* Added support for editable packages created from Git, Mercurial and Bazaar * Added support for editable packages created from Git, Mercurial and Bazaar
repositories and ability to freeze them. Refactored support for version repositories and ability to freeze them. Refactored support for version
...@@ -763,8 +808,9 @@ Changelog ...@@ -763,8 +808,9 @@ Changelog
* Add ``--simulate`` option to ``pip zip``. * Add ``--simulate`` option to ``pip zip``.
0.2.1
----- **0.2.1**
* Fixed small problem that prevented using ``pip.py`` without actually * Fixed small problem that prevented using ``pip.py`` without actually
installing pip. installing pip.
...@@ -783,8 +829,9 @@ Changelog ...@@ -783,8 +829,9 @@ Changelog
* Turn some tar file errors into warnings. * Turn some tar file errors into warnings.
0.2
--- **0.2**
* Renamed to ``pip``, and to install you now do ``pip install * Renamed to ``pip``, and to install you now do ``pip install
PACKAGE`` PACKAGE``
...@@ -797,8 +844,9 @@ Changelog ...@@ -797,8 +844,9 @@ Changelog
creating a bundle using unnamed packages (like just an svn creating a bundle using unnamed packages (like just an svn
repository without ``#egg=Package``). repository without ``#egg=Package``).
0.1.4
----- **0.1.4**
* Added an option ``--install-option`` to pass options to pass * Added an option ``--install-option`` to pass options to pass
arguments to ``setup.py install`` arguments to ``setup.py install``
...@@ -824,16 +872,18 @@ Changelog ...@@ -824,16 +872,18 @@ Changelog
is still required, but just some downloads will be avoided when is still required, but just some downloads will be avoided when
using this. using this.
0.1.3
----- **0.1.3**
* Always use ``svn checkout`` (not ``export``) so that * Always use ``svn checkout`` (not ``export``) so that
``tag_svn_revision`` settings give the revision of the package. ``tag_svn_revision`` settings give the revision of the package.
* Don't update checkouts that came from ``.pybundle`` files. * Don't update checkouts that came from ``.pybundle`` files.
0.1.2
----- **0.1.2**
* Improve error text when there are errors fetching HTML pages when * Improve error text when there are errors fetching HTML pages when
seeking packages. seeking packages.
...@@ -846,8 +896,9 @@ Changelog ...@@ -846,8 +896,9 @@ Changelog
* Fix ``dependency_links`` for finding packages. * Fix ``dependency_links`` for finding packages.
0.1.1
----- **0.1.1**
* Fixed a NameError exception when running pip outside of a * Fixed a NameError exception when running pip outside of a
virtualenv environment. virtualenv environment.
...@@ -857,7 +908,8 @@ Changelog ...@@ -857,7 +908,8 @@ Changelog
* Fixed use of ``hashlib.md5`` on python2.5+ (also from Prabhu * Fixed use of ``hashlib.md5`` on python2.5+ (also from Prabhu
Ramachandran) Ramachandran)
0.1
--- **0.1**
* Initial release * Initial release
Metadata-Version: 1.1 Metadata-Version: 1.1
Name: pip Name: pip
Version: 1.5.2 Version: 1.5.4
Summary: A tool for installing and managing Python packages. Summary: A tool for installing and managing Python packages.
Home-page: http://www.pip-installer.org Home-page: http://www.pip-installer.org
Author: The pip developers Author: The pip developers
...@@ -16,16 +16,19 @@ Description: ...@@ -16,16 +16,19 @@ Description:
* Bug Tracking: https://github.com/pypa/pip/issues * Bug Tracking: https://github.com/pypa/pip/issues
* Mailing list: http://groups.google.com/group/python-virtualenv * Mailing list: http://groups.google.com/group/python-virtualenv
* Docs: http://www.pip-installer.org/ * Docs: http://www.pip-installer.org/
* IRC: #pip on Freenode. * User IRC: #pip on Freenode.
* Dev IRC: #pypa on Freenode.
Quickstart Quickstart
========== ==========
Install a package: First, :doc:`Install pip <installing>`.
Install a package from `PyPI`_:
:: ::
$ pip install SomePackage==1.0 $ pip install SomePackage
[...] [...]
Successfully installed SomePackage Successfully installed SomePackage
...@@ -71,6 +74,8 @@ Description: ...@@ -71,6 +74,8 @@ Description:
Successfully uninstalled SomePackage Successfully uninstalled SomePackage
.. _PyPI: http://pypi.python.org/pypi/
Keywords: easy_install distutils setuptools egg virtualenv Keywords: easy_install distutils setuptools egg virtualenv
Platform: UNKNOWN Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable Classifier: Development Status :: 5 - Production/Stable
......
...@@ -7,4 +7,5 @@ Project Info ...@@ -7,4 +7,5 @@ Project Info
* Bug Tracking: https://github.com/pypa/pip/issues * Bug Tracking: https://github.com/pypa/pip/issues
* Mailing list: http://groups.google.com/group/python-virtualenv * Mailing list: http://groups.google.com/group/python-virtualenv
* Docs: http://www.pip-installer.org/ * Docs: http://www.pip-installer.org/
* IRC: #pip on Freenode. * User IRC: #pip on Freenode.
* Dev IRC: #pypa on Freenode.
:orphan:
Configuration
=============
This content is now covered in the :doc:`User Guide <user_guide>`
:orphan:
============
Cookbook
============
This content is now covered in the :doc:`User Guide <user_guide>`
:orphan:
"ImportError: No module named setuptools"
+++++++++++++++++++++++++++++++++++++++++
Although using ``pip install --upgrade setuptools`` to upgrade from distribute
to setuptools works in isolation, it's possible to get "ImportError: No module
named setuptools" when using pip<1.4 to upgrade a package that depends on
setuptools or distribute.
e.g. when running a command like this: `pip install --upgrade pyramid`
Solution
~~~~~~~~
To prevent the problem in *new* environments (that aren't broken yet):
* Option 1:
* *First* run `pip install -U setuptools`,
* *Then* run the command to upgrade your package (e.g. `pip install --upgrade pyramid`)
* Option 2:
* Upgrade pip using :ref:`get-pip <get-pip>`
* *Then* run the command to upgrade your package (e.g. `pip install --upgrade pyramid`)
To fix the problem once it's occurred, you'll need to manually install the new
setuptools, then rerun the upgrade that failed.
1. Download `ez_setup.py` (https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py)
2. Run `python ez_setup.py`
3. Then rerun your upgrade (e.g. `pip install --upgrade pyramid`)
Cause
~~~~~
distribute-0.7.3 is just an empty wrapper that only serves to require the new
setuptools (setuptools>=0.7) so that it will be installed. (If you don't know
yet, the "new setuptools" is a merge of distribute and setuptools back into one
project).
distribute-0.7.3 does its job well, when the upgrade is done in isolation.
E.g. if you're currently on distribute-0.6.X, then running `pip install -U
setuptools` works fine to upgrade you to setuptools>=0.7.
The problem occurs when:
1. you are currently using an older distribute (i.e. 0.6.X)
2. and you try to use pip to upgrade a package that *depends* on setuptools or
distribute.
As part of the upgrade process, pip builds an install list that ends up
including distribute-0.7.3 and setuptools>=0.7 , but they can end up being
separated by other dependencies in the list, so what can happen is this:
1. pip uninstalls the existing distribute
2. pip installs distribute-0.7.3 (which has no importable setuptools, that pip
*needs* internally to function)
3. pip moves on to install another dependency (before setuptools>=0.7) and is
unable to proceed without the setuptools package
Note that pip v1.4 has fixes to prevent this. distribute-0.7.3 (or
setuptools>=0.7) by themselves cannot prevent this kind of problem.
.. _setuptools: https://pypi.python.org/pypi/setuptools
.. _distribute: https://pypi.python.org/pypi/distribute
pip pip
=== ===
A tool for installing and managing Python packages.
`User list <http://groups.google.com/group/python-virtualenv>`_ | `User list <http://groups.google.com/group/python-virtualenv>`_ |
`Dev list <http://groups.google.com/group/pypa-dev>`_ | `Dev list <http://groups.google.com/group/pypa-dev>`_ |
`Issues <https://github.com/pypa/pip/issues>`_ |
`Github <https://github.com/pypa/pip>`_ | `Github <https://github.com/pypa/pip>`_ |
`PyPI <https://pypi.python.org/pypi/pip/>`_ | `PyPI <https://pypi.python.org/pypi/pip/>`_ |
irc:#pip User IRC: #pip |
Dev IRC: #pypa
The `PyPA recommended
<https://python-packaging-user-guide.readthedocs.org/en/latest/current.html>`_
tool for installing and managing Python packages.
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
quickstart quickstart
installing installing
usage user_guide
cookbook reference/index
logic
configuration
other-tools
development development
news news
...@@ -27,11 +27,10 @@ Then run the following (which may require administrator access):: ...@@ -27,11 +27,10 @@ Then run the following (which may require administrator access)::
$ python get-pip.py $ python get-pip.py
.. note:: If `setuptools`_ (or `distribute`_) is not already installed, ``get-pip.py`` will
install `setuptools`_ for you. [2]_
Beginning with v1.5.1, pip does not require `setuptools`_ prior to running To upgrade an existing `setuptools`_ (or `distribute`_), run ``pip install -U setuptools`` [3]_
`get-pip.py`. Additionally, if `setuptools`_ (or `distribute`_) is not
already installed, `get-pip.py` will install `setuptools`_ for you.
Using Package Managers Using Package Managers
...@@ -54,7 +53,14 @@ On Fedora:: ...@@ -54,7 +53,14 @@ On Fedora::
tool like `curl` that verifies SSL certificates when downloading from tool like `curl` that verifies SSL certificates when downloading from
https URLs. https URLs.
.. _setuptools: https://pypi.python.org/pypi/setuptools .. [2] Beginning with pip v1.5.1, ``get-pip.py`` stopped requiring setuptools to
.. _distribute: https://pypi.python.org/pypi/distribute be installed first.
.. [3] Although using ``pip install --upgrade setuptools`` to upgrade from
distribute to setuptools works in isolation, it's possible to get
"ImportError: No module named setuptools" when using pip<1.4 to upgrade a
package that depends on setuptools or distribute. See :doc:`here for
details <distribute_setuptools>`.
.. _setuptools: https://pypi.python.org/pypi/setuptools
.. _distribute: https://pypi.python.org/pypi/distribute
:orphan:
================
Internal Details
================
This content is now covered in the :doc:`Reference Guide <reference/index>`
==== =============
News Release Notes
==== =============
.. include:: ../CHANGES.txt .. include:: ../CHANGES.txt
Quickstart Quickstart
========== ==========
Install a package: First, :doc:`Install pip <installing>`.
Install a package from `PyPI`_:
:: ::
$ pip install SomePackage==1.0 $ pip install SomePackage
[...] [...]
Successfully installed SomePackage Successfully installed SomePackage
...@@ -50,3 +52,5 @@ Uninstall a package: ...@@ -50,3 +52,5 @@ Uninstall a package:
Proceed (y/n)? y Proceed (y/n)? y
Successfully uninstalled SomePackage Successfully uninstalled SomePackage
.. _PyPI: http://pypi.python.org/pypi/
===============
Reference Guide
===============
.. toctree::
:maxdepth: 2
pip
pip_install
pip_uninstall
pip_freeze
pip_list
pip_show
pip_search
pip_wheel
pip
---
.. contents::
Usage
*****
::
pip <command> [options]
Description
***********
.. _`Logging`:
Logging
=======
Console logging
~~~~~~~~~~~~~~~
pip offers :ref:`-v, --verbose <--verbose>` and :ref:`-q, --quiet <--quiet>`
to control the console log level. Each option can be used multiple times and
used together. One ``-v`` increases the verbosity by one, whereas one ``-q`` decreases it by
one.
The series of log levels, in order, are as follows::
VERBOSE_DEBUG, DEBUG, INFO, NOTIFY, WARN, ERROR, FATAL
``NOTIFY`` is the default level.
A few examples on how the parameters work to affect the level:
* specifying nothing results in ``NOTIFY``
* ``-v`` results in ``INFO``
* ``-vv`` results in ``DEBUG``
* ``-q`` results in ``WARN``
* ``-vq`` results in ``NOTIFY``
The most practical use case for users is either ``-v`` or ``-vv`` to see
additional logging to help troubleshoot an issue.
.. _`FileLogging`:
File logging
~~~~~~~~~~~~
pip offers the :ref:`--log <--log>` option for specifying a file where a maximum
verbosity log will be kept. This option is empty by default. This log appends
to previous logging.
Additionally, when commands fail (i.e. return a non-zero exit code), pip writes
a "failure log" for the failed command. This log overwrites previous
logging. The default location is as follows:
* On Unix and Mac OS X: :file:`$HOME/.pip/pip.log`
* On Windows, the configuration file is: :file:`%HOME%\\pip\\pip.log`
The option for the failure log, is :ref:`--log-file <--log-file>`.
Both logs add a line per execution to specify the date and what pip executable wrote the log.
Like all pip options, ``--log`` and ``log-file``, can also be set as an environment
variable, or placed into the pip config file. See the :ref:`Configuration`
section.
.. _`General Options`:
General Options
***************
.. pip-general-options::
.. _`pip freeze`:
pip freeze
-----------
.. contents::
Usage
*****
.. pip-command-usage:: freeze
Description
***********
.. pip-command-description:: freeze
Options
*******
.. pip-command-options:: freeze
Examples
********
1) Generate output suitable for a requirements file.
::
$ pip freeze
Jinja2==2.6
Pygments==1.5
Sphinx==1.1.3
docutils==0.9.1
2) Generate a requirements file and then install from it in another environment.
::
$ env1/bin/pip freeze > requirements.txt
$ env2/bin/pip install -r requirements.txt
.. _`pip logic`:
================ .. _`pip install`:
Internal Details
================ pip install
-----------
.. contents::
Usage
*****
.. pip-command-usage:: install
Description
***********
.. pip-command-description:: install
.. _`Requirements File Format`: .. _`Requirements File Format`:
Requirements File Format Requirements File Format
======================== ++++++++++++++++++++++++
Each line of the requirements file indicates something to be installed, Each line of the requirements file indicates something to be installed,
and like arguments to :ref:`pip install`, the following forms are supported:: and like arguments to :ref:`pip install`, the following forms are supported::
...@@ -21,7 +34,7 @@ See the :ref:`pip install Examples<pip install Examples>` for examples of all th ...@@ -21,7 +34,7 @@ See the :ref:`pip install Examples<pip install Examples>` for examples of all th
A line beginning with ``#`` is treated as a comment and ignored. A line beginning with ``#`` is treated as a comment and ignored.
Additionally, the following :ref:`Package Index Options <Package Index Options>` are supported Additionally, the following Package Index Options are supported:
* :ref:`-i, --index-url <--index-url>` * :ref:`-i, --index-url <--index-url>`
* :ref:`--extra-index-url <--extra-index-url>` * :ref:`--extra-index-url <--extra-index-url>`
...@@ -47,7 +60,7 @@ Lastly, if you wish, you can refer to other requirements files, like this:: ...@@ -47,7 +60,7 @@ Lastly, if you wish, you can refer to other requirements files, like this::
.. _`Requirement Specifiers`: .. _`Requirement Specifiers`:
Requirement Specifiers Requirement Specifiers
====================== ++++++++++++++++++++++
pip supports installing from "requirement specifiers" as implemented in pip supports installing from "requirement specifiers" as implemented in
`pkg_resources Requirements <http://packages.python.org/setuptools/pkg_resources.html#requirement-objects>`_ `pkg_resources Requirements <http://packages.python.org/setuptools/pkg_resources.html#requirement-objects>`_
...@@ -63,80 +76,27 @@ Some Examples: ...@@ -63,80 +76,27 @@ Some Examples:
.. note:: .. note::
Use single or double quotes around specifiers to avoid ``>`` and ``<`` being interpreted as shell redirects. e.g. ``pip install 'FooProject>=1.2'``. Use single or double quotes around specifiers to avoid ``>`` and ``<`` being
interpreted as shell redirects. e.g. ``pip install 'FooProject>=1.2'``.
.. _`Logging`:
Logging
=======
Console logging
~~~~~~~~~~~~~~~
pip offers :ref:`-v, --verbose <--verbose>` and :ref:`-q, --quiet <--quiet>`
to control the console log level. Each option can be used multiple times and
used together. One ``-v`` increases the verbosity by one, whereas one ``-q`` decreases it by
one.
The series of log levels, in order, are as follows::
VERBOSE_DEBUG, DEBUG, INFO, NOTIFY, WARN, ERROR, FATAL
``NOTIFY`` is the default level.
A few examples on how the parameters work to affect the level:
* specifying nothing results in ``NOTIFY``
* ``-v`` results in ``INFO``
* ``-vv`` results in ``DEBUG``
* ``-q`` results in ``WARN``
* ``-vq`` results in ``NOTIFY``
The most practical use case for users is either ``-v`` or ``-vv`` to see
additional logging to help troubleshoot an issue.
.. _`FileLogging`:
File logging
~~~~~~~~~~~~
pip offers the :ref:`--log <--log>` option for specifying a file where a maximum
verbosity log will be kept. This option is empty by default. This log appends
to previous logging.
Additionally, when commands fail (i.e. return a non-zero exit code), pip writes
a "failure log" for the failed command. This log overwrites previous
logging. The default location is as follows:
* On Unix and Mac OS X: :file:`$HOME/.pip/pip.log`
* On Windows, the configuration file is: :file:`%HOME%\\pip\\pip.log`
The option for the failure log, is :ref:`--log-file <--log-file>`.
Both logs add a line per execution to specify the date and what pip executable wrote the log.
Like all pip options, ``--log`` and ``log-file``, can also be set as an environment
variable, or placed into the pip config file. See the :ref:`Configuration`
section.
.. _`Pre Release Versions`: .. _`Pre Release Versions`:
Pre-release Versions Pre-release Versions
==================== ++++++++++++++++++++
Starting with v1.4, pip will only install stable versions as specified by `PEP426`_ by default. If Starting with v1.4, pip will only install stable versions as specified by
a version cannot be parsed as a compliant `PEP426`_ version then it is assumed `PEP426`_ by default. If a version cannot be parsed as a compliant `PEP426`_
to be a pre-release. version then it is assumed to be a pre-release.
If a Requirement specifier includes a pre-release or development version (e.g. ``>=0.0.dev0``) then If a Requirement specifier includes a pre-release or development version
pip will allow pre-release and development versions for that requirement. This does not include (e.g. ``>=0.0.dev0``) then pip will allow pre-release and development versions
the != flag. for that requirement. This does not include the != flag.
The ``pip install`` command also supports a :ref:`--pre <install_--pre>` flag that will enable The ``pip install`` command also supports a :ref:`--pre <install_--pre>` flag
installing pre-releases and development releases. that will enable installing pre-releases and development releases.
.. _PEP426: http://www.python.org/dev/peps/pep-0426 .. _PEP426: http://www.python.org/dev/peps/pep-0426
...@@ -144,7 +104,7 @@ installing pre-releases and development releases. ...@@ -144,7 +104,7 @@ installing pre-releases and development releases.
.. _`Externally Hosted Files`: .. _`Externally Hosted Files`:
Externally Hosted Files Externally Hosted Files
======================= +++++++++++++++++++++++
Starting with v1.4, pip will warn about installing any file that does not come Starting with v1.4, pip will warn about installing any file that does not come
from the primary index. As of version 1.5, pip defaults to ignoring these files from the primary index. As of version 1.5, pip defaults to ignoring these files
...@@ -176,19 +136,25 @@ file would be like so:: ...@@ -176,19 +136,25 @@ file would be like so::
.. _`VCS Support`: .. _`VCS Support`:
VCS Support VCS Support
=========== +++++++++++
pip supports installing from Git, Mercurial, Subversion and Bazaar, and detects the type of VCS using url prefixes: "git+", "hg+", "bzr+", "svn+". pip supports installing from Git, Mercurial, Subversion and Bazaar, and detects
the type of VCS using url prefixes: "git+", "hg+", "bzr+", "svn+".
pip requires a working VCS command on your path: git, hg, svn, or bzr. pip requires a working VCS command on your path: git, hg, svn, or bzr.
VCS projects can be installed in :ref:`editable mode <editable-installs>` (using the :ref:`--editable <install_--editable>` option) or not. VCS projects can be installed in :ref:`editable mode <editable-installs>` (using
the :ref:`--editable <install_--editable>` option) or not.
* For editable installs, the clone location by default is "<venv path>/src/SomeProject" in virtual environments, and "<cwd>/src/SomeProject" for global installs. * For editable installs, the clone location by default is "<venv
The :ref:`--src <install_--src>` option can be used to modify this location. path>/src/SomeProject" in virtual environments, and "<cwd>/src/SomeProject"
* For non-editable installs, the project is built locally in a temp dir and then installed normally. for global installs. The :ref:`--src <install_--src>` option can be used to
modify this location.
* For non-editable installs, the project is built locally in a temp dir and then
installed normally.
The url suffix "egg=<project name>" is used by pip in it's dependency logic to identify the project prior to pip downloading and analyzing the metadata. The url suffix "egg=<project name>" is used by pip in it's dependency logic to
identify the project prior to pip downloading and analyzing the metadata.
Git Git
~~~ ~~~
...@@ -263,14 +229,14 @@ Tags or revisions can be installed like so:: ...@@ -263,14 +229,14 @@ Tags or revisions can be installed like so::
Finding Packages Finding Packages
================ ++++++++++++++++
pip searches for packages on `PyPI <http://pypi.python.org>`_ using the pip searches for packages on `PyPI`_ using the
`http simple interface <http://pypi.python.org/simple>`_, `http simple interface <http://pypi.python.org/simple>`_,
which is documented `here <http://packages.python.org/setuptools/easy_install.html#package-index-api>`_ which is documented `here <http://packages.python.org/setuptools/easy_install.html#package-index-api>`_
and `there <http://www.python.org/dev/peps/pep-0301/>`_ and `there <http://www.python.org/dev/peps/pep-0301/>`_
pip offers a set of :ref:`Package Index Options <Package Index Options>` for modifying how packages are found. pip offers a number of Package Index Options for modifying how packages are found.
See the :ref:`pip install Examples<pip install Examples>`. See the :ref:`pip install Examples<pip install Examples>`.
...@@ -278,14 +244,14 @@ See the :ref:`pip install Examples<pip install Examples>`. ...@@ -278,14 +244,14 @@ See the :ref:`pip install Examples<pip install Examples>`.
.. _`SSL Certificate Verification`: .. _`SSL Certificate Verification`:
SSL Certificate Verification SSL Certificate Verification
============================ ++++++++++++++++++++++++++++
Starting with v1.3, pip provides SSL certificate verification over https, for the purpose Starting with v1.3, pip provides SSL certificate verification over https, for the purpose
of providing secure, certified downloads from PyPI. of providing secure, certified downloads from PyPI.
Hash Verification Hash Verification
================= +++++++++++++++++
PyPI provides md5 hashes in the hash fragment of package download urls. PyPI provides md5 hashes in the hash fragment of package download urls.
...@@ -300,46 +266,174 @@ see :ref:`SSL Certificate Verification` ...@@ -300,46 +266,174 @@ see :ref:`SSL Certificate Verification`
Download Cache Download Cache
============== ++++++++++++++
pip offers a :ref:`--download-cache <install_--download-cache>` option for installs to prevent redundant downloads of archives from PyPI. pip offers a :ref:`--download-cache <install_--download-cache>` option for
installs to prevent redundant downloads of archives from PyPI.
The point of this cache is *not* to circumvent the index crawling process, but to *just* prevent redundant downloads. The point of this cache is *not* to circumvent the index crawling process, but
to *just* prevent redundant downloads.
Items are stored in this cache based on the url the archive was found at, not simply the archive name. Items are stored in this cache based on the url the archive was found at, not
simply the archive name.
If you want a fast/local install solution that circumvents crawling PyPI, see the :ref:`Fast & Local Installs` Cookbook entry. If you want a fast/local install solution that circumvents crawling PyPI, see
the :ref:`Fast & Local Installs`.
Like all options, :ref:`--download-cache <install_--download-cache>`, can also be set as an environment variable, or placed into the pip config file. Like all options, :ref:`--download-cache <install_--download-cache>`, can also
See the :ref:`Configuration` section. be set as an environment variable, or placed into the pip config file. See the
:ref:`Configuration` section.
.. _`editable-installs`: .. _`editable-installs`:
"Editable" Installs "Editable" Installs
=================== +++++++++++++++++++
"Editable" installs are fundamentally `"setuptools develop mode" <http://packages.python.org/setuptools/setuptools.html#development-mode>`_ installs. "Editable" installs are fundamentally `"setuptools develop mode"
<http://packages.python.org/setuptools/setuptools.html#development-mode>`_
installs.
You can install local projects or VCS projects in "editable" mode:: You can install local projects or VCS projects in "editable" mode::
$ pip install -e path/to/SomeProject $ pip install -e path/to/SomeProject
$ pip install -e git+http://repo/my_project.git#egg=SomeProject $ pip install -e git+http://repo/my_project.git#egg=SomeProject
For local projects, the "SomeProject.egg-info" directory is created relative to the project path. For local projects, the "SomeProject.egg-info" directory is created relative to
This is one advantage over just using ``setup.py develop``, which creates the "egg-info" directly relative the current working directory. the project path. This is one advantage over just using ``setup.py develop``,
which creates the "egg-info" directly relative the current working directory.
Controlling setup_requires
++++++++++++++++++++++++++
Setuptools offers the ``setup_requires`` `setup() keyword
<http://pythonhosted.org/setuptools/setuptools.html#new-and-changed-setup-keywords>`_
for specifying dependencies that need to be present in order for the `setup.py`
script to run. Internally, Setuptools uses ``easy_install`` to fulfill these
dependencies.
pip has no way to control how these dependencies are located. None of the
Package Index Options have an effect.
The solution is to configure a "system" or "personal" `Distutils configuration
file
<http://docs.python.org/2/install/index.html#distutils-configuration-files>`_ to
manage the fulfillment.
For example, to have the dependency located at an alternate index, add this:
::
[easy_install]
index_url = https://my.index-mirror.com
To have the dependency located from a local directory and not crawl PyPI, add this:
::
[easy_install]
allow_hosts = ''
find_links = file:///path/to/local/archives
Options
*******
.. pip-command-options:: install
.. pip-index-options::
.. _`pip install Examples`:
setuptools & pkg_resources Examples
========================== ********
Internally, pip uses the `setuptools` package, and the `pkg_resources` module, which are available from the project, `Setuptools`_. 1) Install `SomePackage` and it's dependencies from `PyPI`_ using :ref:`Requirement Specifiers`
::
$ pip install SomePackage # latest version
$ pip install SomePackage==1.0.4 # specific version
$ pip install 'SomePackage>=1.0.4' # minimum version
2) Install a list of requirements specified in a file. See the :ref:`Requirements files <Requirements Files>`.
::
$ pip install -r requirements.txt
3) Upgrade an already installed `SomePackage` to the latest from PyPI.
::
$ pip install --upgrade SomePackage
4) Install a local project in "editable" mode. See the section on :ref:`Editable Installs <editable-installs>`.
::
$ pip install -e . # project in current directory
$ pip install -e path/to/project # project in another directory
5) Install a project from VCS in "editable" mode. See the sections on :ref:`VCS Support <VCS Support>` and :ref:`Editable Installs <editable-installs>`.
::
$ pip install -e git+https://git.repo/some_pkg.git#egg=SomePackage # from git
$ pip install -e hg+https://hg.repo/some_pkg.git#egg=SomePackage # from mercurial
$ pip install -e svn+svn://svn.repo/some_pkg/trunk/#egg=SomePackage # from svn
$ pip install -e git+https://git.repo/some_pkg.git@feature#egg=SomePackage # from 'feature' branch
$ pip install -e git+https://git.repo/some_repo.git@egg=subdir&subdirectory=subdir_path # install a python package from a repo subdirectory
6) Install a package with `setuptools extras`_.
::
$ pip install SomePackage[PDF]
$ pip install SomePackage[PDF]==3.0
$ pip install -e .[PDF]==3.0 # editable project in current directory
7) Install a particular source archive file.
::
$ pip install ./downloads/SomePackage-1.0.4.tar.gz
$ pip install http://my.package.repo/SomePackage-1.0.4.zip
8) Install from alternative package repositories.
Install from a different index, and not `PyPI`_ ::
$ pip install --index-url http://my.package.repo/simple/ SomePackage
Search an additional index during install, in addition to `PyPI`_ ::
$ pip install --extra-index-url http://my.package.repo/simple SomePackage
Install from a local flat directory containing archives (and don't scan indexes)::
$ pip install --no-index --find-links=file:///local/dir/ SomePackage
$ pip install --no-index --find-links=/local/dir/ SomePackage
$ pip install --no-index --find-links=relative/dir/ SomePackage
9) Find pre-release and development versions, in addition to stable versions. By default, pip only finds stable versions.
::
Here are some examples of how pip uses `setuptools` and `pkg_resources`: $ pip install --pre SomePackage
* The core of pip's install process uses the `setuptools`'s "install" command.
* Editable ("-e") installs use the `setuptools`'s "develop" command.
* pip uses `pkg_resources` for version parsing, for detecting version conflicts, and to determine what projects are installed,
.. _Setuptools: http://pypi.python.org/pypi/setuptools/ .. _PyPI: http://pypi.python.org/pypi/
.. _setuptools extras: http://packages.python.org/setuptools/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
.. _`pip list`:
pip list
---------
.. contents::
Usage
*****
.. pip-command-usage:: list
Description
***********
.. pip-command-description:: list
Options
*******
.. pip-command-options:: list
.. pip-index-options::
Examples
********
1) List installed packages.
::
$ pip list
Pygments (1.5)
docutils (0.9.1)
Sphinx (1.1.2)
Jinja2 (2.6)
2) List outdated packages (excluding editables), and the latest version available
::
$ pip list --outdated
docutils (Current: 0.9.1 Latest: 0.10)
Sphinx (Current: 1.1.2 Latest: 1.1.3)
.. _`pip search`:
pip search
----------
.. contents::
Usage
*****
.. pip-command-usage:: search
Description
***********
.. pip-command-description:: search
Options
*******
.. pip-command-options:: search
Examples
********
1. Search for "peppercorn"
::
$ pip search peppercorn
pepperedform - Helpers for using peppercorn with formprocess.
peppercorn - A library for converting a token stream into [...]
.. _`pip wheel`:
.. _`pip show`:
pip show
--------
.. contents::
Usage
*****
.. pip-command-usage:: show
Description
***********
.. pip-command-description:: show
Options
*******
.. pip-command-options:: show
Examples
********
1. Show information about a package:
::
$ pip show sphinx
---
Name: Sphinx
Version: 1.1.3
Location: /my/env/lib/pythonx.x/site-packages
Requires: Pygments, Jinja2, docutils
.. _`pip uninstall`:
pip uninstall
-------------
.. contents::
Usage
*****
.. pip-command-usage:: uninstall
Description
***********
.. pip-command-description:: uninstall
Options
*******
.. pip-command-options:: uninstall
Examples
********
1) Uninstall a package.
::
$ pip uninstall simplejson
Uninstalling simplejson:
/home/me/env/lib/python2.7/site-packages/simplejson
/home/me/env/lib/python2.7/site-packages/simplejson-2.2.1-py2.7.egg-info
Proceed (y/n)? y
Successfully uninstalled simplejson
.. _`pip wheel`:
pip wheel
---------
.. contents::
Usage
*****
.. pip-command-usage:: wheel
Description
***********
.. pip-command-description:: wheel
Options
*******
.. pip-command-options:: wheel
.. pip-index-options::
Examples
********
1. Build wheels for a requirement (and all its dependencies), and then install
::
$ pip wheel --wheel-dir=/tmp/wheelhouse SomePackage
$ pip install --no-index --find-links=/tmp/wheelhouse SomePackage
:orphan:
==========
Usage
==========
The "Usage" section is now covered in the :doc:`Reference Guide <reference/index>`
============ ==========
Cookbook User Guide
============ ==========
.. contents::
Installing Packages
*******************
pip supports installing from `PyPI`_, version control, local projects, and
directly from distribution files.
The most common scenario is to install from `PyPI`_ using :ref:`Requirement
Specifiers`
::
$ pip install SomePackage # latest version
$ pip install SomePackage==1.0.4 # specific version
$ pip install 'SomePackage>=1.0.4' # minimum version
For more information and examples, see the :ref:`pip install` reference.
.. _`Requirements Files`: .. _`Requirements Files`:
...@@ -8,7 +30,7 @@ Requirements Files ...@@ -8,7 +30,7 @@ Requirements Files
****************** ******************
"Requirements files" are files containing a list of items to be "Requirements files" are files containing a list of items to be
installed using :ref:`pip install -r <install_--requirement>` like so: installed using :ref:`pip install` like so:
:: ::
...@@ -17,23 +39,22 @@ installed using :ref:`pip install -r <install_--requirement>` like so: ...@@ -17,23 +39,22 @@ installed using :ref:`pip install -r <install_--requirement>` like so:
Details on the format of the files are here: :ref:`Requirements File Format`. Details on the format of the files are here: :ref:`Requirements File Format`.
Logically, a Requirements file is just a list of :ref:`pip install` arguments
placed in a file.
There are 3 common use cases for requirements files: In practice, there are 4 common uses of Requirements files:
1. When installing many things, it's easier to use a requirements file,
than specifying them all on the command line.
2. Requirements files are often used to hold the result from :ref:`pip freeze` 1. Requirements files are used to hold the result from :ref:`pip freeze` for the
for the purpose of achieving :ref:`repeatable installations <Repeatability>`. purpose of achieving :ref:`repeatable installations <Repeatability>`. In
In this case, your requirement file contains a pinned version of everything this case, your requirement file contains a pinned version of everything that
that was installed when `pip freeze` was run. was installed when `pip freeze` was run.
:: ::
pip freeze > requirements.txt pip freeze > requirements.txt
pip install -r requirements.txt pip install -r requirements.txt
3. Requirements files can be used to force pip to properly resolve dependencies. 2. Requirements files are used to force pip to properly resolve dependencies.
As it is now, pip `doesn't have true dependency resolution As it is now, pip `doesn't have true dependency resolution
<https://github.com/pypa/pip/issues/988>`_, but instead simply uses the first <https://github.com/pypa/pip/issues/988>`_, but instead simply uses the first
specification it finds for a project. E.g if `pkg1` requires `pkg3>=1.0` and specification it finds for a project. E.g if `pkg1` requires `pkg3>=1.0` and
...@@ -51,40 +72,49 @@ There are 3 common use cases for requirements files: ...@@ -51,40 +72,49 @@ There are 3 common use cases for requirements files:
pkg3>=1.0,<=2.0 pkg3>=1.0,<=2.0
It's important to be clear that pip determines package dependencies using `install_requires metadata 3. Requirements files are used to force pip to install an alternate version of a
<http://pythonhosted.org/setuptools/setuptools.html#declaring-dependencies>`_, not by discovering `requirements.txt` sub-dependency. For example, suppose `ProjectA` in your requirements file
files embedded in projects. requires `ProjectB`, but the latest version (v1.3) has a bug, you can force
pip to accept earlier versions like so:
For a good discussion on the conceptual differences between setup.py and ::
requirements, see `"setup.py vs requirements.txt" (an article by Donald Stufft)
<https://caremad.io/blog/setup-vs-requirement/>`_
See also: ProjectA
ProjectB<1.3
* :ref:`Requirements File Format` 4. Requirements files are used to override a dependency with a local patch that
* :ref:`pip freeze` lives in version control. For example, suppose a dependency,
`SomeDependency` from PyPI has a bug, and you can't wait for an upstream fix.
You could clone/copy the src, make the fix, and place it in vcs with the tag
`sometag`. You'd reference it in your requirements file with a line like so:
::
.. _`Fast & Local Installs`: git+https://myvcs.com/some_dependency@sometag#egg=SomeDependency
Fast & Local Installs If `SomeDependency` was previously a top-level requirement in your
********************* requirements file, then **replace** that line with the new line. If
`SomeDependency` is a sub-dependency, then **add** the new line.
Often, you will want a fast install from local archives, without probing PyPI.
First, :ref:`download the archives <Downloading Archives>` that fulfill your requirements:: It's important to be clear that pip determines package dependencies using
`install_requires metadata
<http://pythonhosted.org/setuptools/setuptools.html#declaring-dependencies>`_,
not by discovering `requirements.txt` files embedded in projects.
$ pip install --download <DIR> -r requirements.txt See also:
Then, install using :ref:`--find-links <--find-links>` and :ref:`--no-index <--no-index>`:: * :ref:`Requirements File Format`
* :ref:`pip freeze`
* `"setup.py vs requirements.txt" (an article by Donald Stufft)
<https://caremad.io/blog/setup-vs-requirement/>`_
$ pip install --no-index --find-links=[file://]<DIR> -r requirements.txt
.. _`Building and Installing Wheels`: .. _`Installing from Wheels`:
Building and Installing Wheels Installing from Wheels
****************************** **********************
"Wheel" is a built, archive format that can greatly speed installation compared "Wheel" is a built, archive format that can greatly speed installation compared
to building and installing from source archives. For more information, see the to building and installing from source archives. For more information, see the
...@@ -92,16 +122,11 @@ to building and installing from source archives. For more information, see the ...@@ -92,16 +122,11 @@ to building and installing from source archives. For more information, see the
`PEP427 <http://www.python.org/dev/peps/pep-0427>`_, and `PEP427 <http://www.python.org/dev/peps/pep-0427>`_, and
`PEP425 <http://www.python.org/dev/peps/pep-0425>`_ `PEP425 <http://www.python.org/dev/peps/pep-0425>`_
Pip prefers Wheels where they are available, to disable this use the Pip prefers Wheels where they are available. To disable this, use the
:ref:`--no-use-wheel <install_--no-use-wheel>` flag for :ref:`pip install`. :ref:`--no-use-wheel <install_--no-use-wheel>` flag for :ref:`pip install`.
If no satisfactory wheels are found, pip will default to finding source archives. If no satisfactory wheels are found, pip will default to finding source archives.
.. note::
pip currently disallows platform-specific wheels (except for Windows and Mac)
from being downloaded from PyPI. See :ref:`Should you upload wheels to PyPI`.
To install directly from a wheel archive: To install directly from a wheel archive:
...@@ -110,11 +135,12 @@ To install directly from a wheel archive: ...@@ -110,11 +135,12 @@ To install directly from a wheel archive:
pip install SomePackage-1.0-py2.py3-none-any.whl pip install SomePackage-1.0-py2.py3-none-any.whl
pip additionally offers :ref:`pip wheel` as a convenience, to build wheels for For the cases where wheels are not available, pip offers :ref:`pip wheel` as a
your requirements and dependencies. convenience, to build wheels for all your requirements and dependencies.
:ref:`pip wheel` requires the `wheel package <https://pypi.python.org/pypi/wheel>`_ to be installed, :ref:`pip wheel` requires the `wheel package
which provides the "bdist_wheel" setuptools extension that it uses. <https://pypi.python.org/pypi/wheel>`_ to be installed, which provides the
"bdist_wheel" setuptools extension that it uses.
To build wheels for your requirements and all their dependencies to a local directory: To build wheels for your requirements and all their dependencies to a local directory:
...@@ -124,91 +150,230 @@ To build wheels for your requirements and all their dependencies to a local dire ...@@ -124,91 +150,230 @@ To build wheels for your requirements and all their dependencies to a local dire
pip wheel --wheel-dir=/local/wheels -r requirements.txt pip wheel --wheel-dir=/local/wheels -r requirements.txt
.. warning:: And *then* to install those requirements just using your local directory of wheels (and not from PyPI):
Currently, when ``pip wheel`` finds a wheel for one of your requirements ::
already on PyPI, it does not rebuild, and it does not place the file in your
wheelhouse dir. There is an issue open to change this
(https://github.com/pypa/pip/issues/1310)
pip install --no-index --find-links=/local/wheels -r requirements.txt
And *then* to install those requirements just using your local directory of wheels (and not from PyPI): Uninstalling Packages
*********************
pip is able to uninstall most packages like so:
:: ::
pip install --no-index --find-links=/local/wheels -r requirements.txt $ pip uninstall SomePackage
pip also performs an automatic uninstall of an old version of a package
before upgrading to a newer version.
For more information and examples, see the :ref:`pip uninstall` reference.
.. _`Should you upload wheels to PyPI`:
Should you upload wheels to PyPI? Listing Packages
--------------------------------- ****************
The wheel format can eliminate a lot of redundant compilation but, alas, To list installed packages:
it's not generally advisable to upload your pre-compiled linux-x86-64
library binding to pypi. Wheel's tags are only designed to express
the most important *Python*-specific compatibility concerns (Python
version, ABI, and architecture) but do not represent other important
binary compatibility factors such as the OS release, patch level, and
the versions of all the shared library dependencies of any extensions
inside the package.
Rather than representing all possible compatibility information in the ::
wheel itself, the wheel design suggests distribution-specific build
services (e.g. a separate index for Fedora Linux binary wheels, compiled
by the index maintainer). This is the same solution taken by Linux
distributions which all re-compile their own packages instead of installing
each other's binary packages.
Some kinds of precompiled C extension modules can make sense on PyPI, even $ pip list
for Linux. Good examples include things that can be sensibly statically Pygments (1.5)
linked (a cryptographic hash function; an accelerator module that is docutils (0.9.1)
not a binding for an external library); the best example of something Sphinx (1.1.2)
that shouldn't be statically linked is a library like openssl that needs Jinja2 (2.6)
to be constantly kept up-to-date for security. Regardless of whether a
compatible pre-build package is available, many Linux users will prefer
to always compile their own anyway.
On Windows and Mac, the case for binary wheels on pypi is stronger due to the To list outdated packages, and show the latest version available:
systems being much more uniform than Linux and because it's harder for the end
user to compile their own. Windows and Mac wheels uploaded to pypi should be
compatible with the Python distributions downloaded from http://python.org/. If
you already upload other binary formats to pypi, upload wheels as well. Unlike
the older formats, wheels are compatible with virtual environments.
::
.. _`Downloading Archives`: $ pip list --outdated
docutils (Current: 0.9.1 Latest: 0.10)
Sphinx (Current: 1.1.2 Latest: 1.1.3)
Downloading archives
********************
pip allows you to *just* download the source archives for your requirements, without installing anything and without regard to what's already installed. To show details about an installed package:
:: ::
$ pip install --download <DIR> -r requirements.txt $ pip show sphinx
---
Name: Sphinx
Version: 1.1.3
Location: /my/env/lib/pythonx.x/site-packages
Requires: Pygments, Jinja2, docutils
or, for a specific package::
$ pip install --download <DIR> SomePackage For more information and examples, see the :ref:`pip list` and :ref:`pip show`
reference pages.
Unpacking archives Searching for Packages
****************** **********************
pip allows you to *just* unpack archives to a build directory without installing them to site-packages. This can be useful to troubleshoot install errors or to inspect what is being installed. pip can search `PyPI`_ for packages using the ``pip search``
command::
:: $ pip search "query"
The query will be used to search the names and summaries of all
packages.
For more information and examples, see the :ref:`pip search` reference.
.. _`Configuration`:
Configuration
*************
.. _config-file:
Config file
------------
pip allows you to set all command line option defaults in a standard ini
style config file.
The names and locations of the configuration files vary slightly across
platforms.
* On Unix and Mac OS X the configuration file is: :file:`$HOME/.pip/pip.conf`
* On Windows, the configuration file is: :file:`%HOME%\\pip\\pip.ini`
You can set a custom path location for the config file using the environment variable ``PIP_CONFIG_FILE``.
In a virtual environment, an additional config file will be read from the base
directory of the virtualenv (``sys.prefix`` as reported by Python). The base
name of the file is the same as the user configuration file (:file:`pip.conf`
on Unix and OSX, :file:`pip.ini` on Windows). Values in the virtualenv-specific
configuration file take precedence over those in the user's configuration file
(whether from the user home or specified via ``PIP_CONFIG_FILE``).
The names of the settings are derived from the long command line option, e.g.
if you want to use a different package index (``--index-url``) and set the
HTTP timeout (``--default-timeout``) to 60 seconds your config file would
look like this:
.. code-block:: ini
[global]
timeout = 60
index-url = http://download.zope.org/ppix
Each subcommand can be configured optionally in its own section so that every
global setting with the same name will be overridden; e.g. decreasing the
``timeout`` to ``10`` seconds when running the `freeze`
(`Freezing Requirements <./#freezing-requirements>`_) command and using
``60`` seconds for all other commands is possible with:
.. code-block:: ini
[global]
timeout = 60
[freeze]
timeout = 10
Boolean options like ``--ignore-installed`` or ``--no-dependencies`` can be
set like this:
.. code-block:: ini
[install]
ignore-installed = true
no-dependencies = yes
Appending options like ``--find-links`` can be written on multiple lines:
.. code-block:: ini
[global]
find-links =
http://download.example.com
[install]
find-links =
http://mirror1.example.com
http://mirror2.example.com
Environment Variables
---------------------
pip's command line options can be set with environment variables using the
format ``PIP_<UPPER_LONG_NAME>`` . Dashes (``-``) have to be replaced with
underscores (``_``).
For example, to set the default timeout::
export PIP_DEFAULT_TIMEOUT=60
This is the same as passing the option to pip directly::
pip --default-timeout=60 [...]
To set options that can be set multiple times on the command line, just add
spaces in between values. For example::
export PIP_FIND_LINKS="http://mirror1.example.com http://mirror2.example.com"
is the same as calling::
pip install --find-links=http://mirror1.example.com --find-links=http://mirror2.example.com
Config Precedence
-----------------
Command line options have precedence over environment variables, which have precedence over the config file.
Within the config file, command specific sections have precedence over the global section.
Examples:
- ``--host=foo`` overrides ``PIP_HOST=foo``
- ``PIP_HOST=foo`` overrides a config file with ``[global] host = foo``
- A command specific section in the config file ``[<command>] host = bar``
overrides the option with same name in the ``[global]`` config file section
Command Completion
------------------
pip comes with support for command line completion in bash and zsh.
$ pip install --no-install SomePackage To setup for bash::
If you're in a virtualenv, the build dir is ``<virtualenv path>/build``. Otherwise, it's ``<OS temp dir>/pip-build-<username>`` $ pip completion --bash >> ~/.profile
Afterwards, to finish the job of installing unpacked archives, run:: To setup for zsh::
$ pip install --no-download SomePackage $ pip completion --zsh >> ~/.zprofile
Alternatively, you can use the result of the ``completion`` command
directly with the eval function of you shell, e.g. by adding the following to your startup file::
eval "`pip completion --bash`"
.. _`Fast & Local Installs`:
Fast & Local Installs
*********************
Often, you will want a fast install from local archives, without probing PyPI.
First, download the archives that fulfill your requirements::
$ pip install --download <DIR> -r requirements.txt
Then, install using :ref:`--find-links <--find-links>` and :ref:`--no-index <--no-index>`::
$ pip install --no-index --find-links=[file://]<DIR> -r requirements.txt
Non-recursive upgrades Non-recursive upgrades
...@@ -234,39 +399,17 @@ If you would like to perform a non-recursive upgrade perform these 2 steps:: ...@@ -234,39 +399,17 @@ If you would like to perform a non-recursive upgrade perform these 2 steps::
The first line will upgrade `SomePackage`, but not dependencies like `AnotherPackage`. The 2nd line will fill in new dependencies like `OneMorePackage`. The first line will upgrade `SomePackage`, but not dependencies like `AnotherPackage`. The 2nd line will fill in new dependencies like `OneMorePackage`.
.. _`Repeatability`:
Ensuring Repeatability
**********************
Three things are required to fully guarantee a repeatable installation using requirements files.
1. The requirements file was generated by ``pip freeze`` or you're sure it only
contains requirements that specify a specific version.
2. The installation is performed using :ref:`--no-deps <install_--no-deps>`.
This guarantees that only what is explicitly listed in the requirements file is
installed.
3. The installation is performed against an index or find-links location that is
guaranteed to *not* allow archives to be changed and updated without a
version increase. Unfortunately, this is *not* true on PyPI. It is possible
for the same pypi distribution to have a different hash over time. Project
authors are allowed to delete a distribution, and then upload a new one with
the same name and version, but a different hash. See `Issue #1175
<https://github.com/pypa/pip/issues/1175>`_ for plans to add hash
confirmation to pip, or a new "lock file" notion, but for now, know that the `peep
project <https://pypi.python.org/pypi/peep>`_ offers this feature on top of pip
using requirements file comments.
User Installs User Installs
************* *************
With Python 2.6 came the `"user scheme" for installation With Python 2.6 came the `"user scheme" for installation
<http://docs.python.org/install/index.html#alternate-installation-the-user-scheme>`_, which means that all <http://docs.python.org/install/index.html#alternate-installation-the-user-scheme>`_,
Python distributions support an alternative install location that is specific to a user. which means that all Python distributions support an alternative install
The default location for each OS is explained in the python documentation location that is specific to a user. The default location for each OS is
for the `site.USER_BASE <http://docs.python.org/library/site.html#site.USER_BASE>`_ variable. explained in the python documentation for the `site.USER_BASE
This mode of installation can be turned on by <http://docs.python.org/library/site.html#site.USER_BASE>`_ variable. This mode
specifying the :ref:`--user <install_--user>` option to ``pip install``. of installation can be turned on by specifying the :ref:`--user
<install_--user>` option to ``pip install``.
Moreover, the "user scheme" can be customized by setting the Moreover, the "user scheme" can be customized by setting the
``PYTHONUSERBASE`` environment variable, which updates the value of ``site.USER_BASE``. ``PYTHONUSERBASE`` environment variable, which updates the value of ``site.USER_BASE``.
...@@ -344,110 +487,30 @@ From within a real python, where ``SomePackage`` *is* installed globally, and is ...@@ -344,110 +487,30 @@ From within a real python, where ``SomePackage`` *is* installed globally, and is
Successfully installed SomePackage Successfully installed SomePackage
.. _`Repeatability`:
Controlling setup_requires Ensuring Repeatability
************************** **********************
Setuptools offers the ``setup_requires``
`setup() keyword <http://pythonhosted.org/setuptools/setuptools.html#new-and-changed-setup-keywords>`_
for specifying dependencies that need to be present in order for the `setup.py` script to run.
Internally, Setuptools uses ``easy_install`` to fulfill these dependencies.
pip has no way to control how these dependencies are located.
None of the :ref:`Package Index Options <Package Index Options>` have an effect.
The solution is to configure a "system" or "personal"
`Distutils configuration file <http://docs.python.org/2/install/index.html#distutils-configuration-files>`_
to manage the fulfillment.
For example, to have the dependency located at an alternate index, add this:
::
[easy_install]
index_url = https://my.index-mirror.com
To have the dependency located from a local directory and not crawl PyPI, add this:
::
[easy_install]
allow_hosts = ''
find_links = file:///path/to/local/archives
Upgrading from distribute to setuptools
***************************************
`distribute`_ has now been merged into `setuptools`_, and it is recommended to upgrade to setuptools when possible.
To upgrade from `distribute`_ to `setuptools`_ using pip, run::
pip install --upgrade setuptools
"ImportError: No module named setuptools"
-----------------------------------------
Although using the upgrade command above works in isolation, it's possible to get
"ImportError: No module named setuptools" when using pip<1.4 to upgrade a
package that depends on setuptools or distribute.
e.g. when running a command like this: `pip install --upgrade pyramid`
Solution
~~~~~~~~
To prevent the problem in *new* environments (that aren't broken yet):
* Option 1:
* *First* run `pip install -U setuptools`,
* *Then* run the command to upgrade your package (e.g. `pip install --upgrade pyramid`)
* Option 2:
* Upgrade pip using :ref:`get-pip <get-pip>`
* *Then* run the command to upgrade your package (e.g. `pip install --upgrade pyramid`)
To fix the problem once it's occurred, you'll need to manually install the new
setuptools, then rerun the upgrade that failed.
1. Download `ez_setup.py` (https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py)
2. Run `python ez_setup.py`
3. Then rerun your upgrade (e.g. `pip install --upgrade pyramid`)
Cause
~~~~~
distribute-0.7.3 is just an empty wrapper that only serves to require the new
setuptools (setuptools>=0.7) so that it will be installed. (If you don't know
yet, the "new setuptools" is a merge of distribute and setuptools back into one
project).
distribute-0.7.3 does its job well, when the upgrade is done in isolation.
E.g. if you're currently on distribute-0.6.X, then running `pip install -U
setuptools` works fine to upgrade you to setuptools>=0.7.
The problem occurs when: Three things are required to fully guarantee a repeatable installation using requirements files.
1. you are currently using an older distribute (i.e. 0.6.X) 1. The requirements file was generated by ``pip freeze`` or you're sure it only
2. and you try to use pip to upgrade a package that *depends* on setuptools or contains requirements that specify a specific version.
distribute.
As part of the upgrade process, pip builds an install list that ends up 2. The installation is performed using :ref:`--no-deps <install_--no-deps>`.
including distribute-0.7.3 and setuptools>=0.7 , but they can end up being This guarantees that only what is explicitly listed in the requirements file is
separated by other dependencies in the list, so what can happen is this: installed.
1. pip uninstalls the existing distribute 3. The installation is performed against an index or find-links location that is
2. pip installs distribute-0.7.3 (which has no importable setuptools, that pip guaranteed to *not* allow archives to be changed and updated without a
*needs* internally to function) version increase. Unfortunately, this is *not* true on PyPI. It is possible
3. pip moves on to install another dependency (before setuptools>=0.7) and is for the same pypi distribution to have a different hash over time. Project
unable to proceed without the setuptools package authors are allowed to delete a distribution, and then upload a new one with
the same name and version, but a different hash. See `Issue #1175
<https://github.com/pypa/pip/issues/1175>`_ for plans to add hash
confirmation to pip, or a new "lock file" notion, but for now, know that the `peep
project <https://pypi.python.org/pypi/peep>`_ offers this feature on top of pip
using requirements file comments.
Note that pip v1.4 has fixes to prevent this. distribute-0.7.3 (or
setuptools>=0.7) by themselves cannot prevent this kind of problem.
.. _setuptools: https://pypi.python.org/pypi/setuptools .. _PyPI: http://pypi.python.org/pypi/
.. _distribute: https://pypi.python.org/pypi/distribute
.. _PyPI: https://pypi.python.org
Metadata-Version: 1.1 Metadata-Version: 1.1
Name: pip Name: pip
Version: 1.5.2 Version: 1.5.4
Summary: A tool for installing and managing Python packages. Summary: A tool for installing and managing Python packages.
Home-page: http://www.pip-installer.org Home-page: http://www.pip-installer.org
Author: The pip developers Author: The pip developers
...@@ -16,16 +16,19 @@ Description: ...@@ -16,16 +16,19 @@ Description:
* Bug Tracking: https://github.com/pypa/pip/issues * Bug Tracking: https://github.com/pypa/pip/issues
* Mailing list: http://groups.google.com/group/python-virtualenv * Mailing list: http://groups.google.com/group/python-virtualenv
* Docs: http://www.pip-installer.org/ * Docs: http://www.pip-installer.org/
* IRC: #pip on Freenode. * User IRC: #pip on Freenode.
* Dev IRC: #pypa on Freenode.
Quickstart Quickstart
========== ==========
Install a package: First, :doc:`Install pip <installing>`.
Install a package from `PyPI`_:
:: ::
$ pip install SomePackage==1.0 $ pip install SomePackage
[...] [...]
Successfully installed SomePackage Successfully installed SomePackage
...@@ -71,6 +74,8 @@ Description: ...@@ -71,6 +74,8 @@ Description:
Successfully uninstalled SomePackage Successfully uninstalled SomePackage
.. _PyPI: http://pypi.python.org/pypi/
Keywords: easy_install distutils setuptools egg virtualenv Keywords: easy_install distutils setuptools egg virtualenv
Platform: UNKNOWN Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable Classifier: Development Status :: 5 - Production/Stable
......
...@@ -9,13 +9,23 @@ setup.py ...@@ -9,13 +9,23 @@ setup.py
docs/configuration.rst docs/configuration.rst
docs/cookbook.rst docs/cookbook.rst
docs/development.rst docs/development.rst
docs/distribute_setuptools.rst
docs/index.rst docs/index.rst
docs/installing.rst docs/installing.rst
docs/logic.rst docs/logic.rst
docs/news.rst docs/news.rst
docs/other-tools.rst
docs/quickstart.rst docs/quickstart.rst
docs/usage.rst docs/usage.rst
docs/user_guide.rst
docs/reference/index.rst
docs/reference/pip.rst
docs/reference/pip_freeze.rst
docs/reference/pip_install.rst
docs/reference/pip_list.rst
docs/reference/pip_search.rst
docs/reference/pip_show.rst
docs/reference/pip_uninstall.rst
docs/reference/pip_wheel.rst
pip/__init__.py pip/__init__.py
pip/__main__.py pip/__main__.py
pip/basecommand.py pip/basecommand.py
......
...@@ -19,7 +19,7 @@ import pip.cmdoptions ...@@ -19,7 +19,7 @@ import pip.cmdoptions
cmdoptions = pip.cmdoptions cmdoptions = pip.cmdoptions
# The version as used in the setup.py and the docs conf.py # The version as used in the setup.py and the docs conf.py
__version__ = "1.5.2" __version__ = "1.5.4"
def autocomplete(): def autocomplete():
......
"""Utilities for writing code that runs on Python 2 and 3""" """Utilities for writing code that runs on Python 2 and 3"""
# Copyright (c) 2010-2013 Benjamin Peterson # Copyright (c) 2010-2014 Benjamin Peterson
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy of # Permission is hereby granted, free of charge, to any person obtaining a copy
# this software and associated documentation files (the "Software"), to deal in # of this software and associated documentation files (the "Software"), to deal
# the Software without restriction, including without limitation the rights to # in the Software without restriction, including without limitation the rights
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# the Software, and to permit persons to whom the Software is furnished to do so, # copies of the Software, and to permit persons to whom the Software is
# subject to the following conditions: # furnished to do so, subject to the following conditions:
# #
# The above copyright notice and this permission notice shall be included in all # The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software. # copies or substantial portions of the Software.
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import operator import operator
import sys import sys
import types import types
__author__ = "Benjamin Peterson <benjamin@python.org>" __author__ = "Benjamin Peterson <benjamin@python.org>"
__version__ = "1.3.0" __version__ = "1.5.2"
# True if we are running on Python 3. # Useful for very coarse version differentiation.
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3 PY3 = sys.version_info[0] == 3
if PY3: if PY3:
...@@ -82,9 +84,9 @@ class _LazyDescr(object): ...@@ -82,9 +84,9 @@ class _LazyDescr(object):
def __get__(self, obj, tp): def __get__(self, obj, tp):
result = self._resolve() result = self._resolve()
setattr(obj, self.name, result) setattr(obj, self.name, result) # Invokes __set__.
# This is a bit ugly, but it avoids running this again. # This is a bit ugly, but it avoids running this again.
delattr(tp, self.name) delattr(obj.__class__, self.name)
return result return result
...@@ -102,6 +104,35 @@ class MovedModule(_LazyDescr): ...@@ -102,6 +104,35 @@ class MovedModule(_LazyDescr):
def _resolve(self): def _resolve(self):
return _import_module(self.mod) return _import_module(self.mod)
def __getattr__(self, attr):
# Hack around the Django autoreloader. The reloader tries to get
# __file__ or __name__ of every module in sys.modules. This doesn't work
# well if this MovedModule is for an module that is unavailable on this
# machine (like winreg on Unix systems). Thus, we pretend __file__ and
# __name__ don't exist if the module hasn't been loaded yet. See issues
# #51 and #53.
if attr in ("__file__", "__name__") and self.mod not in sys.modules:
raise AttributeError
_module = self._resolve()
value = getattr(_module, attr)
setattr(self, attr, value)
return value
class _LazyModule(types.ModuleType):
def __init__(self, name):
super(_LazyModule, self).__init__(name)
self.__doc__ = self.__class__.__doc__
def __dir__(self):
attrs = ["__doc__", "__name__"]
attrs += [attr.name for attr in self._moved_attributes]
return attrs
# Subclasses should override this
_moved_attributes = []
class MovedAttribute(_LazyDescr): class MovedAttribute(_LazyDescr):
...@@ -129,24 +160,29 @@ class MovedAttribute(_LazyDescr): ...@@ -129,24 +160,29 @@ class MovedAttribute(_LazyDescr):
class _MovedItems(types.ModuleType): class _MovedItems(_LazyModule):
"""Lazy loading of moved objects""" """Lazy loading of moved objects"""
_moved_attributes = [ _moved_attributes = [
MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
MovedAttribute("map", "itertools", "builtins", "imap", "map"), MovedAttribute("map", "itertools", "builtins", "imap", "map"),
MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
MovedAttribute("reload_module", "__builtin__", "imp", "reload"), MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
MovedAttribute("reduce", "__builtin__", "functools"), MovedAttribute("reduce", "__builtin__", "functools"),
MovedAttribute("StringIO", "StringIO", "io"), MovedAttribute("StringIO", "StringIO", "io"),
MovedAttribute("UserString", "UserString", "collections"),
MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
MovedModule("builtins", "__builtin__"), MovedModule("builtins", "__builtin__"),
MovedModule("configparser", "ConfigParser"), MovedModule("configparser", "ConfigParser"),
MovedModule("copyreg", "copy_reg"), MovedModule("copyreg", "copy_reg"),
MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
MovedModule("http_cookies", "Cookie", "http.cookies"), MovedModule("http_cookies", "Cookie", "http.cookies"),
MovedModule("html_entities", "htmlentitydefs", "html.entities"), MovedModule("html_entities", "htmlentitydefs", "html.entities"),
...@@ -162,12 +198,14 @@ _moved_attributes = [ ...@@ -162,12 +198,14 @@ _moved_attributes = [
MovedModule("queue", "Queue"), MovedModule("queue", "Queue"),
MovedModule("reprlib", "repr"), MovedModule("reprlib", "repr"),
MovedModule("socketserver", "SocketServer"), MovedModule("socketserver", "SocketServer"),
MovedModule("_thread", "thread", "_thread"),
MovedModule("tkinter", "Tkinter"), MovedModule("tkinter", "Tkinter"),
MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
MovedModule("tkinter_tix", "Tix", "tkinter.tix"), MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"),
MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
MovedModule("tkinter_colorchooser", "tkColorChooser", MovedModule("tkinter_colorchooser", "tkColorChooser",
...@@ -179,14 +217,167 @@ _moved_attributes = [ ...@@ -179,14 +217,167 @@ _moved_attributes = [
MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", MovedModule("tkinter_tksimpledialog", "tkSimpleDialog",
"tkinter.simpledialog"), "tkinter.simpledialog"),
MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"),
MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"),
MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"),
MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
MovedModule("winreg", "_winreg"), MovedModule("winreg", "_winreg"),
] ]
for attr in _moved_attributes: for attr in _moved_attributes:
setattr(_MovedItems, attr.name, attr) setattr(_MovedItems, attr.name, attr)
if isinstance(attr, MovedModule):
sys.modules[__name__ + ".moves." + attr.name] = attr
del attr
_MovedItems._moved_attributes = _moved_attributes
moves = sys.modules[__name__ + ".moves"] = _MovedItems(__name__ + ".moves")
class Module_six_moves_urllib_parse(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_parse"""
_urllib_parse_moved_attributes = [
MovedAttribute("ParseResult", "urlparse", "urllib.parse"),
MovedAttribute("parse_qs", "urlparse", "urllib.parse"),
MovedAttribute("parse_qsl", "urlparse", "urllib.parse"),
MovedAttribute("urldefrag", "urlparse", "urllib.parse"),
MovedAttribute("urljoin", "urlparse", "urllib.parse"),
MovedAttribute("urlparse", "urlparse", "urllib.parse"),
MovedAttribute("urlsplit", "urlparse", "urllib.parse"),
MovedAttribute("urlunparse", "urlparse", "urllib.parse"),
MovedAttribute("urlunsplit", "urlparse", "urllib.parse"),
MovedAttribute("quote", "urllib", "urllib.parse"),
MovedAttribute("quote_plus", "urllib", "urllib.parse"),
MovedAttribute("unquote", "urllib", "urllib.parse"),
MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
MovedAttribute("urlencode", "urllib", "urllib.parse"),
]
for attr in _urllib_parse_moved_attributes:
setattr(Module_six_moves_urllib_parse, attr.name, attr)
del attr
Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes
sys.modules[__name__ + ".moves.urllib_parse"] = sys.modules[__name__ + ".moves.urllib.parse"] = Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse")
class Module_six_moves_urllib_error(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_error"""
_urllib_error_moved_attributes = [
MovedAttribute("URLError", "urllib2", "urllib.error"),
MovedAttribute("HTTPError", "urllib2", "urllib.error"),
MovedAttribute("ContentTooShortError", "urllib", "urllib.error"),
]
for attr in _urllib_error_moved_attributes:
setattr(Module_six_moves_urllib_error, attr.name, attr)
del attr
Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes
sys.modules[__name__ + ".moves.urllib_error"] = sys.modules[__name__ + ".moves.urllib.error"] = Module_six_moves_urllib_error(__name__ + ".moves.urllib.error")
class Module_six_moves_urllib_request(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_request"""
_urllib_request_moved_attributes = [
MovedAttribute("urlopen", "urllib2", "urllib.request"),
MovedAttribute("install_opener", "urllib2", "urllib.request"),
MovedAttribute("build_opener", "urllib2", "urllib.request"),
MovedAttribute("pathname2url", "urllib", "urllib.request"),
MovedAttribute("url2pathname", "urllib", "urllib.request"),
MovedAttribute("getproxies", "urllib", "urllib.request"),
MovedAttribute("Request", "urllib2", "urllib.request"),
MovedAttribute("OpenerDirector", "urllib2", "urllib.request"),
MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"),
MovedAttribute("ProxyHandler", "urllib2", "urllib.request"),
MovedAttribute("BaseHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"),
MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"),
MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"),
MovedAttribute("FileHandler", "urllib2", "urllib.request"),
MovedAttribute("FTPHandler", "urllib2", "urllib.request"),
MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"),
MovedAttribute("UnknownHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
MovedAttribute("urlretrieve", "urllib", "urllib.request"),
MovedAttribute("urlcleanup", "urllib", "urllib.request"),
MovedAttribute("URLopener", "urllib", "urllib.request"),
MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
]
for attr in _urllib_request_moved_attributes:
setattr(Module_six_moves_urllib_request, attr.name, attr)
del attr del attr
moves = sys.modules[__name__ + ".moves"] = _MovedItems("moves") Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes
sys.modules[__name__ + ".moves.urllib_request"] = sys.modules[__name__ + ".moves.urllib.request"] = Module_six_moves_urllib_request(__name__ + ".moves.urllib.request")
class Module_six_moves_urllib_response(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_response"""
_urllib_response_moved_attributes = [
MovedAttribute("addbase", "urllib", "urllib.response"),
MovedAttribute("addclosehook", "urllib", "urllib.response"),
MovedAttribute("addinfo", "urllib", "urllib.response"),
MovedAttribute("addinfourl", "urllib", "urllib.response"),
]
for attr in _urllib_response_moved_attributes:
setattr(Module_six_moves_urllib_response, attr.name, attr)
del attr
Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes
sys.modules[__name__ + ".moves.urllib_response"] = sys.modules[__name__ + ".moves.urllib.response"] = Module_six_moves_urllib_response(__name__ + ".moves.urllib.response")
class Module_six_moves_urllib_robotparser(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_robotparser"""
_urllib_robotparser_moved_attributes = [
MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"),
]
for attr in _urllib_robotparser_moved_attributes:
setattr(Module_six_moves_urllib_robotparser, attr.name, attr)
del attr
Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes
sys.modules[__name__ + ".moves.urllib_robotparser"] = sys.modules[__name__ + ".moves.urllib.robotparser"] = Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser")
class Module_six_moves_urllib(types.ModuleType):
"""Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
parse = sys.modules[__name__ + ".moves.urllib_parse"]
error = sys.modules[__name__ + ".moves.urllib_error"]
request = sys.modules[__name__ + ".moves.urllib_request"]
response = sys.modules[__name__ + ".moves.urllib_response"]
robotparser = sys.modules[__name__ + ".moves.urllib_robotparser"]
def __dir__(self):
return ['parse', 'error', 'request', 'response', 'robotparser']
sys.modules[__name__ + ".moves.urllib"] = Module_six_moves_urllib(__name__ + ".moves.urllib")
def add_move(move): def add_move(move):
...@@ -252,11 +443,16 @@ if PY3: ...@@ -252,11 +443,16 @@ if PY3:
def get_unbound_function(unbound): def get_unbound_function(unbound):
return unbound return unbound
create_bound_method = types.MethodType
Iterator = object Iterator = object
else: else:
def get_unbound_function(unbound): def get_unbound_function(unbound):
return unbound.im_func return unbound.im_func
def create_bound_method(func, obj):
return types.MethodType(func, obj, obj.__class__)
class Iterator(object): class Iterator(object):
def next(self): def next(self):
...@@ -297,21 +493,33 @@ if PY3: ...@@ -297,21 +493,33 @@ if PY3:
return s.encode("latin-1") return s.encode("latin-1")
def u(s): def u(s):
return s return s
unichr = chr
if sys.version_info[1] <= 1: if sys.version_info[1] <= 1:
def int2byte(i): def int2byte(i):
return bytes((i,)) return bytes((i,))
else: else:
# This is about 2x faster than the implementation above on 3.2+ # This is about 2x faster than the implementation above on 3.2+
int2byte = operator.methodcaller("to_bytes", 1, "big") int2byte = operator.methodcaller("to_bytes", 1, "big")
byte2int = operator.itemgetter(0)
indexbytes = operator.getitem
iterbytes = iter
import io import io
StringIO = io.StringIO StringIO = io.StringIO
BytesIO = io.BytesIO BytesIO = io.BytesIO
else: else:
def b(s): def b(s):
return s return s
# Workaround for standalone backslash
def u(s): def u(s):
return unicode(s, "unicode_escape") return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
unichr = unichr
int2byte = chr int2byte = chr
def byte2int(bs):
return ord(bs[0])
def indexbytes(buf, i):
return ord(buf[i])
def iterbytes(buf):
return (ord(byte) for byte in buf)
import StringIO import StringIO
StringIO = BytesIO = StringIO.StringIO StringIO = BytesIO = StringIO.StringIO
_add_doc(b, """Byte literal""") _add_doc(b, """Byte literal""")
...@@ -319,8 +527,7 @@ _add_doc(u, """Text literal""") ...@@ -319,8 +527,7 @@ _add_doc(u, """Text literal""")
if PY3: if PY3:
import builtins exec_ = getattr(moves.builtins, "exec")
exec_ = getattr(builtins, "exec")
def reraise(tp, value, tb=None): def reraise(tp, value, tb=None):
...@@ -328,10 +535,6 @@ if PY3: ...@@ -328,10 +535,6 @@ if PY3:
raise value.with_traceback(tb) raise value.with_traceback(tb)
raise value raise value
print_ = getattr(builtins, "print")
del builtins
else: else:
def exec_(_code_, _globs_=None, _locs_=None): def exec_(_code_, _globs_=None, _locs_=None):
"""Execute code in a namespace.""" """Execute code in a namespace."""
...@@ -351,14 +554,24 @@ else: ...@@ -351,14 +554,24 @@ else:
""") """)
print_ = getattr(moves.builtins, "print", None)
if print_ is None:
def print_(*args, **kwargs): def print_(*args, **kwargs):
"""The new-style print function.""" """The new-style print function for Python 2.4 and 2.5."""
fp = kwargs.pop("file", sys.stdout) fp = kwargs.pop("file", sys.stdout)
if fp is None: if fp is None:
return return
def write(data): def write(data):
if not isinstance(data, basestring): if not isinstance(data, basestring):
data = str(data) data = str(data)
# If the file has an encoding, encode unicode with it.
if (isinstance(fp, file) and
isinstance(data, unicode) and
fp.encoding is not None):
errors = getattr(fp, "errors", None)
if errors is None:
errors = "strict"
data = data.encode(fp.encoding, errors)
fp.write(data) fp.write(data)
want_unicode = False want_unicode = False
sep = kwargs.pop("sep", None) sep = kwargs.pop("sep", None)
...@@ -399,6 +612,21 @@ else: ...@@ -399,6 +612,21 @@ else:
_add_doc(reraise, """Reraise an exception.""") _add_doc(reraise, """Reraise an exception.""")
def with_metaclass(meta, base=object): def with_metaclass(meta, *bases):
"""Create a base class with a metaclass.""" """Create a base class with a metaclass."""
return meta("NewBase", (base,), {}) return meta("NewBase", bases, {})
def add_metaclass(metaclass):
"""Class decorator for creating a class with a metaclass."""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
orig_vars.pop('__dict__', None)
orig_vars.pop('__weakref__', None)
slots = orig_vars.get('__slots__')
if slots is not None:
if isinstance(slots, str):
slots = [slots]
for slots_var in slots:
orig_vars.pop(slots_var)
return metaclass(cls.__name__, cls.__bases__, orig_vars)
return wrapper
...@@ -130,12 +130,15 @@ class ConfigOptionParser(CustomOptionParser): ...@@ -130,12 +130,15 @@ class ConfigOptionParser(CustomOptionParser):
self.config = ConfigParser.RawConfigParser() self.config = ConfigParser.RawConfigParser()
self.name = kwargs.pop('name') self.name = kwargs.pop('name')
self.files = self.get_config_files() self.files = self.get_config_files()
if self.files:
self.config.read(self.files) self.config.read(self.files)
assert self.name assert self.name
optparse.OptionParser.__init__(self, *args, **kwargs) optparse.OptionParser.__init__(self, *args, **kwargs)
def get_config_files(self): def get_config_files(self):
config_file = os.environ.get('PIP_CONFIG_FILE', False) config_file = os.environ.get('PIP_CONFIG_FILE', False)
if config_file == os.devnull:
return []
if config_file and os.path.exists(config_file): if config_file and os.path.exists(config_file):
return [config_file] return [config_file]
return [default_config_file] return [default_config_file]
......
...@@ -4,7 +4,8 @@ import tempfile ...@@ -4,7 +4,8 @@ import tempfile
import shutil import shutil
from pip.req import InstallRequirement, RequirementSet, parse_requirements from pip.req import InstallRequirement, RequirementSet, parse_requirements
from pip.log import logger from pip.log import logger
from pip.locations import src_prefix, virtualenv_no_global, distutils_scheme from pip.locations import (src_prefix, virtualenv_no_global, distutils_scheme,
build_prefix)
from pip.basecommand import Command from pip.basecommand import Command
from pip.index import PackageFinder from pip.index import PackageFinder
from pip.exceptions import InstallationError, CommandError, PreviousBuildDirError from pip.exceptions import InstallationError, CommandError, PreviousBuildDirError
...@@ -22,9 +23,6 @@ class InstallCommand(Command): ...@@ -22,9 +23,6 @@ class InstallCommand(Command):
pip also supports installing from "requirements files", which provide pip also supports installing from "requirements files", which provide
an easy way to specify a whole environment to be installed. an easy way to specify a whole environment to be installed.
See http://www.pip-installer.org for details on VCS url formats and
requirements files.
""" """
name = 'install' name = 'install'
...@@ -187,8 +185,14 @@ class InstallCommand(Command): ...@@ -187,8 +185,14 @@ class InstallCommand(Command):
def run(self, options, args): def run(self, options, args):
if options.no_install or options.no_download: if (
logger.deprecated('1.7', "DEPRECATION: '--no-install' and '--no-download` are deprecated. See https://github.com/pypa/pip/issues/906.") options.no_install or
options.no_download or
(options.build_dir != build_prefix) or
options.no_clean
):
logger.deprecated('1.7', 'DEPRECATION: --no-install, --no-download, --build, '
'and --no-clean are deprecated. See https://github.com/pypa/pip/issues/906.')
if options.download_dir: if options.download_dir:
options.no_install = True options.no_install = True
......
...@@ -146,19 +146,25 @@ class WheelCommand(Command): ...@@ -146,19 +146,25 @@ class WheelCommand(Command):
ignore_dependencies=options.ignore_dependencies, ignore_dependencies=options.ignore_dependencies,
ignore_installed=True, ignore_installed=True,
session=session, session=session,
wheel_download_dir=options.wheel_dir
) )
# make the wheelhouse
if not os.path.exists(options.wheel_dir):
os.makedirs(options.wheel_dir)
#parse args and/or requirements files #parse args and/or requirements files
for name in args: for name in args:
if name.endswith(".whl"):
logger.notify("ignoring %s" % name)
continue
requirement_set.add_requirement( requirement_set.add_requirement(
InstallRequirement.from_line(name, None)) InstallRequirement.from_line(name, None))
for filename in options.requirements: for filename in options.requirements:
for req in parse_requirements(filename, finder=finder, options=options, session=session): for req in parse_requirements(
if req.editable or (req.name is None and req.url.endswith(".whl")): filename,
finder=finder,
options=options,
session=session):
if req.editable:
logger.notify("ignoring %s" % req.url) logger.notify("ignoring %s" % req.url)
continue continue
requirement_set.add_requirement(req) requirement_set.add_requirement(req)
......
...@@ -344,18 +344,6 @@ def unpack_vcs_link(link, location, only_download=False): ...@@ -344,18 +344,6 @@ def unpack_vcs_link(link, location, only_download=False):
vcs_backend.unpack(location) vcs_backend.unpack(location)
def unpack_file_url(link, location):
source = url_to_path(link.url)
content_type = mimetypes.guess_type(source)[0]
if os.path.isdir(source):
# delete the location since shutil will create it again :(
if os.path.isdir(location):
rmtree(location)
shutil.copytree(source, location, symlinks=True)
else:
unpack_file(source, location, content_type, link)
def _get_used_vcs_backend(link): def _get_used_vcs_backend(link):
for backend in vcs.backends: for backend in vcs.backends:
if link.scheme in backend.schemes: if link.scheme in backend.schemes:
...@@ -478,7 +466,6 @@ def _copy_file(filename, location, content_type, link): ...@@ -478,7 +466,6 @@ def _copy_file(filename, location, content_type, link):
shutil.move(download_location, dest_file) shutil.move(download_location, dest_file)
if copy: if copy:
shutil.copy(filename, download_location) shutil.copy(filename, download_location)
logger.indent -= 2
logger.notify('Saved %s' % display_path(download_location)) logger.notify('Saved %s' % display_path(download_location))
...@@ -490,11 +477,12 @@ def unpack_http_url(link, location, download_cache, download_dir=None, ...@@ -490,11 +477,12 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
temp_dir = tempfile.mkdtemp('-unpack', 'pip-') temp_dir = tempfile.mkdtemp('-unpack', 'pip-')
temp_location = None temp_location = None
target_url = link.url.split('#', 1)[0] target_url = link.url.split('#', 1)[0]
already_cached = False already_cached = False
cache_file = None cache_file = None
cache_content_type_file = None cache_content_type_file = None
download_hash = None download_hash = None
# If a download cache is specified, is the file cached there?
if download_cache: if download_cache:
cache_file = os.path.join(download_cache, cache_file = os.path.join(download_cache,
urllib.quote(target_url, '')) urllib.quote(target_url, ''))
...@@ -506,12 +494,14 @@ def unpack_http_url(link, location, download_cache, download_dir=None, ...@@ -506,12 +494,14 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
if not os.path.isdir(download_cache): if not os.path.isdir(download_cache):
create_download_cache_folder(download_cache) create_download_cache_folder(download_cache)
# If a download dir is specified, is the file already downloaded there?
already_downloaded = None already_downloaded = None
if download_dir: if download_dir:
already_downloaded = os.path.join(download_dir, link.filename) already_downloaded = os.path.join(download_dir, link.filename)
if not os.path.exists(already_downloaded): if not os.path.exists(already_downloaded):
already_downloaded = None already_downloaded = None
# If already downloaded, does it's hash match?
if already_downloaded: if already_downloaded:
temp_location = already_downloaded temp_location = already_downloaded
content_type = mimetypes.guess_type(already_downloaded)[0] content_type = mimetypes.guess_type(already_downloaded)[0]
...@@ -529,7 +519,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None, ...@@ -529,7 +519,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
os.unlink(already_downloaded) os.unlink(already_downloaded)
already_downloaded = None already_downloaded = None
# We have a cached file, and we haven't already found a good downloaded copy # If not a valid download, let's confirm the cached file is valid
if already_cached and not temp_location: if already_cached and not temp_location:
with open(cache_content_type_file) as fp: with open(cache_content_type_file) as fp:
content_type = fp.read().strip() content_type = fp.read().strip()
...@@ -550,6 +540,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None, ...@@ -550,6 +540,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
already_cached = False already_cached = False
# We don't have either a cached or a downloaded copy # We don't have either a cached or a downloaded copy
# let's download to a tmp dir
if not temp_location: if not temp_location:
try: try:
resp = session.get(target_url, stream=True) resp = session.get(target_url, stream=True)
...@@ -582,11 +573,72 @@ def unpack_http_url(link, location, download_cache, download_dir=None, ...@@ -582,11 +573,72 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
if link.hash and link.hash_name: if link.hash and link.hash_name:
_check_hash(download_hash, link) _check_hash(download_hash, link)
# a download dir is specified; let's copy the archive there
if download_dir and not already_downloaded: if download_dir and not already_downloaded:
_copy_file(temp_location, download_dir, content_type, link) _copy_file(temp_location, download_dir, content_type, link)
# unpack the archive to the build dir location. even when only downloading
# archives, they have to be unpacked to parse dependencies
unpack_file(temp_location, location, content_type, link) unpack_file(temp_location, location, content_type, link)
# if using a download cache, cache it, if needed
if cache_file and not already_cached: if cache_file and not already_cached:
cache_download(cache_file, temp_location, content_type) cache_download(cache_file, temp_location, content_type)
if not (already_cached or already_downloaded): if not (already_cached or already_downloaded):
os.unlink(temp_location) os.unlink(temp_location)
os.rmdir(temp_dir) os.rmdir(temp_dir)
def unpack_file_url(link, location, download_dir=None):
link_path = url_to_path(link.url_without_fragment)
already_downloaded = False
# If it's a url to a local directory
if os.path.isdir(link_path):
if os.path.isdir(location):
rmtree(location)
shutil.copytree(link_path, location, symlinks=True)
return
# if link has a hash, let's confirm it matches
if link.hash:
link_path_hash = _get_hash_from_file(link_path, link)
_check_hash(link_path_hash, link)
# If a download dir is specified, is the file already there and valid?
if download_dir:
download_path = os.path.join(download_dir, link.filename)
if os.path.exists(download_path):
content_type = mimetypes.guess_type(download_path)[0]
logger.notify('File was already downloaded %s' % download_path)
if link.hash:
download_hash = _get_hash_from_file(download_path, link)
try:
_check_hash(download_hash, link)
already_downloaded = True
except HashMismatch:
logger.warn(
'Previously-downloaded file %s has bad hash, '
're-downloading.' % link_path
)
os.unlink(download_path)
else:
already_downloaded = True
if already_downloaded:
from_path = download_path
else:
from_path = link_path
content_type = mimetypes.guess_type(from_path)[0]
# unpack the archive to the build dir location. even when only downloading
# archives, they have to be unpacked to parse dependencies
unpack_file(from_path, location, content_type, link)
# a download dir is specified and not already downloaded
if download_dir and not already_downloaded:
_copy_file(from_path, download_dir, content_type, link)
...@@ -33,7 +33,7 @@ from pip.download import (PipSession, get_file_content, is_url, url_to_path, ...@@ -33,7 +33,7 @@ from pip.download import (PipSession, get_file_content, is_url, url_to_path,
unpack_file_url, unpack_http_url) unpack_file_url, unpack_http_url)
import pip.wheel import pip.wheel
from pip.wheel import move_wheel_files, Wheel, wheel_ext from pip.wheel import move_wheel_files, Wheel, wheel_ext
from pip._vendor import pkg_resources from pip._vendor import pkg_resources, six
def read_text_file(filename): def read_text_file(filename):
...@@ -280,6 +280,10 @@ class InstallRequirement(object): ...@@ -280,6 +280,10 @@ class InstallRequirement(object):
else: else:
setup_py = os.path.join(self.source_dir, setup_file) setup_py = os.path.join(self.source_dir, setup_file)
# Python2 __file__ should not be unicode
if six.PY2 and isinstance(setup_py, six.text_type):
setup_py = setup_py.encode(sys.getfilesystemencoding())
return setup_py return setup_py
def run_egg_info(self, force_root_egg_info=False): def run_egg_info(self, force_root_egg_info=False):
...@@ -661,6 +665,9 @@ exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', ...@@ -661,6 +665,9 @@ exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n',
self.install_editable(install_options, global_options) self.install_editable(install_options, global_options)
return return
if self.is_wheel: if self.is_wheel:
version = pip.wheel.wheel_version(self.source_dir)
pip.wheel.check_compatibility(version, self.name)
self.move_wheel_files(self.source_dir, root=root) self.move_wheel_files(self.source_dir, root=root)
self.install_succeeded = True self.install_succeeded = True
return return
...@@ -931,12 +938,15 @@ class Requirements(object): ...@@ -931,12 +938,15 @@ class Requirements(object):
class RequirementSet(object): class RequirementSet(object):
def __init__(self, build_dir, src_dir, download_dir, download_cache=None, def __init__(self, build_dir, src_dir, download_dir, download_cache=None,
upgrade=False, ignore_installed=False, as_egg=False, target_dir=None, upgrade=False, ignore_installed=False, as_egg=False,
ignore_dependencies=False, force_reinstall=False, use_user_site=False, target_dir=None, ignore_dependencies=False,
session=None, pycompile=True): force_reinstall=False, use_user_site=False, session=None,
pycompile=True, wheel_download_dir=None):
self.build_dir = build_dir self.build_dir = build_dir
self.src_dir = src_dir self.src_dir = src_dir
self.download_dir = download_dir self.download_dir = download_dir
if download_cache:
download_cache = os.path.expanduser(download_cache)
self.download_cache = download_cache self.download_cache = download_cache
self.upgrade = upgrade self.upgrade = upgrade
self.ignore_installed = ignore_installed self.ignore_installed = ignore_installed
...@@ -954,6 +964,7 @@ class RequirementSet(object): ...@@ -954,6 +964,7 @@ class RequirementSet(object):
self.target_dir = target_dir #set from --target option self.target_dir = target_dir #set from --target option
self.session = session or PipSession() self.session = session or PipSession()
self.pycompile = pycompile self.pycompile = pycompile
self.wheel_download_dir = wheel_download_dir
def __str__(self): def __str__(self):
reqs = [req for req in self.requirements.values() reqs = [req for req in self.requirements.values()
...@@ -1170,11 +1181,26 @@ class RequirementSet(object): ...@@ -1170,11 +1181,26 @@ class RequirementSet(object):
assert url assert url
if url: if url:
try: try:
self.unpack_url(url, location, self.is_download)
except HTTPError: if (
e = sys.exc_info()[1] url.filename.endswith(wheel_ext)
logger.fatal('Could not install requirement %s because of error %s' and self.wheel_download_dir
% (req_to_install, e)) ):
# when doing 'pip wheel`
download_dir = self.wheel_download_dir
do_download = True
else:
download_dir = self.download_dir
do_download = self.is_download
self.unpack_url(
url, location, download_dir,
do_download,
)
except HTTPError as exc:
logger.fatal(
'Could not install requirement %s because '
'of error %s' % (req_to_install, exc)
)
raise InstallationError( raise InstallationError(
'Could not install requirement %s because of HTTP error %s for URL %s' 'Could not install requirement %s because of HTTP error %s for URL %s'
% (req_to_install, e, url)) % (req_to_install, e, url))
...@@ -1182,7 +1208,7 @@ class RequirementSet(object): ...@@ -1182,7 +1208,7 @@ class RequirementSet(object):
unpack = False unpack = False
if unpack: if unpack:
is_bundle = req_to_install.is_bundle is_bundle = req_to_install.is_bundle
is_wheel = url and url.filename.endswith('.whl') is_wheel = url and url.filename.endswith(wheel_ext)
if is_bundle: if is_bundle:
req_to_install.move_bundle_files(self.build_dir, self.src_dir) req_to_install.move_bundle_files(self.build_dir, self.src_dir)
for subreq in req_to_install.bundle_requirements(): for subreq in req_to_install.bundle_requirements():
...@@ -1198,18 +1224,6 @@ class RequirementSet(object): ...@@ -1198,18 +1224,6 @@ class RequirementSet(object):
elif is_wheel: elif is_wheel:
req_to_install.source_dir = location req_to_install.source_dir = location
req_to_install.url = url.url req_to_install.url = url.url
dist = list(pkg_resources.find_distributions(location))[0]
if not req_to_install.req:
req_to_install.req = dist.as_requirement()
self.add_requirement(req_to_install)
if not self.ignore_dependencies:
for subreq in dist.requires(req_to_install.extras):
if self.has_requirement(subreq.project_name):
continue
subreq = InstallRequirement(str(subreq),
req_to_install)
reqs.append(subreq)
self.add_requirement(subreq)
else: else:
req_to_install.source_dir = location req_to_install.source_dir = location
req_to_install.run_egg_info() req_to_install.run_egg_info()
...@@ -1233,8 +1247,32 @@ class RequirementSet(object): ...@@ -1233,8 +1247,32 @@ class RequirementSet(object):
req_to_install.conflicts_with = req_to_install.satisfied_by req_to_install.conflicts_with = req_to_install.satisfied_by
req_to_install.satisfied_by = None req_to_install.satisfied_by = None
else: else:
logger.notify(
'Requirement already satisfied (use '
'--upgrade to upgrade): %s' %
req_to_install
)
install = False install = False
if not (is_bundle or is_wheel): if is_wheel:
dist = list(
pkg_resources.find_distributions(location)
)[0]
if not req_to_install.req:
req_to_install.req = dist.as_requirement()
self.add_requirement(req_to_install)
if not self.ignore_dependencies:
for subreq in dist.requires(
req_to_install.extras):
if self.has_requirement(
subreq.project_name):
continue
subreq = InstallRequirement(str(subreq),
req_to_install)
reqs.append(subreq)
self.add_requirement(subreq)
# sdists
elif not is_bundle:
## FIXME: shouldn't be globally added: ## FIXME: shouldn't be globally added:
finder.add_dependency_links(req_to_install.dependency_links) finder.add_dependency_links(req_to_install.dependency_links)
if (req_to_install.extras): if (req_to_install.extras):
...@@ -1257,9 +1295,13 @@ class RequirementSet(object): ...@@ -1257,9 +1295,13 @@ class RequirementSet(object):
if not self.has_requirement(req_to_install.name): if not self.has_requirement(req_to_install.name):
#'unnamed' requirements will get added here #'unnamed' requirements will get added here
self.add_requirement(req_to_install) self.add_requirement(req_to_install)
if self.is_download or req_to_install._temp_build_dir is not None:
self.reqs_to_cleanup.append(req_to_install) # cleanup tmp src
else: if not is_bundle:
if (
self.is_download or
req_to_install._temp_build_dir is not None
):
self.reqs_to_cleanup.append(req_to_install) self.reqs_to_cleanup.append(req_to_install)
if install: if install:
...@@ -1304,23 +1346,36 @@ class RequirementSet(object): ...@@ -1304,23 +1346,36 @@ class RequirementSet(object):
call_subprocess(["python", "%s/setup.py" % dest, "clean"], cwd=dest, call_subprocess(["python", "%s/setup.py" % dest, "clean"], cwd=dest,
command_desc='python setup.py clean') command_desc='python setup.py clean')
def unpack_url(self, link, location, only_download=False): def unpack_url(self, link, location, download_dir=None,
only_download=False):
if download_dir is None:
download_dir = self.download_dir
# non-editable vcs urls
if is_vcs_url(link):
if only_download: if only_download:
loc = self.download_dir loc = download_dir
else: else:
loc = location loc = location
if is_vcs_url(link): unpack_vcs_link(link, loc, only_download)
return unpack_vcs_link(link, loc, only_download)
# a local file:// index could have links with hashes # file urls
elif not link.hash and is_file_url(link): elif is_file_url(link):
return unpack_file_url(link, loc) unpack_file_url(link, location, download_dir)
if only_download:
write_delete_marker_file(location)
# http urls
else: else:
if self.download_cache: unpack_http_url(
self.download_cache = os.path.expanduser(self.download_cache) link,
retval = unpack_http_url(link, location, self.download_cache, self.download_dir, self.session) location,
self.download_cache,
download_dir,
self.session,
)
if only_download: if only_download:
write_delete_marker_file(location) write_delete_marker_file(location)
return retval
def install(self, install_options, global_options=(), *args, **kwargs): def install(self, install_options, global_options=(), *args, **kwargs):
"""Install everything in this set (after having downloaded and unpacked the packages)""" """Install everything in this set (after having downloaded and unpacked the packages)"""
......
...@@ -13,18 +13,23 @@ import shutil ...@@ -13,18 +13,23 @@ import shutil
import sys import sys
from base64 import urlsafe_b64encode from base64 import urlsafe_b64encode
from email.parser import Parser
from pip.backwardcompat import ConfigParser, StringIO from pip.backwardcompat import ConfigParser, StringIO
from pip.exceptions import InvalidWheelFilename from pip.exceptions import InvalidWheelFilename, UnsupportedWheel
from pip.locations import distutils_scheme from pip.locations import distutils_scheme
from pip.log import logger from pip.log import logger
from pip import pep425tags from pip import pep425tags
from pip.util import call_subprocess, normalize_path, make_path_relative from pip.util import call_subprocess, normalize_path, make_path_relative
from pip._vendor import pkg_resources from pip._vendor import pkg_resources
from pip._vendor.distlib.scripts import ScriptMaker from pip._vendor.distlib.scripts import ScriptMaker
from pip._vendor import pkg_resources
wheel_ext = '.whl' wheel_ext = '.whl'
VERSION_COMPATIBLE = (1, 0)
def rehash(path, algo='sha256', blocksize=1<<20): def rehash(path, algo='sha256', blocksize=1<<20):
"""Return (hash, length) for path using hashlib.new(algo)""" """Return (hash, length) for path using hashlib.new(algo)"""
...@@ -388,6 +393,52 @@ def uninstallation_paths(dist): ...@@ -388,6 +393,52 @@ def uninstallation_paths(dist):
yield path yield path
def wheel_version(source_dir):
"""
Return the Wheel-Version of an extracted wheel, if possible.
Otherwise, return False if we couldn't parse / extract it.
"""
try:
dist = [d for d in pkg_resources.find_on_path(None, source_dir)][0]
wheel_data = dist.get_metadata('WHEEL')
wheel_data = Parser().parsestr(wheel_data)
version = wheel_data['Wheel-Version'].strip()
version = tuple(map(int, version.split('.')))
return version
except:
return False
def check_compatibility(version, name):
"""
Raises errors or warns if called with an incompatible Wheel-Version.
Pip should refuse to install a Wheel-Version that's a major series
ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when
installing a version only minor version ahead (e.g 1.2 > 1.1).
version: a 2-tuple representing a Wheel-Version (Major, Minor)
name: name of wheel or package to raise exception about
:raises UnsupportedWheel: when an incompatible Wheel-Version is given
"""
if not version:
raise UnsupportedWheel(
"%s is in an unsupported or invalid wheel" % name
)
if version[0] > VERSION_COMPATIBLE[0]:
raise UnsupportedWheel(
"%s's Wheel-Version (%s) is not compatible with this version "
"of pip" % (name, '.'.join(map(str, version)))
)
elif version > VERSION_COMPATIBLE:
logger.warn('Installing from a newer Wheel-Version (%s)'
% '.'.join(map(str, version)))
class Wheel(object): class Wheel(object):
"""A wheel file""" """A wheel file"""
...@@ -475,18 +526,19 @@ class WheelBuilder(object): ...@@ -475,18 +526,19 @@ class WheelBuilder(object):
reqset = self.requirement_set.requirements.values() reqset = self.requirement_set.requirements.values()
#make the wheelhouse buildset = [req for req in reqset if not req.is_wheel]
if not os.path.exists(self.wheel_dir):
os.makedirs(self.wheel_dir) if not buildset:
return
#build the wheels #build the wheels
logger.notify('Building wheels for collected packages: %s' % ', '.join([req.name for req in reqset])) logger.notify(
'Building wheels for collected packages: %s' %
','.join([req.name for req in buildset])
)
logger.indent += 2 logger.indent += 2
build_success, build_failure = [], [] build_success, build_failure = [], []
for req in reqset: for req in buildset:
if req.is_wheel:
logger.notify("Skipping building wheel: %s", req.url)
continue
if self._build_one(req): if self._build_one(req):
build_success.append(req) build_success.append(req)
else: else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment