From 170f059694e0bb6f2b7d059fce40aa882241bbc7 Mon Sep 17 00:00:00 2001 From: simonepri Date: Sat, 25 Apr 2020 19:16:35 +0100 Subject: [PATCH 1/5] Add breaking test for dependency_from_pep_508 --- tests/packages/test_main.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/packages/test_main.py b/tests/packages/test_main.py index 586be5a31b8..5559057e4e9 100644 --- a/tests/packages/test_main.py +++ b/tests/packages/test_main.py @@ -183,6 +183,22 @@ def test_dependency_from_pep_508_with_git_url(): assert "1.2" == dep.reference +def test_dependency_from_pep_508_with_git_url_and_comment_and_extra(): + name = ( + "poetry @ git+https://github.com/python-poetry/poetry.git@b;ar;#egg=poetry" + ' ; extra == "foo;"' + ) + + dep = dependency_from_pep_508(name) + + assert "poetry" == dep.name + assert dep.is_vcs() + assert "git" == dep.vcs + assert "https://github.com/python-poetry/poetry.git" == dep.source + assert "b;ar;" == dep.reference + assert dep.in_extras == ["foo;"] + + def test_dependency_from_pep_508_with_url(): name = "django-utils @ https://example.com/django-utils-1.0.0.tar.gz" From 03797368a999bd4f36153ef8364009dcec3f4f75 Mon Sep 17 00:00:00 2001 From: simonepri Date: Sat, 25 Apr 2020 19:16:47 +0100 Subject: [PATCH 2/5] Fix dependency_from_pep_508 --- poetry/packages/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/poetry/packages/__init__.py b/poetry/packages/__init__.py index e0a2203c9d3..a829858deb2 100644 --- a/poetry/packages/__init__.py +++ b/poetry/packages/__init__.py @@ -33,8 +33,8 @@ def dependency_from_pep_508(name): name = parts[0].strip() if len(parts) > 1: rest = parts[1] - if ";" in rest: - name += ";" + rest.split(";", 1)[1] + if " ;" in rest: + name += " ;" + rest.split(" ;", 1)[1] req = Requirement(name) From ef1af15c4cf60c326dea30934f6fed4616afd8ce Mon Sep 17 00:00:00 2001 From: simonepri Date: Sat, 25 Apr 2020 19:29:55 +0100 Subject: [PATCH 3/5] Add failing test for parse_requires --- tests/utils/test_helpers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py index d34061c88d6..d31d505f238 100644 --- a/tests/utils/test_helpers.py +++ b/tests/utils/test_helpers.py @@ -29,6 +29,9 @@ def test_parse_requires(): [:python_version >= "3.4.0.0" and python_version < "3.6.0.0"] zipfile36>=0.1.0.0,<0.2.0.0 + +[dev] +isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e528357650281a3d3ec22#egg=isort """ result = parse_requires(requires) expected = [ @@ -49,6 +52,7 @@ def test_parse_requires(): 'virtualenv>=15.2.0.0,<16.0.0.0; python_version >= "2.7.0.0" and python_version < "2.8.0.0"', 'pathlib2>=2.3.0.0,<3.0.0.0; python_version >= "2.7.0.0" and python_version < "2.8.0.0"', 'zipfile36>=0.1.0.0,<0.2.0.0; python_version >= "3.4.0.0" and python_version < "3.6.0.0"', + 'isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e528357650281a3d3ec22#egg=isort ; extra == "dev"', ] assert result == expected From 44ccf6b13f4eb82e4329a00a42392211b6719bb5 Mon Sep 17 00:00:00 2001 From: simonepri Date: Sat, 25 Apr 2020 19:30:03 +0100 Subject: [PATCH 4/5] Fix parse_requires --- poetry/utils/helpers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/poetry/utils/helpers.py b/poetry/utils/helpers.py index 3ecef0c391e..9bd8dcc5f74 100644 --- a/poetry/utils/helpers.py +++ b/poetry/utils/helpers.py @@ -83,6 +83,8 @@ def parse_requires(requires): # type: (str) -> List[str] continue if current_marker: + if "@" in line: + line += " " line = "{}; {}".format(line, current_marker) requires_dist.append(line) From e455743f4b06ad4991f60683de396cce83cd09dd Mon Sep 17 00:00:00 2001 From: simonepri Date: Sat, 25 Apr 2020 21:29:40 +0100 Subject: [PATCH 5/5] Update parse_requires fix --- poetry/utils/helpers.py | 4 +--- tests/utils/test_helpers.py | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/poetry/utils/helpers.py b/poetry/utils/helpers.py index 9bd8dcc5f74..85d18a71d44 100644 --- a/poetry/utils/helpers.py +++ b/poetry/utils/helpers.py @@ -83,9 +83,7 @@ def parse_requires(requires): # type: (str) -> List[str] continue if current_marker: - if "@" in line: - line += " " - line = "{}; {}".format(line, current_marker) + line = "{} ; {}".format(line, current_marker) requires_dist.append(line) diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py index d31d505f238..eb7ce191f18 100644 --- a/tests/utils/test_helpers.py +++ b/tests/utils/test_helpers.py @@ -48,10 +48,10 @@ def test_parse_requires(): "msgpack-python>=0.5.0.0,<0.6.0.0", "pyparsing>=2.2.0.0,<3.0.0.0", "requests-toolbelt>=0.8.0.0,<0.9.0.0", - 'typing>=3.6.0.0,<4.0.0.0; (python_version >= "2.7.0.0" and python_version < "2.8.0.0") or (python_version >= "3.4.0.0" and python_version < "3.5.0.0")', - 'virtualenv>=15.2.0.0,<16.0.0.0; python_version >= "2.7.0.0" and python_version < "2.8.0.0"', - 'pathlib2>=2.3.0.0,<3.0.0.0; python_version >= "2.7.0.0" and python_version < "2.8.0.0"', - 'zipfile36>=0.1.0.0,<0.2.0.0; python_version >= "3.4.0.0" and python_version < "3.6.0.0"', + 'typing>=3.6.0.0,<4.0.0.0 ; (python_version >= "2.7.0.0" and python_version < "2.8.0.0") or (python_version >= "3.4.0.0" and python_version < "3.5.0.0")', + 'virtualenv>=15.2.0.0,<16.0.0.0 ; python_version >= "2.7.0.0" and python_version < "2.8.0.0"', + 'pathlib2>=2.3.0.0,<3.0.0.0 ; python_version >= "2.7.0.0" and python_version < "2.8.0.0"', + 'zipfile36>=0.1.0.0,<0.2.0.0 ; python_version >= "3.4.0.0" and python_version < "3.6.0.0"', 'isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e528357650281a3d3ec22#egg=isort ; extra == "dev"', ] assert result == expected