Skip to content

Commit 499f45d

Browse files
committed
Merge pull request #985 from pypa/ignore-external-and-unsafe-urls
Ignore external and unsafe urls aka PEP438
2 parents 5544cd8 + a134137 commit 499f45d

File tree

8 files changed

+466
-16
lines changed

8 files changed

+466
-16
lines changed

docs/logic.rst

+27
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,33 @@ installing pre-releases and development releases.
8181

8282
.. _PEP426: http://www.python.org/dev/peps/pep-0426
8383

84+
.. _`Externally Hosted Files`:
85+
86+
Externally Hosted Files
87+
=======================
88+
89+
Starting with v1.4, pip will warn about installing any file that does not come
90+
from the primary index. In future versions pip will default to ignoring these
91+
files unless asked to consider them.
92+
93+
The ``pip install`` command supports a
94+
:ref:`--allow-external PROJECT <--allow-external>` option that will enable
95+
installing links that are linked directly from the simple index but to an
96+
external host that also have a supported hash fragment. Externally hosted
97+
files for all projects may be enabled using the
98+
:ref:`--allow-all-external <--allow-all-external>` flag to the ``pip install``
99+
command.
100+
101+
The ``pip install`` command also supports a
102+
:ref:`--allow-insecure PROJECT <--allow-insecure>` option that will enable
103+
installing insecurely linked files. These are either directly linked (as above)
104+
files without a hash, or files that are linked from either the home page or the
105+
download url of a package.
106+
107+
In order to get the future behavior in v1.4 the ``pip install`` command
108+
supports a :ref:`--no-allow-external <--no-allow-external>` and
109+
:ref:`--no-allow-insecure <--no-allow-external>` flags.
110+
84111
.. _`VCS Support`:
85112

86113
VCS Support

pip/cmdoptions.py

+48-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,48 @@ def make_option_group(group, parser):
6363
default=[],
6464
help='Specific mirror URLs to query when --use-mirrors is used.')
6565

66+
allow_external = make_option(
67+
"--allow-external",
68+
dest="allow_external",
69+
action="append",
70+
default=[],
71+
metavar="PACKAGE",
72+
help="Allow the installation of externally hosted files",
73+
)
74+
75+
allow_all_external = make_option(
76+
"--allow-all-external",
77+
dest="allow_all_external",
78+
action="store_true",
79+
default=True, # TODO: Change to False after 1.4 has been released
80+
help="Allow the installation of all externally hosted files",
81+
)
82+
83+
# TODO: NOOP after 1.4 has been released
84+
no_allow_external = make_option(
85+
"--no-allow-external",
86+
dest="allow_all_external",
87+
action="store_false",
88+
help="Disallow the installation of all externally hosted files",
89+
)
90+
91+
allow_unsafe = make_option(
92+
"--allow-insecure",
93+
dest="allow_insecure",
94+
action="append",
95+
default=[],
96+
metavar="PACKAGE",
97+
help="Allow the installation of insecure and unverifiable files",
98+
)
99+
100+
no_allow_unsafe = make_option(
101+
"--no-allow-insecure",
102+
dest="allow_all_insecure",
103+
action="store_false",
104+
default=True,
105+
help="Disallow the installation of insecure and unverifiable files"
106+
)
107+
66108
requirements = make_option(
67109
'-r', '--requirement',
68110
dest='requirements',
@@ -138,6 +180,11 @@ def make_option_group(group, parser):
138180
no_index,
139181
find_links,
140182
use_mirrors,
141-
mirrors
183+
mirrors,
184+
allow_external,
185+
allow_all_external,
186+
no_allow_external,
187+
allow_unsafe,
188+
no_allow_unsafe,
142189
]
143190
}

pip/commands/install.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ def _build_package_finder(self, options, index_urls):
162162
index_urls=index_urls,
163163
use_mirrors=options.use_mirrors,
164164
mirrors=options.mirrors,
165-
use_wheel=options.use_wheel)
165+
use_wheel=options.use_wheel,
166+
allow_external=options.allow_external,
167+
allow_insecure=options.allow_insecure,
168+
allow_all_external=options.allow_all_external,
169+
allow_all_insecure=options.allow_all_insecure,
170+
)
166171

167172
def run(self, options, args):
168173
if options.download_dir:

0 commit comments

Comments
 (0)