File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 99
1010from packaging .utils import canonicalize_name
1111from poetry .core .packages .package import Package
12+ from poetry .core .packages .utils .utils import is_python_project
1213from poetry .core .packages .utils .utils import url_to_path
1314from poetry .core .utils .helpers import module_name
1415
@@ -150,8 +151,7 @@ def create_package_from_distribution(
150151 ) = cls .get_package_vcs_properties_from_path (
151152 env .path / "src" / canonicalize_name (distribution .metadata ["name" ])
152153 )
153- else :
154- # If not, it's a path dependency
154+ elif is_python_project (path .parent ):
155155 source_type = "directory"
156156 source_url = str (path .parent )
157157
Original file line number Diff line number Diff line change @@ -423,3 +423,30 @@ def test_system_site_packages_source_type(
423423 package .name : package .source_type for package in installed_repository .packages
424424 }
425425 assert source_types == {"cleo" : None , "directory-pep-610" : "directory" }
426+
427+
428+ def test_pipx_shared_lib_site_packages (
429+ tmp_path : Path ,
430+ poetry : Poetry ,
431+ site_purelib : Path ,
432+ caplog : LogCaptureFixture ,
433+ ) -> None :
434+ """
435+ Simulate pipx shared/lib/site-packages which is not relative to the venv path.
436+ """
437+ venv_path = tmp_path / "venv"
438+ shared_lib_site_path = tmp_path / "site"
439+ env = MockEnv (
440+ path = venv_path , sys_path = [str (venv_path / "purelib" ), str (shared_lib_site_path )]
441+ )
442+ dist_info = "cleo-0.7.6.dist-info"
443+ shutil .copytree (site_purelib / dist_info , shared_lib_site_path / dist_info )
444+ installed_repository = InstalledRepository .load (env )
445+
446+ assert len (installed_repository .packages ) == 1
447+ cleo_package = installed_repository .packages [0 ]
448+ cleo_package .to_dependency ()
449+ # There must not be a warning
450+ # that the package does not seem to be a valid Python package.
451+ assert caplog .messages == []
452+ assert cleo_package .source_type is None
You can’t perform that action at this time.
0 commit comments