Add --ignore-requires-python escape hatch

This commit is contained in:
Xavier Fernandez 2016-07-17 11:29:02 +02:00
parent 11cc37932c
commit 2df0ea9a26
5 changed files with 24 additions and 3 deletions

View File

@ -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)**

View File

@ -477,6 +477,13 @@ build_dir = partial(
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',

View File

@ -118,6 +118,7 @@ class InstallCommand(RequirementCommand):
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())
@ -295,6 +296,7 @@ class InstallCommand(RequirementCommand):
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,

View File

@ -70,6 +70,7 @@ class WheelCommand(RequirementCommand):
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())
@ -171,6 +172,7 @@ class WheelCommand(RequirementCommand):
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,

View File

@ -14,7 +14,8 @@ from pip.download import (is_file_url, is_dir_url, is_vcs_url, url_to_path,
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)
@ -145,7 +146,8 @@ class RequirementSet(object):
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
@ -179,6 +181,7 @@ class RequirementSet(object):
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 = []
@ -656,7 +659,13 @@ class RequirementSet(object):
# # 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):