Skip to content

Commit

Permalink
installed repository: fix path of editable install with src layout (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Jul 14, 2024
1 parent fae20e1 commit df2a66f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/poetry/repositories/installed_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ def create_package_from_distribution(
# TODO: handle multiple source directories?
if is_editable_package:
source_type = "directory"
source_url = paths.pop().as_posix()
path = paths.pop()
if path.name == "src":
path = path.parent
source_url = path.as_posix()
elif cls.is_vcs_package(path, env):
(
source_type,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Metadata-Version: 2.1
Name: editable-src-dir
Version: 2.3.4
Summary: Editable description.
License: MIT
Keywords: cli,commands
Author: Foo Bar
Author-email: [email protected]
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Description-Content-Type: text/x-rst

Editable
####
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/path/to/editable/src
13 changes: 13 additions & 0 deletions tests/repositories/test_installed_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def installed_results(
),
metadata.PathDistribution(site_purelib / "standard-1.2.3.dist-info"),
metadata.PathDistribution(site_purelib / "editable-2.3.4.dist-info"),
metadata.PathDistribution(site_purelib / "editable-src-dir-2.3.4.dist-info"),
metadata.PathDistribution(
site_purelib / "editable-with-import-2.3.4.dist-info"
),
Expand Down Expand Up @@ -286,6 +287,18 @@ def test_load_editable_package(
assert editable.source_url == editable_source_directory_path


def test_load_editable_src_dir_package(
repository: InstalledRepository, editable_source_directory_path: str
) -> None:
# test editable package with src layout with text .pth file
editable = get_package_from_repository("editable-src-dir", repository)
assert editable is not None
assert editable.name == "editable-src-dir"
assert editable.version.text == "2.3.4"
assert editable.source_type == "directory"
assert editable.source_url == editable_source_directory_path


def test_load_editable_with_import_package(repository: InstalledRepository) -> None:
# test editable package with executable .pth file
editable = get_package_from_repository("editable-with-import", repository)
Expand Down

0 comments on commit df2a66f

Please sign in to comment.