diff --git a/CHANGES.txt b/CHANGES.txt index fac313222..8354fb6a6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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)** diff --git a/pip/cmdoptions.py b/pip/cmdoptions.py index 5ca95d659..f71488cdf 100644 --- a/pip/cmdoptions.py +++ b/pip/cmdoptions.py @@ -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', diff --git a/pip/commands/install.py b/pip/commands/install.py index 9a90e6f0a..d957f407d 100644 --- a/pip/commands/install.py +++ b/pip/commands/install.py @@ -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, diff --git a/pip/commands/wheel.py b/pip/commands/wheel.py index 3ad32459c..70e95eb8e 100644 --- a/pip/commands/wheel.py +++ b/pip/commands/wheel.py @@ -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, diff --git a/pip/req/req_set.py b/pip/req/req_set.py index 90d6c175f..e2b78d4ac 100644 --- a/pip/req/req_set.py +++ b/pip/req/req_set.py @@ -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):