Skip to content

Commit 2df0ea9

Browse files
committed
Add --ignore-requires-python escape hatch
1 parent 11cc379 commit 2df0ea9

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
* Normalize package names before using in ``pip show`` (:issue:`3976`)
5454

5555
* Raises when Requires-Python do not match the running version.
56+
Add ``--ignore-requires-python`` escape hatch.
5657

5758

5859
**8.1.2 (2016-05-10)**

pip/cmdoptions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,13 @@ def only_binary():
477477
help='Directory to unpack packages into and build in.'
478478
)
479479

480+
ignore_requires_python = partial(
481+
Option,
482+
'--ignore-requires-python',
483+
dest='ignore_requires_python',
484+
action='store_true',
485+
help='Ignore the Requires-Python information.')
486+
480487
install_options = partial(
481488
Option,
482489
'--install-option',

pip/commands/install.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def __init__(self, *args, **kw):
118118
action='store_true',
119119
help='Ignore the installed packages (reinstalling instead).')
120120

121+
cmd_opts.add_option(cmdoptions.ignore_requires_python())
121122
cmd_opts.add_option(cmdoptions.no_deps())
122123

123124
cmd_opts.add_option(cmdoptions.install_options())
@@ -295,6 +296,7 @@ def run(self, options, args):
295296
as_egg=options.as_egg,
296297
ignore_installed=options.ignore_installed,
297298
ignore_dependencies=options.ignore_dependencies,
299+
ignore_requires_python=options.ignore_requires_python,
298300
force_reinstall=options.force_reinstall,
299301
use_user_site=options.use_user_site,
300302
target_dir=temp_target_dir,

pip/commands/wheel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(self, *args, **kw):
7070
cmd_opts.add_option(cmdoptions.editable())
7171
cmd_opts.add_option(cmdoptions.requirements())
7272
cmd_opts.add_option(cmdoptions.src())
73+
cmd_opts.add_option(cmdoptions.ignore_requires_python())
7374
cmd_opts.add_option(cmdoptions.no_deps())
7475
cmd_opts.add_option(cmdoptions.build_dir())
7576

@@ -171,6 +172,7 @@ def run(self, options, args):
171172
download_dir=None,
172173
ignore_dependencies=options.ignore_dependencies,
173174
ignore_installed=True,
175+
ignore_requires_python=options.ignore_requires_python,
174176
isolated=options.isolated_mode,
175177
session=session,
176178
wheel_cache=wheel_cache,

pip/req/req_set.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
from pip.exceptions import (InstallationError, BestVersionAlreadyInstalled,
1515
DistributionNotFound, PreviousBuildDirError,
1616
HashError, HashErrors, HashUnpinned,
17-
DirectoryUrlHashUnsupported, VcsHashUnsupported)
17+
DirectoryUrlHashUnsupported, VcsHashUnsupported,
18+
UnsupportedPythonVersion)
1819
from pip.req.req_install import InstallRequirement
1920
from pip.utils import (
2021
display_path, dist_in_usersite, ensure_dir, normalize_path)
@@ -145,7 +146,8 @@ def __init__(self, build_dir, src_dir, download_dir, upgrade=False,
145146
target_dir=None, ignore_dependencies=False,
146147
force_reinstall=False, use_user_site=False, session=None,
147148
pycompile=True, isolated=False, wheel_download_dir=None,
148-
wheel_cache=None, require_hashes=False):
149+
wheel_cache=None, require_hashes=False,
150+
ignore_requires_python=False):
149151
"""Create a RequirementSet.
150152
151153
:param wheel_download_dir: Where still-packed .whl files should be
@@ -179,6 +181,7 @@ def __init__(self, build_dir, src_dir, download_dir, upgrade=False,
179181
self.requirement_aliases = {}
180182
self.unnamed_requirements = []
181183
self.ignore_dependencies = ignore_dependencies
184+
self.ignore_requires_python = ignore_requires_python
182185
self.successfully_downloaded = []
183186
self.successfully_installed = []
184187
self.reqs_to_cleanup = []
@@ -656,7 +659,13 @@ def _prepare_file(self,
656659
# # parse dependencies # #
657660
# ###################### #
658661
dist = abstract_dist.dist(finder)
659-
check_dist_requires_python(dist)
662+
try:
663+
check_dist_requires_python(dist)
664+
except UnsupportedPythonVersion as e:
665+
if self.ignore_requires_python:
666+
logger.warning(e.args[0])
667+
else:
668+
raise
660669
more_reqs = []
661670

662671
def add_req(subreq):

0 commit comments

Comments
 (0)