Skip to content

Commit

Permalink
exporter: use URIs for local dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
maxispeicher committed Oct 7, 2020
1 parent 6fbe88d commit a7f9a4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion poetry/utils/exporter.py
Expand Up @@ -95,9 +95,12 @@ def _export_requirements_txt(
if is_direct_remote_reference:
line = requirement
elif is_direct_local_reference:
line = requirement.replace("@ ", "@ file://")
dependency_uri = Path(dependency.source_url).as_uri()
line = f"{dependency.name} @ {dependency_uri}"
else:
line = "{}=={}".format(package.name, package.version)

if not is_direct_remote_reference:
if ";" in requirement:
markers = requirement.split(";", 1)[1].strip()
if markers:
Expand Down
12 changes: 6 additions & 6 deletions tests/utils/test_exporter.py
Expand Up @@ -582,9 +582,9 @@ def test_exporter_can_export_requirements_txt_with_directory_packages(
content = f.read()

expected = """\
foo @ file://{}/tests/fixtures/sample_project
foo @ {}/tests/fixtures/sample_project
""".format(
working_directory.as_posix()
working_directory.as_uri()
)

assert expected == content
Expand Down Expand Up @@ -627,9 +627,9 @@ def test_exporter_can_export_requirements_txt_with_directory_packages_and_marker
content = f.read()

expected = """\
foo @ file://{}/tests/fixtures/sample_project; python_version < "3.7"
foo @ {}/tests/fixtures/sample_project; python_version < "3.7"
""".format(
working_directory.as_posix()
working_directory.as_uri()
)

assert expected == content
Expand Down Expand Up @@ -671,7 +671,7 @@ def test_exporter_can_export_requirements_txt_with_file_packages(
content = f.read()

expected = """\
foo @ file://{}/tests/fixtures/distributions/demo-0.1.0.tar.gz
foo @ {}/tests/fixtures/distributions/demo-0.1.0.tar.gz
""".format(
working_directory.as_uri()
)
Expand Down Expand Up @@ -716,7 +716,7 @@ def test_exporter_can_export_requirements_txt_with_file_packages_and_markers(
content = f.read()

expected = """\
foo @ file://{}/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()
)
Expand Down

0 comments on commit a7f9a4a

Please sign in to comment.