File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed
Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 1+ v6.7.0
2+ ======
3+
4+ * #453: When inferring top-level names that are importable for
5+ distributions in ``package_distributions ``, now symlinks to
6+ other directories are honored.
7+
18v6.6.0
29======
310
Original file line number Diff line number Diff line change @@ -981,30 +981,34 @@ def _topmost(name: PackagePath) -> Optional[str]:
981981 return top if rest else None
982982
983983
984- def _get_toplevel_name (name : PackagePath ) -> Optional [ str ] :
984+ def _get_toplevel_name (name : PackagePath ) -> str :
985985 """
986986 Infer a possibly importable module name from a name presumed on
987987 sys.path.
988988
989989 >>> _get_toplevel_name(PackagePath('foo.py'))
990990 'foo'
991+ >>> _get_toplevel_name(PackagePath('foo'))
992+ 'foo'
991993 >>> _get_toplevel_name(PackagePath('foo.pyc'))
992994 'foo'
993995 >>> _get_toplevel_name(PackagePath('foo/__init__.py'))
994996 'foo'
995997 >>> _get_toplevel_name(PackagePath('foo.pth'))
998+ 'foo.pth'
996999 >>> _get_toplevel_name(PackagePath('foo.dist-info'))
1000+ 'foo.dist-info'
9971001 """
9981002 return _topmost (name ) or (
9991003 # python/typeshed#10328
10001004 inspect .getmodulename (name ) # type: ignore
1005+ or str (name )
10011006 )
10021007
10031008
10041009def _top_level_inferred (dist ):
10051010 opt_names = set (map (_get_toplevel_name , always_iterable (dist .files )))
10061011
1007- @pass_none
10081012 def importable_name (name ):
10091013 return '.' not in name
10101014
Original file line number Diff line number Diff line change 99
1010from . import fixtures
1111from ._context import suppress
12+ from ._path import Symlink
1213from importlib_metadata import (
1314 Distribution ,
1415 EntryPoint ,
@@ -399,6 +400,27 @@ def test_packages_distributions_all_module_types(self):
399400
400401 assert not any (name .endswith ('.dist-info' ) for name in distributions )
401402
403+ def test_packages_distributions_symlinked_top_level (self ):
404+ """
405+ Distribution is resolvable from a simple top-level symlink in RECORD.
406+ See #452.
407+ """
408+
409+ files : fixtures .FilesSpec = {
410+ "symlinked_pkg-1.0.0.dist-info" : {
411+ "METADATA" : """
412+ Name: symlinked-pkg
413+ Version: 1.0.0
414+ """ ,
415+ "RECORD" : "symlinked,,\n " ,
416+ },
417+ ".symlink.target" : {},
418+ "symlinked" : Symlink (".symlink.target" ),
419+ }
420+
421+ fixtures .build_files (files , self .site_dir )
422+ assert packages_distributions ()['symlinked' ] == ['symlinked-pkg' ]
423+
402424
403425class PackagesDistributionsEggTest (
404426 fixtures .EggInfoPkg ,
You can’t perform that action at this time.
0 commit comments