From 342fe43c936a36467f4e621bc187ec202eeca03c Mon Sep 17 00:00:00 2001 From: Panos Mavrogiorgos Date: Thu, 30 Sep 2021 21:52:56 +0300 Subject: [PATCH] Add space before the semicolon separating the package and the platform constraints Fixes #12 Related to: - https://github.com/python-poetry/poetry/issues/4575 - https://github.com/pypa/packaging/issues/456 --- src/poetry_export_plugin/exporter.py | 2 +- tests/test_exporter.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/poetry_export_plugin/exporter.py b/src/poetry_export_plugin/exporter.py index eda7005..827bd82 100644 --- a/src/poetry_export_plugin/exporter.py +++ b/src/poetry_export_plugin/exporter.py @@ -142,7 +142,7 @@ def _export_requirements_txt(self, cwd: Path, output: Union["IO", str]) -> None: if ";" in requirement: markers = requirement.split(";", 1)[1].strip() if markers: - line += f"; {markers}" + line += f" ; {markers}" if ( not is_direct_remote_reference diff --git a/tests/test_exporter.py b/tests/test_exporter.py index ee6c19f..cf18b7c 100644 --- a/tests/test_exporter.py +++ b/tests/test_exporter.py @@ -172,8 +172,8 @@ def test_exporter_can_export_requirements_txt_with_standard_packages_and_markers expected = """\ bar==4.5.6 -baz==7.8.9; sys_platform == "win32" -foo==1.2.3; python_version < "3.7" +baz==7.8.9 ; sys_platform == "win32" +foo==1.2.3 ; python_version < "3.7" """ assert expected == content @@ -431,15 +431,15 @@ def test_exporter_can_export_requirements_txt_with_nested_packages_and_markers( content = f.read() expected = { - "a": Dependency.create_from_pep_508("a==1.2.3; python_version < '3.7'"), + "a": Dependency.create_from_pep_508("a==1.2.3 ; python_version < '3.7'"), "b": Dependency.create_from_pep_508( - "b==4.5.6; platform_system == 'Windows' and python_version < '3.7'" + "b==4.5.6 ; platform_system == 'Windows' and python_version < '3.7'" ), "c": Dependency.create_from_pep_508( - "c==7.8.9; sys_platform == 'win32' and python_version < '3.7'" + "c==7.8.9 ; sys_platform == 'win32' and python_version < '3.7'" ), "d": Dependency.create_from_pep_508( - "d==0.0.1; platform_system == 'Windows' and python_version < '3.7' or sys_platform == 'win32' and python_version < '3.7'" + "d==0.0.1 ; platform_system == 'Windows' and python_version < '3.7' or sys_platform == 'win32' and python_version < '3.7'" ), } @@ -455,7 +455,7 @@ def test_exporter_can_export_requirements_txt_with_nested_packages_and_markers( @pytest.mark.parametrize( "dev,lines", - [(False, ['a==1.2.3; python_version < "3.8"']), (True, ["a==1.2.3", "b==4.5.6"])], + [(False, ['a==1.2.3 ; python_version < "3.8"']), (True, ["a==1.2.3", "b==4.5.6"])], ) def test_exporter_can_export_requirements_txt_with_nested_packages_and_markers_any( tmp_dir, poetry, dev, lines @@ -1180,7 +1180,7 @@ def test_exporter_can_export_requirements_txt_with_directory_packages_and_marker content = f.read() expected = """\ -foo @ {}/tests/fixtures/sample_project; python_version < "3.7" +foo @ {}/tests/fixtures/sample_project ; python_version < "3.7" """.format( working_directory.as_uri() ) @@ -1269,7 +1269,7 @@ def test_exporter_can_export_requirements_txt_with_file_packages_and_markers( content = f.read() expected = """\ -foo @ {}/tests/fixtures/distributions/demo-0.1.0.tar.gz; python_version < "3.7" +foo @ {}/tests/fixtures/distributions/demo-0.1.0.tar.gz ; python_version < "3.7" """.format( working_directory.as_uri() )