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
@@ -149,8 +150,7 @@ def create_package_from_distribution(
149150 ) = cls .get_package_vcs_properties_from_path (
150151 env .path / "src" / canonicalize_name (distribution .metadata ["name" ])
151152 )
152- else :
153- # If not, it's a path dependency
153+ elif is_python_project (path .parent ):
154154 source_type = "directory"
155155 source_url = str (path .parent )
156156
Original file line number Diff line number Diff line change @@ -422,3 +422,30 @@ def test_system_site_packages_source_type(
422422 package .name : package .source_type for package in installed_repository .packages
423423 }
424424 assert source_types == {"cleo" : None , "directory-pep-610" : "directory" }
425+
426+
427+ def test_pipx_shared_lib_site_packages (
428+ tmp_path : Path ,
429+ poetry : Poetry ,
430+ site_purelib : Path ,
431+ caplog : LogCaptureFixture ,
432+ ) -> None :
433+ """
434+ Simulate pipx shared/lib/site-packages which is not relative to the venv path.
435+ """
436+ venv_path = tmp_path / "venv"
437+ shared_lib_site_path = tmp_path / "site"
438+ env = MockEnv (
439+ path = venv_path , sys_path = [str (venv_path / "purelib" ), str (shared_lib_site_path )]
440+ )
441+ dist_info = "cleo-0.7.6.dist-info"
442+ shutil .copytree (site_purelib / dist_info , shared_lib_site_path / dist_info )
443+ installed_repository = InstalledRepository .load (env )
444+
445+ assert len (installed_repository .packages ) == 1
446+ cleo_package = installed_repository .packages [0 ]
447+ cleo_package .to_dependency ()
448+ # There must not be a warning
449+ # that the package does not seem to be a valid Python package.
450+ assert caplog .messages == []
451+ assert cleo_package .source_type is None
You can’t perform that action at this time.
0 commit comments