~ubuntu-branches/debian/jessie/python-pip/jessie

« back to all changes in this revision

Viewing changes to docs/logic.txt

  • Committer: Package Import Robot
  • Author(s): Barry Warsaw
  • Date: 2013-08-19 18:33:23 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20130819183323-8xyoldb2798iil6e
Tags: 1.4.1-1
* Team upload.
* New upstream release.
  - d/control: Update Standards-Version to 3.9.4 with no additional
    changes required.
  - d/patches/no-python-specific-scripts.patch: Refreshed.
  - d/patches/format_egg_string.patch: Refreshed.
  - d/patches/system-ca-certificates.patch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.. _`pip logic`:
2
 
 
3
 
================
4
 
Internal Details
5
 
================
6
 
 
7
 
.. _`Requirements File Format`:
8
 
 
9
 
Requirements File Format
10
 
========================
11
 
 
12
 
Each line of the requirements file indicates something to be installed,
13
 
and like arguments to :ref:`pip install`, the following forms are supported::
14
 
 
15
 
    <requirement specifier>
16
 
    <archive url/path>
17
 
    [-e] <local project path>
18
 
    [-e] <vcs project url>
19
 
 
20
 
See the :ref:`pip install Examples<pip install Examples>` for examples of all these forms.
21
 
 
22
 
A line beginning with ``#`` is treated as a comment and ignored.
23
 
 
24
 
Additionally, the following :ref:`Package Index Options <Package Index Options>` are supported
25
 
 
26
 
  *  :ref:`-i, --index-url <--index-url>`
27
 
  *  :ref:`--extra-index-url <--extra-index-url>`
28
 
  *  :ref:`--no-index <--no-index>`
29
 
  *  :ref:`-f, --find-links <--find-links>`
30
 
 
31
 
For example, to specify :ref:`--no-index <--no-index>` and 2 :ref:`--find-links <--find-links>` locations:
32
 
 
33
 
::
34
 
 
35
 
--no-index
36
 
--find-links /my/local/archives
37
 
--find-links http://some.archives.com/archives
38
 
 
39
 
 
40
 
Lastly, if you wish, you can refer to other requirements files, like this::
41
 
 
42
 
    -r more_requirements.txt
43
 
 
44
 
.. _`Requirement Specifiers`:
45
 
 
46
 
Requirement Specifiers
47
 
======================
48
 
 
49
 
pip supports installing from "requirement specifiers" as implemented in
50
 
`pkg_resources Requirements <http://packages.python.org/distribute/pkg_resources.html#requirement-objects>`_
51
 
 
52
 
Some Examples::
53
 
 
54
 
  FooProject >= 1.2
55
 
  Fizzy [foo, bar]
56
 
  PickyThing<1.6,>1.9,!=1.9.6,<2.0a0,==2.4c1
57
 
  SomethingWhoseVersionIDontCareAbout
58
 
 
59
 
 
60
 
.. _`VCS Support`:
61
 
 
62
 
VCS Support
63
 
===========
64
 
 
65
 
pip supports installing from Git, Mercurial, Subversion and Bazaar, and detects the type of VCS using url prefixes: "git+", "hg+", "bzr+", "svn+".
66
 
 
67
 
pip requires a working VCS command on your path: git, hg, svn, or bzr.
68
 
 
69
 
VCS projects can be installed in :ref:`editable mode <editable-installs>` (using the :ref:`--editable <install_--editable>` option) or not.
70
 
 
71
 
* For editable installs, the clone location by default is "<venv path>/src/SomeProject" in virtual environments, and "<cwd>/src/SomeProject" for global installs.
72
 
  The :ref:`--src <install_--src>` option can be used to modify this location.
73
 
* For non-editable installs, the project is built locally in a temp dir and then installed normally.
74
 
 
75
 
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.
76
 
 
77
 
Git
78
 
~~~
79
 
 
80
 
pip currently supports cloning over ``git``, ``git+http`` and ``git+ssh``::
81
 
 
82
 
    git+git://git.myproject.org/MyProject#egg=MyProject
83
 
    git+http://git.myproject.org/MyProject#egg=MyProject
84
 
    git+ssh://git.myproject.org/MyProject#egg=MyProject
85
 
 
86
 
Passing branch names, a commit hash or a tag name is also possible::
87
 
 
88
 
    git://git.myproject.org/MyProject.git@master#egg=MyProject
89
 
    git://git.myproject.org/MyProject.git@v1.0#egg=MyProject
90
 
    git://git.myproject.org/MyProject.git@da39a3ee5e6b4b0d3255bfef95601890afd80709#egg=MyProject
91
 
 
92
 
Mercurial
93
 
~~~~~~~~~
94
 
 
95
 
The supported schemes are: ``hg+http``, ``hg+https``,
96
 
``hg+static-http`` and ``hg+ssh``::
97
 
 
98
 
    hg+http://hg.myproject.org/MyProject#egg=MyProject
99
 
    hg+https://hg.myproject.org/MyProject#egg=MyProject
100
 
    hg+ssh://hg.myproject.org/MyProject#egg=MyProject
101
 
 
102
 
You can also specify a revision number, a revision hash, a tag name or a local
103
 
branch name::
104
 
 
105
 
    hg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject
106
 
    hg+http://hg.myproject.org/MyProject@2019#egg=MyProject
107
 
    hg+http://hg.myproject.org/MyProject@v1.0#egg=MyProject
108
 
    hg+http://hg.myproject.org/MyProject@special_feature#egg=MyProject
109
 
 
110
 
Subversion
111
 
~~~~~~~~~~
112
 
 
113
 
pip supports the URL schemes ``svn``, ``svn+svn``, ``svn+http``, ``svn+https``, ``svn+ssh``.
114
 
You can also give specific revisions to an SVN URL, like::
115
 
 
116
 
    svn+svn://svn.myproject.org/svn/MyProject#egg=MyProject
117
 
    svn+http://svn.myproject.org/svn/MyProject/trunk@2019#egg=MyProject
118
 
 
119
 
which will check out revision 2019.  ``@{20080101}`` would also check
120
 
out the revision from 2008-01-01. You can only check out specific
121
 
revisions using ``-e svn+...``.
122
 
 
123
 
Bazaar
124
 
~~~~~~
125
 
 
126
 
pip supports Bazaar using the ``bzr+http``, ``bzr+https``, ``bzr+ssh``,
127
 
``bzr+sftp``, ``bzr+ftp`` and ``bzr+lp`` schemes::
128
 
 
129
 
    bzr+http://bzr.myproject.org/MyProject/trunk#egg=MyProject
130
 
    bzr+sftp://user@myproject.org/MyProject/trunk#egg=MyProject
131
 
    bzr+ssh://user@myproject.org/MyProject/trunk#egg=MyProject
132
 
    bzr+ftp://user@myproject.org/MyProject/trunk#egg=MyProject
133
 
    bzr+lp:MyProject#egg=MyProject
134
 
 
135
 
Tags or revisions can be installed like this::
136
 
 
137
 
    bzr+https://bzr.myproject.org/MyProject/trunk@2019#egg=MyProject
138
 
    bzr+http://bzr.myproject.org/MyProject/trunk@v1.0#egg=MyProject
139
 
 
140
 
 
141
 
Finding Packages
142
 
================
143
 
 
144
 
pip searches for packages on `PyPI <http://pypi.python.org>`_ using the
145
 
`http simple interface <http://pypi.python.org/simple>`_,
146
 
which is documented `here <http://packages.python.org/distribute/easy_install.html#package-index-api>`_
147
 
and `there <http://www.python.org/dev/peps/pep-0301/>`_
148
 
 
149
 
pip offers a set of :ref:`Package Index Options <Package Index Options>` for modifying how packages are found.
150
 
 
151
 
See the :ref:`pip install Examples<pip install Examples>`.
152
 
 
153
 
 
154
 
.. _`SSL Certificate Verification`:
155
 
 
156
 
SSL Certificate Verification
157
 
============================
158
 
 
159
 
Starting with v1.3, pip provides SSL certificate verification over https, for the purpose
160
 
of providing secure, certified downloads from PyPI.
161
 
 
162
 
This is supported by default in all Python versions pip supports, except Python 2.5.
163
 
 
164
 
Python 2.5 users can :ref:`install an SSL backport <SSL Backport>`, which provides ssl support for older pythons.
165
 
Pip does not try to install this automatically because it requires a compiler, which not all systems will have.
166
 
 
167
 
Although not recommended, Python 2.5 users who are unable to install ssl, can use the global option,
168
 
``--insecure``, to allow access to PyPI w/o attempting SSL certificate verification. This option will only be visible
169
 
when ssl is not importable.  This is *not* a general option.
170
 
 
171
 
 
172
 
.. _`SSL Backport`:
173
 
 
174
 
Installing the SSL Backport
175
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~
176
 
 
177
 
.. warning::
178
 
 
179
 
    We advise against using ``pip`` itself to install the ssl backport, because it won't be secure
180
 
    until *after* installing ssl.  Likewise, `easy_install <http://pythonhosted.org/distribute/easy_install.html>`_ is not advised, because it
181
 
    does not currently support ssl.
182
 
 
183
 
 
184
 
1. Download the ssl archive:
185
 
 
186
 
  * Using a Browser:
187
 
 
188
 
    1. Go to `this url <https://pypi.python.org/pypi/ssl/1.15>`_.
189
 
    2. Confirm the identity of the site is valid.
190
 
       Most browsers provide this information to the left of the URL bar in the form of padlock icon that you can click on to confirm the site is verified.
191
 
    3. Scroll down, and click to download ``ssl-1.15.tar.gz``.
192
 
 
193
 
  * Using curl, which supports ssl certificate verification:
194
 
     ::
195
 
 
196
 
      $ curl -O https://pypi.python.org/packages/source/s/ssl/ssl-1.15.tar.gz
197
 
 
198
 
2. Confirm the md5sum:
199
 
   ::
200
 
     $ md5sum ssl-1.15.tar.gz
201
 
     81ea8a1175e437b4c769ae65b3290e0c  ssl-1.15.tar.gz
202
 
 
203
 
3. Unpack the archive, and change into the ``ssl-1.15`` directory.
204
 
4. Run: ``python setup.py install``.
205
 
 
206
 
 
207
 
Hash Verification
208
 
=================
209
 
 
210
 
PyPI provides md5 hashes in the hash fragment of package download urls.
211
 
 
212
 
pip supports checking this, as well as any of the
213
 
guaranteed hashlib algorithms (sha1, sha224, sha384, sha256, sha512, md5).
214
 
 
215
 
The hash fragment is case sensitive (i.e. sha1 not SHA1).
216
 
 
217
 
This check is only intended to provide basic download corruption protection.
218
 
It is not intended to provide security against tampering. For that,
219
 
see :ref:`SSL Certificate Verification`
220
 
 
221
 
 
222
 
Download Cache
223
 
==============
224
 
 
225
 
pip offers a :ref:`--download-cache <install_--download-cache>` option for installs to prevent redundant downloads of archives from PyPI.
226
 
 
227
 
The point of this cache is *not* to circumvent the index crawling process, but to *just* prevent redundant downloads.
228
 
 
229
 
Items are stored in this cache based on the url the archive was found at, not simply the archive name.
230
 
 
231
 
If you want a fast/local install solution that circumvents crawling PyPI, see the :ref:`Fast & Local Installs` Cookbook entry.
232
 
 
233
 
Like all options, :ref:`--download-cache <install_--download-cache>`, can also be set as an environment variable, or placed into the pip config file.
234
 
See the :ref:`Configuration` section.
235
 
 
236
 
 
237
 
.. _`editable-installs`:
238
 
 
239
 
"Editable" Installs
240
 
===================
241
 
 
242
 
"Editable" installs are fundamentally `"setuptools develop mode" <http://packages.python.org/distribute/setuptools.html#development-mode>`_ installs.
243
 
 
244
 
You can install local projects or VCS projects in "editable" mode::
245
 
 
246
 
$ pip install -e path/to/SomeProject
247
 
$ pip install -e git+http://repo/my_project.git#egg=SomeProject
248
 
 
249
 
For local projects, the "SomeProject.egg-info" directory is created relative to the project path.
250
 
This is one advantage over just using ``setup.py develop``, which creates the "egg-info" directly relative the current working directory.
251
 
 
252
 
 
253
 
setuptools & pkg_resources
254
 
==========================
255
 
 
256
 
Internally, pip uses the `setuptools` package, and the `pkg_resources` module, which are available from the project, `Setuptools`_, or it's fork `Distribute`_.
257
 
 
258
 
pip can work with either `Setuptools`_ or `Distribute`_, although for Python 3, `Distribute`_ is required.
259
 
 
260
 
Here are some examples of how pip uses `setuptools` and `pkg_resources`:
261
 
 
262
 
* The core of pip's install process uses the `setuptools`'s "install" command.
263
 
* Editable ("-e") installs use the `setuptools`'s "develop" command.
264
 
* pip uses `pkg_resources` for version parsing, for detecting version conflicts, and to determine what projects are installed,
265
 
 
266
 
 
267
 
.. _Setuptools: http://pypi.python.org/pypi/setuptools/0.6c11
268
 
.. _Distribute: http://pypi.python.org/pypi/distribute/