Skip to content

Commit

Permalink
Add --ignore-requires-python escape hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
xavfernandez committed Oct 27, 2016
1 parent 11cc379 commit 2df0ea9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
* Normalize package names before using in ``pip show`` (:issue:`3976`)

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


**8.1.2 (2016-05-10)**
Expand Down
7 changes: 7 additions & 0 deletions pip/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,13 @@ def only_binary():
help='Directory to unpack packages into and build in.'
)

ignore_requires_python = partial(
Option,
'--ignore-requires-python',
dest='ignore_requires_python',
action='store_true',
help='Ignore the Requires-Python information.')

install_options = partial(
Option,
'--install-option',
Expand Down
2 changes: 2 additions & 0 deletions pip/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def __init__(self, *args, **kw):
action='store_true',
help='Ignore the installed packages (reinstalling instead).')

cmd_opts.add_option(cmdoptions.ignore_requires_python())
cmd_opts.add_option(cmdoptions.no_deps())

cmd_opts.add_option(cmdoptions.install_options())
Expand Down Expand Up @@ -295,6 +296,7 @@ def run(self, options, args):
as_egg=options.as_egg,
ignore_installed=options.ignore_installed,
ignore_dependencies=options.ignore_dependencies,
ignore_requires_python=options.ignore_requires_python,
force_reinstall=options.force_reinstall,
use_user_site=options.use_user_site,
target_dir=temp_target_dir,
Expand Down
2 changes: 2 additions & 0 deletions pip/commands/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(self, *args, **kw):
cmd_opts.add_option(cmdoptions.editable())
cmd_opts.add_option(cmdoptions.requirements())
cmd_opts.add_option(cmdoptions.src())
cmd_opts.add_option(cmdoptions.ignore_requires_python())
cmd_opts.add_option(cmdoptions.no_deps())
cmd_opts.add_option(cmdoptions.build_dir())

Expand Down Expand Up @@ -171,6 +172,7 @@ def run(self, options, args):
download_dir=None,
ignore_dependencies=options.ignore_dependencies,
ignore_installed=True,
ignore_requires_python=options.ignore_requires_python,
isolated=options.isolated_mode,
session=session,
wheel_cache=wheel_cache,
Expand Down
15 changes: 12 additions & 3 deletions pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from pip.exceptions import (InstallationError, BestVersionAlreadyInstalled,
DistributionNotFound, PreviousBuildDirError,
HashError, HashErrors, HashUnpinned,
DirectoryUrlHashUnsupported, VcsHashUnsupported)
DirectoryUrlHashUnsupported, VcsHashUnsupported,
UnsupportedPythonVersion)
from pip.req.req_install import InstallRequirement
from pip.utils import (
display_path, dist_in_usersite, ensure_dir, normalize_path)
Expand Down Expand Up @@ -145,7 +146,8 @@ def __init__(self, build_dir, src_dir, download_dir, upgrade=False,
target_dir=None, ignore_dependencies=False,
force_reinstall=False, use_user_site=False, session=None,
pycompile=True, isolated=False, wheel_download_dir=None,
wheel_cache=None, require_hashes=False):
wheel_cache=None, require_hashes=False,
ignore_requires_python=False):
"""Create a RequirementSet.
:param wheel_download_dir: Where still-packed .whl files should be
Expand Down Expand Up @@ -179,6 +181,7 @@ def __init__(self, build_dir, src_dir, download_dir, upgrade=False,
self.requirement_aliases = {}
self.unnamed_requirements = []
self.ignore_dependencies = ignore_dependencies
self.ignore_requires_python = ignore_requires_python
self.successfully_downloaded = []
self.successfully_installed = []
self.reqs_to_cleanup = []
Expand Down Expand Up @@ -656,7 +659,13 @@ def _prepare_file(self,
# # parse dependencies # #
# ###################### #
dist = abstract_dist.dist(finder)
check_dist_requires_python(dist)
try:
check_dist_requires_python(dist)
except UnsupportedPythonVersion as e:
if self.ignore_requires_python:
logger.warning(e.args[0])
else:
raise
more_reqs = []

def add_req(subreq):
Expand Down

0 comments on commit 2df0ea9

Please sign in to comment.