Merge branch 'master' into windows-cmder-root-space-escape-fix

This commit is contained in:
Dan Ryan
2018-05-23 13:33:34 -04:00
committed by GitHub
6 changed files with 201 additions and 24 deletions
+8 -12
View File
@@ -206,30 +206,26 @@ class PackageFinder(object):
)
self.dependency_links.extend(links)
def get_extras_links(self, links):
@staticmethod
def get_extras_links(links):
requires = []
extras = {}
current_section = None
current_list = requires
for link in links:
if not link:
current_section = None
if not current_section:
if not (link.startswith('[')):
requires.append(link)
else:
current_section = link[1:-1]
extras[current_section] = []
current_list = requires
if link.startswith('['):
current_list = []
extras[link[1:-1]] = current_list
else:
extras[current_section].append(link)
current_list.append(link)
return extras
@staticmethod
def _sort_locations(locations, expand_dir=False):
"""
+31 -1
View File
@@ -58,6 +58,36 @@ def make_install_requirement(name, version, extras, markers, constraint=False):
constraint=constraint)
def _requirement_to_str_lowercase_name(requirement):
"""
Formats a packaging.requirements.Requirement with a lowercase name.
This is simply a copy of
https://github.com/pypa/packaging/blob/16.8/packaging/requirements.py#L109-L124
modified to lowercase the dependency name.
Previously, we were invoking the original Requirement.__str__ method and
lowercasing the entire result, which would lowercase the name, *and* other,
important stuff that should not be lowercased (such as the marker). See
this issue for more information: https://github.com/pypa/pipenv/issues/2113.
"""
parts = [requirement.name.lower()]
if requirement.extras:
parts.append("[{0}]".format(",".join(sorted(requirement.extras))))
if requirement.specifier:
parts.append(str(requirement.specifier))
if requirement.url:
parts.append("@ {0}".format(requirement.url))
if requirement.marker:
parts.append("; {0}".format(requirement.marker))
return "".join(parts)
def format_requirement(ireq, marker=None):
"""
Generic formatter for pretty printing InstallRequirements to the terminal
@@ -66,7 +96,7 @@ def format_requirement(ireq, marker=None):
if ireq.editable:
line = '-e {}'.format(ireq.link)
else:
line = str(ireq.req).lower()
line = _requirement_to_str_lowercase_name(ireq.req)
if marker:
line = '{}; {}'.format(line, marker)
+11 -11
View File
@@ -1362,29 +1362,29 @@ index f653f6e..48aaa35 100644
)
self.dependency_links.extend(links)
+ def get_extras_links(self, links):
+ @classmethod
+ def get_extras_links(links):
+ requires = []
+ extras = {}
+
+ current_section = None
+ current_list = requires
+
+ for link in links:
+ if not link:
+ current_section = None
+
+ if not current_section:
+ if not (link.startswith('[')):
+ requires.append(link)
+ else:
+ current_section = link[1:-1]
+ extras[current_section] = []
+ current_list = requires
+ if link.startswith('['):
+ current_list = []
+ extras[link[1:-1]] = current_list
+ else:
+ extras[current_section].append(link)
+ current_list.append(link)
+
+ return extras
+
+
+
+
+
+
+
@staticmethod
def _sort_locations(locations, expand_dir=False):
+20
View File
@@ -33,6 +33,26 @@ tablib = {version = "*", markers="os_name=='splashwear'"}
c = p.pipenv('run python -c "import tablib;"')
assert c.return_code == 1
@pytest.mark.markers
@flaky
def test_platform_python_implementation_marker(PipenvInstance, pypi):
"""Markers should be converted during locking to help users who input this incorrectly
"""
with PipenvInstance(pypi=pypi) as p:
with open(p.pipfile_path, 'w') as f:
contents = """
[packages]
depends-on-marked-package = "*"
""".strip()
f.write(contents)
c = p.pipenv('install')
assert c.return_code == 0
# depends-on-marked-package has an install_requires of 'pytz; platform_python_implementation=="CPython"'
# Verify that that marker shows up in our lockfile unaltered.
assert p.lockfile['default']['pytz']['markers'] == "platform_python_implementation == 'CPython'"
@pytest.mark.run
@pytest.mark.alt
+131
View File
@@ -0,0 +1,131 @@
from __future__ import absolute_import
import pytest
from notpip.index import PackageFinder
get_extras_links_scenarios = {
'windows and not windows': (
[
'chardet',
'[:platform_system != "windows"]',
'twisted',
'[:platform_system == "windows"]',
'twisted[windows_platform]',
],
{
':platform_system != "windows"': [
'twisted',
],
':platform_system == "windows"': [
'twisted[windows_platform]',
],
},
),
'requests': (
[
'chardet<3.1.0,>=3.0.2',
'idna<2.7,>=2.5',
'urllib3<1.23,>=1.21.1',
'certifi>=2017.4.17',
'[security]',
'pyOpenSSL>=0.14',
'cryptography>=1.3.4',
'idna>=2.0.0',
'[socks]',
'PySocks!=1.5.7,>=1.5.6',
(
'[socks:sys_platform == "win32"'
' and (python_version == "2.7" or python_version == "2.6")]'
),
'win_inet_pton',
],
{
'security': [
'pyOpenSSL>=0.14',
'cryptography>=1.3.4',
'idna>=2.0.0',
],
'socks': [
'PySocks!=1.5.7,>=1.5.6',
],
'socks:sys_platform == "win32" '
'and (python_version == "2.7" or python_version == "2.6")': [
'win_inet_pton',
],
}
),
'attrs': (
[
'[dev]',
'coverage',
'hypothesis',
'pympler',
'pytest',
'six',
'zope.interface',
'sphinx',
'zope.interface',
'[docs]',
'sphinx',
'zope.interface',
'[tests]',
'coverage',
'hypothesis',
'pympler',
'pytest',
'six',
'zope.interface',
],
{
'dev': [
'coverage',
'hypothesis',
'pympler',
'pytest',
'six',
'zope.interface',
'sphinx',
'zope.interface',
],
'docs': [
'sphinx',
'zope.interface',
],
'tests': [
'coverage',
'hypothesis',
'pympler',
'pytest',
'six',
'zope.interface',
],
},
),
'misc': (
[
'chardet',
'[:platform_system != "windows"]',
'attrs',
'[:platform_system == "windows"]',
'pytz',
],
{
':platform_system != "windows"': [
'attrs',
],
':platform_system == "windows"': [
'pytz',
],
},
),
}
@pytest.mark.parametrize(
'scenarios,expected',
list(get_extras_links_scenarios.values()),
ids=list(get_extras_links_scenarios.keys()),
)
def test_get_extras_links(scenarios, expected):
assert PackageFinder.get_extras_links(scenarios) == expected