Skip to content

Commit 17d0a3a

Browse files
radoeringSecrus
authored andcommitted
installed repository: fix path of editable install with src layout (python-poetry#9547)
1 parent 4333463 commit 17d0a3a

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

src/poetry/repositories/installed_repository.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ def create_package_from_distribution(
142142
# TODO: handle multiple source directories?
143143
if is_editable_package:
144144
source_type = "directory"
145-
source_url = paths.pop().as_posix()
145+
path = paths.pop()
146+
if path.name == "src":
147+
path = path.parent
148+
source_url = path.as_posix()
146149
elif cls.is_vcs_package(path, env):
147150
(
148151
source_type,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Metadata-Version: 2.1
2+
Name: editable-src-dir
3+
Version: 2.3.4
4+
Summary: Editable description.
5+
License: MIT
6+
Keywords: cli,commands
7+
Author: Foo Bar
8+
Author-email: foo@bar.com
9+
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
10+
Classifier: License :: OSI Approved :: MIT License
11+
Classifier: Programming Language :: Python :: 2
12+
Classifier: Programming Language :: Python :: 2.7
13+
Classifier: Programming Language :: Python :: 3
14+
Classifier: Programming Language :: Python :: 3.4
15+
Classifier: Programming Language :: Python :: 3.5
16+
Classifier: Programming Language :: Python :: 3.6
17+
Classifier: Programming Language :: Python :: 3.7
18+
Classifier: Programming Language :: Python :: 3.8
19+
Description-Content-Type: text/x-rst
20+
21+
Editable
22+
####
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/path/to/editable/src

tests/repositories/test_installed_repository.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def installed_results(
7070
),
7171
metadata.PathDistribution(site_purelib / "standard-1.2.3.dist-info"),
7272
metadata.PathDistribution(site_purelib / "editable-2.3.4.dist-info"),
73+
metadata.PathDistribution(site_purelib / "editable-src-dir-2.3.4.dist-info"),
7374
metadata.PathDistribution(
7475
site_purelib / "editable-with-import-2.3.4.dist-info"
7576
),
@@ -287,6 +288,18 @@ def test_load_editable_package(
287288
assert editable.source_url == editable_source_directory_path
288289

289290

291+
def test_load_editable_src_dir_package(
292+
repository: InstalledRepository, editable_source_directory_path: str
293+
) -> None:
294+
# test editable package with src layout with text .pth file
295+
editable = get_package_from_repository("editable-src-dir", repository)
296+
assert editable is not None
297+
assert editable.name == "editable-src-dir"
298+
assert editable.version.text == "2.3.4"
299+
assert editable.source_type == "directory"
300+
assert editable.source_url == editable_source_directory_path
301+
302+
290303
def test_load_editable_with_import_package(repository: InstalledRepository) -> None:
291304
# test editable package with executable .pth file
292305
editable = get_package_from_repository("editable-with-import", repository)

0 commit comments

Comments
 (0)