File tree 3 files changed +35
-2
lines changed
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
+
1
8
v6.6.0
2
9
======
3
10
Original file line number Diff line number Diff line change @@ -981,30 +981,34 @@ def _topmost(name: PackagePath) -> Optional[str]:
981
981
return top if rest else None
982
982
983
983
984
- def _get_toplevel_name (name : PackagePath ) -> Optional [ str ] :
984
+ def _get_toplevel_name (name : PackagePath ) -> str :
985
985
"""
986
986
Infer a possibly importable module name from a name presumed on
987
987
sys.path.
988
988
989
989
>>> _get_toplevel_name(PackagePath('foo.py'))
990
990
'foo'
991
+ >>> _get_toplevel_name(PackagePath('foo'))
992
+ 'foo'
991
993
>>> _get_toplevel_name(PackagePath('foo.pyc'))
992
994
'foo'
993
995
>>> _get_toplevel_name(PackagePath('foo/__init__.py'))
994
996
'foo'
995
997
>>> _get_toplevel_name(PackagePath('foo.pth'))
998
+ 'foo.pth'
996
999
>>> _get_toplevel_name(PackagePath('foo.dist-info'))
1000
+ 'foo.dist-info'
997
1001
"""
998
1002
return _topmost (name ) or (
999
1003
# python/typeshed#10328
1000
1004
inspect .getmodulename (name ) # type: ignore
1005
+ or str (name )
1001
1006
)
1002
1007
1003
1008
1004
1009
def _top_level_inferred (dist ):
1005
1010
opt_names = set (map (_get_toplevel_name , always_iterable (dist .files )))
1006
1011
1007
- @pass_none
1008
1012
def importable_name (name ):
1009
1013
return '.' not in name
1010
1014
Original file line number Diff line number Diff line change 9
9
10
10
from . import fixtures
11
11
from ._context import suppress
12
+ from ._path import Symlink
12
13
from importlib_metadata import (
13
14
Distribution ,
14
15
EntryPoint ,
@@ -399,6 +400,27 @@ def test_packages_distributions_all_module_types(self):
399
400
400
401
assert not any (name .endswith ('.dist-info' ) for name in distributions )
401
402
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
+
402
424
403
425
class PackagesDistributionsEggTest (
404
426
fixtures .EggInfoPkg ,
You can’t perform that action at this time.
0 commit comments