mirror of https://github.com/pypa/pip
Merge branch 'refactor/reduce-action-at-distance' into resolver/warn-after-resolution
This commit is contained in:
commit
851518b17a
|
@ -0,0 +1 @@
|
|||
Use log level `info` instead of `warning` when ignoring packages due to environment markers.
|
|
@ -0,0 +1 @@
|
|||
Run 'setup.py develop' inside pep518 build environment.
|
|
@ -1 +1 @@
|
|||
Upgraded distro to 1.0.4.
|
||||
Upgraded distro to 1.2.0.
|
||||
|
|
|
@ -114,14 +114,16 @@ class Command(object):
|
|||
def main(self, args):
|
||||
options, args = self.parse_args(args)
|
||||
|
||||
verbosity = options.verbose - options.quiet
|
||||
if verbosity >= 1:
|
||||
# Set verbosity so that it can be used elsewhere.
|
||||
self.verbosity = options.verbose - options.quiet
|
||||
|
||||
if self.verbosity >= 1:
|
||||
level = "DEBUG"
|
||||
elif verbosity == -1:
|
||||
elif self.verbosity == -1:
|
||||
level = "WARNING"
|
||||
elif verbosity == -2:
|
||||
elif self.verbosity == -2:
|
||||
level = "ERROR"
|
||||
elif verbosity <= -3:
|
||||
elif self.verbosity <= -3:
|
||||
level = "CRITICAL"
|
||||
else:
|
||||
level = "INFO"
|
||||
|
|
|
@ -361,7 +361,7 @@ class InstallCommand(RequirementCommand):
|
|||
message_parts.append("\n")
|
||||
|
||||
logger.error(
|
||||
"".join(message_parts), exc_info=(options.verbose > 1)
|
||||
"".join(message_parts), exc_info=(self.verbosity > 1)
|
||||
)
|
||||
return ERROR
|
||||
except PreviousBuildDirError:
|
||||
|
|
|
@ -65,7 +65,7 @@ class UninstallCommand(Command):
|
|||
)
|
||||
for req in reqs_to_uninstall.values():
|
||||
uninstall_pathset = req.uninstall(
|
||||
auto_confirm=options.yes, verbose=options.verbose != 0
|
||||
auto_confirm=options.yes, verbose=self.verbosity > 0,
|
||||
)
|
||||
if uninstall_pathset:
|
||||
uninstall_pathset.commit()
|
||||
|
|
|
@ -899,19 +899,20 @@ class InstallRequirement(object):
|
|||
|
||||
with indent_log():
|
||||
# FIXME: should we do --install-headers here too?
|
||||
call_subprocess(
|
||||
[
|
||||
sys.executable,
|
||||
'-c',
|
||||
SETUPTOOLS_SHIM % self.setup_py
|
||||
] +
|
||||
list(global_options) +
|
||||
['develop', '--no-deps'] +
|
||||
list(install_options),
|
||||
with self.build_env:
|
||||
call_subprocess(
|
||||
[
|
||||
sys.executable,
|
||||
'-c',
|
||||
SETUPTOOLS_SHIM % self.setup_py
|
||||
] +
|
||||
list(global_options) +
|
||||
['develop', '--no-deps'] +
|
||||
list(install_options),
|
||||
|
||||
cwd=self.setup_py_dir,
|
||||
show_stdout=False,
|
||||
)
|
||||
cwd=self.setup_py_dir,
|
||||
show_stdout=False,
|
||||
)
|
||||
|
||||
self.install_succeeded = True
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class RequirementSet(object):
|
|||
already be added. Note that None implies that this is a user
|
||||
supplied requirement, vs an inferred one.
|
||||
:param extras_requested: an iterable of extras used to evaluate the
|
||||
environement markers.
|
||||
environment markers.
|
||||
:return: Additional requirements to scan. That is either [] if
|
||||
the requirement is not applicable, or [install_req] if the
|
||||
requirement is applicable and has just been added.
|
||||
|
|
|
@ -38,9 +38,6 @@ import argparse
|
|||
import subprocess
|
||||
|
||||
|
||||
if not sys.platform.startswith('linux'):
|
||||
raise ImportError('Unsupported platform: {0}'.format(sys.platform))
|
||||
|
||||
_UNIXCONFDIR = os.environ.get('UNIXCONFDIR', '/etc')
|
||||
_OS_RELEASE_BASENAME = 'os-release'
|
||||
|
||||
|
@ -511,6 +508,21 @@ def distro_release_attr(attribute):
|
|||
return _distro.distro_release_attr(attribute)
|
||||
|
||||
|
||||
class cached_property(object):
|
||||
"""A version of @property which caches the value. On access, it calls the
|
||||
underlying function and sets the value in `__dict__` so future accesses
|
||||
will not re-call the property.
|
||||
"""
|
||||
def __init__(self, f):
|
||||
self._fname = f.__name__
|
||||
self._f = f
|
||||
|
||||
def __get__(self, obj, owner):
|
||||
assert obj is not None, 'call {} on an instance'.format(self._fname)
|
||||
ret = obj.__dict__[self._fname] = self._f(obj)
|
||||
return ret
|
||||
|
||||
|
||||
class LinuxDistribution(object):
|
||||
"""
|
||||
Provides information about a Linux distribution.
|
||||
|
@ -576,6 +588,9 @@ class LinuxDistribution(object):
|
|||
`distro release file`_ that is actually used as a data source. The
|
||||
empty string if no distro release file is used as a data source.
|
||||
|
||||
* ``include_lsb`` (bool): The result of the ``include_lsb`` parameter.
|
||||
This controls whether the lsb information will be loaded.
|
||||
|
||||
Raises:
|
||||
|
||||
* :py:exc:`IOError`: Some I/O issue with an os-release file or distro
|
||||
|
@ -591,26 +606,20 @@ class LinuxDistribution(object):
|
|||
self.os_release_file = os_release_file or \
|
||||
os.path.join(_UNIXCONFDIR, _OS_RELEASE_BASENAME)
|
||||
self.distro_release_file = distro_release_file or '' # updated later
|
||||
self._os_release_info = self._get_os_release_info()
|
||||
self._lsb_release_info = self._get_lsb_release_info() \
|
||||
if include_lsb else {}
|
||||
self._distro_release_info = self._get_distro_release_info()
|
||||
self.include_lsb = include_lsb
|
||||
|
||||
def __repr__(self):
|
||||
"""Return repr of all info
|
||||
"""
|
||||
return \
|
||||
"LinuxDistribution(" \
|
||||
"os_release_file={0!r}, " \
|
||||
"distro_release_file={1!r}, " \
|
||||
"_os_release_info={2!r}, " \
|
||||
"_lsb_release_info={3!r}, " \
|
||||
"_distro_release_info={4!r})".format(
|
||||
self.os_release_file,
|
||||
self.distro_release_file,
|
||||
self._os_release_info,
|
||||
self._lsb_release_info,
|
||||
self._distro_release_info)
|
||||
"os_release_file={self.os_release_file!r}, " \
|
||||
"distro_release_file={self.distro_release_file!r}, " \
|
||||
"include_lsb={self.include_lsb!r}, " \
|
||||
"_os_release_info={self._os_release_info!r}, " \
|
||||
"_lsb_release_info={self._lsb_release_info!r}, " \
|
||||
"_distro_release_info={self._distro_release_info!r})".format(
|
||||
self=self)
|
||||
|
||||
def linux_distribution(self, full_distribution_name=True):
|
||||
"""
|
||||
|
@ -835,7 +844,8 @@ class LinuxDistribution(object):
|
|||
"""
|
||||
return self._distro_release_info.get(attribute, '')
|
||||
|
||||
def _get_os_release_info(self):
|
||||
@cached_property
|
||||
def _os_release_info(self):
|
||||
"""
|
||||
Get the information items from the specified os-release file.
|
||||
|
||||
|
@ -907,34 +917,24 @@ class LinuxDistribution(object):
|
|||
pass
|
||||
return props
|
||||
|
||||
def _get_lsb_release_info(self):
|
||||
@cached_property
|
||||
def _lsb_release_info(self):
|
||||
"""
|
||||
Get the information items from the lsb_release command output.
|
||||
|
||||
Returns:
|
||||
A dictionary containing all information items.
|
||||
"""
|
||||
cmd = 'lsb_release -a'
|
||||
process = subprocess.Popen(
|
||||
cmd,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
stdout, stderr = stdout.decode('utf-8'), stderr.decode('utf-8')
|
||||
code = process.returncode
|
||||
if code == 0:
|
||||
content = stdout.splitlines()
|
||||
return self._parse_lsb_release_content(content)
|
||||
elif code == 127: # Command not found
|
||||
if not self.include_lsb:
|
||||
return {}
|
||||
else:
|
||||
if sys.version_info[:2] >= (3, 5):
|
||||
raise subprocess.CalledProcessError(code, cmd, stdout, stderr)
|
||||
elif sys.version_info[:2] >= (2, 7):
|
||||
raise subprocess.CalledProcessError(code, cmd, stdout)
|
||||
elif sys.version_info[:2] == (2, 6):
|
||||
raise subprocess.CalledProcessError(code, cmd)
|
||||
with open(os.devnull, 'w') as devnull:
|
||||
try:
|
||||
cmd = ('lsb_release', '-a')
|
||||
stdout = subprocess.check_output(cmd, stderr=devnull)
|
||||
except OSError: # Command not found
|
||||
return {}
|
||||
content = stdout.decode(sys.getfilesystemencoding()).splitlines()
|
||||
return self._parse_lsb_release_content(content)
|
||||
|
||||
@staticmethod
|
||||
def _parse_lsb_release_content(lines):
|
||||
|
@ -952,7 +952,6 @@ class LinuxDistribution(object):
|
|||
"""
|
||||
props = {}
|
||||
for line in lines:
|
||||
line = line.decode('utf-8') if isinstance(line, bytes) else line
|
||||
kv = line.strip('\n').split(':', 1)
|
||||
if len(kv) != 2:
|
||||
# Ignore lines without colon.
|
||||
|
@ -961,7 +960,8 @@ class LinuxDistribution(object):
|
|||
props.update({k.replace(' ', '_').lower(): v.strip()})
|
||||
return props
|
||||
|
||||
def _get_distro_release_info(self):
|
||||
@cached_property
|
||||
def _distro_release_info(self):
|
||||
"""
|
||||
Get the information items from the specified distro release file.
|
||||
|
||||
|
@ -1001,6 +1001,9 @@ class LinuxDistribution(object):
|
|||
'fedora-release',
|
||||
'gentoo-release',
|
||||
'mageia-release',
|
||||
'mandrake-release',
|
||||
'mandriva-release',
|
||||
'mandrivalinux-release',
|
||||
'manjaro-release',
|
||||
'oracle-release',
|
||||
'redhat-release',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
appdirs==1.4.3
|
||||
distlib==0.2.6
|
||||
distro==1.0.4
|
||||
distro==1.2.0
|
||||
html5lib==1.0b10
|
||||
six==1.11.0
|
||||
colorama==0.3.9
|
||||
|
|
|
@ -1202,10 +1202,10 @@ def test_basic_install_environment_markers(script):
|
|||
)
|
||||
"""))
|
||||
|
||||
res = script.pip('install', '--no-index', pkga_path, expect_stderr=True)
|
||||
res = script.pip('install', '--no-index', pkga_path)
|
||||
# missing_pkg should be ignored
|
||||
assert ("Ignoring missing-pkg: markers 'python_version == \"1.0\"' don't "
|
||||
"match your environment") in res.stderr, str(res)
|
||||
"match your environment") in res.stdout, str(res)
|
||||
assert "Successfully installed pkga-0.1" in res.stdout, str(res)
|
||||
|
||||
|
||||
|
|
|
@ -300,6 +300,14 @@ def test_constraints_local_editable_install_causes_error(script, data):
|
|||
assert 'Could not satisfy constraints for' in result.stderr
|
||||
|
||||
|
||||
def test_constraints_local_editable_install_pep518(script, data):
|
||||
to_install = data.src.join("pep518-3.0")
|
||||
|
||||
script.pip('download', 'setuptools', 'wheel', '-d', data.packages)
|
||||
script.pip(
|
||||
'install', '--no-index', '-f', data.find_links, '-e', to_install)
|
||||
|
||||
|
||||
def test_constraints_local_install_causes_error(script, data):
|
||||
script.scratch_path.join("constraints.txt").write(
|
||||
"singlemodule==0.0.0"
|
||||
|
@ -484,11 +492,10 @@ def test_install_unsupported_wheel_link_with_marker(script):
|
|||
result = script.pip(
|
||||
'install', '-r', script.scratch_path / 'with-marker.txt',
|
||||
expect_error=False,
|
||||
expect_stderr=True,
|
||||
)
|
||||
|
||||
assert ("Ignoring asdf: markers 'sys_platform == \"xyz\"' don't match "
|
||||
"your environment") in result.stderr
|
||||
"your environment") in result.stdout
|
||||
assert len(result.files_created) == 0
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue