Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix grouping of extras requirements in notpip #2142

Merged
merged 14 commits into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions pipenv/patched/notpip/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,30 +206,26 @@ def add_dependency_links(self, links):
)
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):
"""
Expand Down
22 changes: 11 additions & 11 deletions tasks/vendoring/patches/patched/pip.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
131 changes: 131 additions & 0 deletions tests/unit/test_patched.py
Original file line number Diff line number Diff line change
@@ -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