Skip to content

Commit 2af35e7

Browse files
pmav991nF0rmed
authored andcommitted
Separate the package and the platform constraints in poetry export
Fixes python-poetry#4575 Related to: - pypa/packaging#456 - python-poetry/poetry-plugin-export#12
1 parent 529824b commit 2af35e7

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

poetry/utils/exporter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _export_requirements_txt(
8989
if ";" in requirement:
9090
markers = requirement.split(";", 1)[1].strip()
9191
if markers:
92-
line += f"; {markers}"
92+
line += f" ; {markers}"
9393

9494
if (
9595
not is_direct_remote_reference

tests/utils/test_exporter.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ def test_exporter_can_export_requirements_txt_with_standard_packages_and_markers
164164

165165
expected = """\
166166
bar==4.5.6
167-
baz==7.8.9; sys_platform == "win32"
168-
foo==1.2.3; python_version < "3.7"
167+
baz==7.8.9 ; sys_platform == "win32"
168+
foo==1.2.3 ; python_version < "3.7"
169169
"""
170170

171171
assert expected == content
@@ -273,10 +273,10 @@ def test_exporter_can_export_requirements_txt_poetry(tmp_dir, poetry):
273273
"junit-xml": Dependency.create_from_pep_508("junit-xml==1.9"),
274274
"keyring": Dependency.create_from_pep_508("keyring==21.8.0"),
275275
"secretstorage": Dependency.create_from_pep_508(
276-
"secretstorage==3.3.0; sys_platform=='linux'"
276+
"secretstorage==3.3.0 ; sys_platform=='linux'"
277277
),
278278
"cryptography": Dependency.create_from_pep_508(
279-
"cryptography==3.2; sys_platform=='linux'"
279+
"cryptography==3.2 ; sys_platform=='linux'"
280280
),
281281
"six": Dependency.create_from_pep_508("six==1.15.0"),
282282
}
@@ -353,7 +353,7 @@ def test_exporter_can_export_requirements_txt_pyinstaller(tmp_dir, poetry):
353353
"pyinstaller": Dependency.create_from_pep_508("pyinstaller==4.0"),
354354
"altgraph": Dependency.create_from_pep_508("altgraph==0.17"),
355355
"macholib": Dependency.create_from_pep_508(
356-
"macholib==1.8; sys_platform == 'darwin'"
356+
"macholib==1.8 ; sys_platform == 'darwin'"
357357
),
358358
}
359359

@@ -423,15 +423,15 @@ def test_exporter_can_export_requirements_txt_with_nested_packages_and_markers(
423423
content = f.read()
424424

425425
expected = {
426-
"a": Dependency.create_from_pep_508("a==1.2.3; python_version < '3.7'"),
426+
"a": Dependency.create_from_pep_508("a==1.2.3 ; python_version < '3.7'"),
427427
"b": Dependency.create_from_pep_508(
428-
"b==4.5.6; platform_system == 'Windows' and python_version < '3.7'"
428+
"b==4.5.6 ; platform_system == 'Windows' and python_version < '3.7'"
429429
),
430430
"c": Dependency.create_from_pep_508(
431-
"c==7.8.9; sys_platform == 'win32' and python_version < '3.7'"
431+
"c==7.8.9 ; sys_platform == 'win32' and python_version < '3.7'"
432432
),
433433
"d": Dependency.create_from_pep_508(
434-
"d==0.0.1; platform_system == 'Windows' and python_version < '3.7' or sys_platform == 'win32' and python_version < '3.7'"
434+
"d==0.0.1 ; platform_system == 'Windows' and python_version < '3.7' or sys_platform == 'win32' and python_version < '3.7'"
435435
),
436436
}
437437

@@ -447,7 +447,7 @@ def test_exporter_can_export_requirements_txt_with_nested_packages_and_markers(
447447

448448
@pytest.mark.parametrize(
449449
"dev,lines",
450-
[(False, ['a==1.2.3; python_version < "3.8"']), (True, ["a==1.2.3", "b==4.5.6"])],
450+
[(False, ['a==1.2.3 ; python_version < "3.8"']), (True, ["a==1.2.3", "b==4.5.6"])],
451451
)
452452
def test_exporter_can_export_requirements_txt_with_nested_packages_and_markers_any(
453453
tmp_dir, poetry, dev, lines
@@ -1139,7 +1139,7 @@ def test_exporter_can_export_requirements_txt_with_directory_packages_and_marker
11391139
content = f.read()
11401140

11411141
expected = """\
1142-
foo @ {}/tests/fixtures/sample_project; python_version < "3.7"
1142+
foo @ {}/tests/fixtures/sample_project ; python_version < "3.7"
11431143
""".format(
11441144
working_directory.as_uri()
11451145
)
@@ -1228,7 +1228,7 @@ def test_exporter_can_export_requirements_txt_with_file_packages_and_markers(
12281228
content = f.read()
12291229

12301230
expected = """\
1231-
foo @ {}/tests/fixtures/distributions/demo-0.1.0.tar.gz; python_version < "3.7"
1231+
foo @ {}/tests/fixtures/distributions/demo-0.1.0.tar.gz ; python_version < "3.7"
12321232
""".format(
12331233
working_directory.as_uri()
12341234
)

0 commit comments

Comments
 (0)