File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
src/horse_with_no_namespace Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ def apply():
3333 logged = True
3434
3535 # Only patch pkg_resources if it is installed...
36+ # (To do: at some point pkg_resources will be removed from setuptools.
37+ # Then we might have to add our own fake module.)
3638 try :
3739 import pkg_resources
3840 except ImportError :
@@ -42,9 +44,12 @@ def apply():
4244 # to update __path__ using pkgutil.extend_path instead
4345 def declare_namespace (packageName ):
4446 parent_locals = sys ._getframe (1 ).f_locals
45- parent_locals ["__path__" ] = pkgutil .extend_path (
46- parent_locals ["__path__" ], packageName
47- )
47+ # Sometimes declare_namespace is called from pkg_resources itself;
48+ # then there is no __path__ which needs to be updated.
49+ if "__path__" in parent_locals :
50+ parent_locals ["__path__" ] = pkgutil .extend_path (
51+ parent_locals ["__path__" ], packageName
52+ )
4853
4954 pkg_resources .declare_namespace = declare_namespace
5055
You can’t perform that action at this time.
0 commit comments