Skip to content

Commit

Permalink
Merge pull request #3210 from abn/issue/3077
Browse files Browse the repository at this point in the history
Handle non-editable packages with pth files
  • Loading branch information
sdispater authored Oct 23, 2020
2 parents 221bd80 + b92fb66 commit 2e20673
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
12 changes: 10 additions & 2 deletions poetry/repositories/installed_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,22 @@ def load(cls, env): # type: (Env) -> InstalledRepository
if path.name.endswith(".dist-info"):
paths = cls.get_package_paths(env=env, name=package.pretty_name)
if paths:
is_editable_package = False
for src in paths:
if cls.is_vcs_package(src, env):
cls.set_package_vcs_properties(package, env)
break

if not (
is_editable_package
or env.is_path_relative_to_lib(src)
):
is_editable_package = True
else:
# TODO: handle multiple source directories?
package._source_type = "directory"
package._source_url = paths.pop().as_posix()
if is_editable_package:
package._source_type = "directory"
package._source_url = paths.pop().as_posix()
continue

if cls.is_vcs_package(path, env):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Metadata-Version: 2.1
Name: standard
Version: 1.2.3
Summary: Standard description.
License: MIT
Keywords: cli,commands
Author: Foo Bar
Author-email: foo@bar.com
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 @@
standard
11 changes: 11 additions & 0 deletions tests/repositories/test_installed_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
zipp.Path(str(SITE_PURELIB / "foo-0.1.0-py3.8.egg"), "EGG-INFO")
),
metadata.PathDistribution(VENDOR_DIR / "attrs-19.3.0.dist-info"),
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-with-import-2.3.4.dist-info"),
metadata.PathDistribution(SITE_PLATLIB / "lib64-2.3.4.dist-info"),
Expand Down Expand Up @@ -158,3 +159,13 @@ def test_load_editable_with_import_package(repository):
assert editable.version.text == "2.3.4"
assert editable.source_type is None
assert editable.source_url is None


def test_load_standard_package_with_pth_file(repository):
# test standard packages with .pth file is not treated as editable
standard = get_package_from_repository("standard", repository)
assert standard is not None
assert standard.name == "standard"
assert standard.version.text == "1.2.3"
assert standard.source_type is None
assert standard.source_url is None

0 comments on commit 2e20673

Please sign in to comment.