Skip to content

Commit

Permalink
Add updates for Python 3.12 support
Browse files Browse the repository at this point in the history
Signed-off-by: BryceGattis <brycegattis@yahoo.com>
  • Loading branch information
BryceGattis committed Dec 21, 2024
1 parent cd02348 commit 5615e44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/rez/cli/selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import os
import sys
import importlib
import importlib.util
import inspect
import argparse
import shutil
Expand Down Expand Up @@ -56,7 +58,9 @@ def __call__(self, parser, namespace, values, option_string=None):
prefix = "test_"
for importer, name, ispkg in iter_modules([tests_dir]):
if not ispkg and name.startswith(prefix):
module = importer.find_module(name).load_module(name)
spec = importer.find_spec(name)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
name_ = name[len(prefix):]
all_module_tests.append(name_)
tests.append((name_, module))
Expand Down
5 changes: 3 additions & 2 deletions src/rez/plugin_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from rez.utils.logging_ import print_debug, print_warning
from rez.exceptions import RezPluginError
from zipimport import zipimporter
import importlib.util
import pkgutil
import os.path
import sys
Expand Down Expand Up @@ -157,10 +158,10 @@ def load_plugins(self):
# https://github.com/AcademySoftwareFoundation/rez/pull/218
# load_module will force reload the module if it's
# already loaded, so check for that
# TODO: Confirm if the force reload still happens after this change.
plugin_module = sys.modules.get(modname)
if plugin_module is None:
loader = importer.find_module(modname)
plugin_module = loader.load_module(modname)
plugin_module = importlib.import_module(modname)

elif os.path.dirname(plugin_module.__file__) != path:
if config.debug("plugins"):
Expand Down

0 comments on commit 5615e44

Please sign in to comment.