Skip to content

Commit

Permalink
handling archived lib when scanning rezplugins (AcademySoftwareFounda…
Browse files Browse the repository at this point in the history
…tion#1108)

e.g. when working with embedded python
  • Loading branch information
davidlatwe committed Jul 26, 2021
1 parent 88918d7 commit 4df71fd
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/rez/plugin_managers.py
Expand Up @@ -8,6 +8,7 @@
from rez.utils.logging_ import print_debug, print_warning
from rez.vendor.six import six
from rez.exceptions import RezPluginError
from zipimport import zipimporter
import pkgutil
import os.path
import sys
Expand Down Expand Up @@ -302,9 +303,22 @@ def rezplugins_module_paths(self):
if not ispkg:
continue

module_path = os.path.join(importer.path, name)
if os.path.isdir(os.path.join(module_path, "rezplugins")):
paths.append(module_path)
if isinstance(importer, zipimporter):
init_path = os.path.join(name, "rezplugins", "__init__.pyc")
try:
importer.get_data(init_path)
except (IOError, OSError):
continue
else:
module_path = os.path.join(importer.archive, name)

else:
module_path = os.path.join(importer.path, name)
init_path = os.path.join(module_path, "rezplugins", "__init__.py")
if not os.path.isfile(init_path):
continue

paths.append(module_path)

return paths

Expand Down

0 comments on commit 4df71fd

Please sign in to comment.