Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mmengine/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ def _is_builtin_module(module_name: str) -> bool:
origin_path = getattr(spec, 'origin', None)
if origin_path is None:
return False
# Handle frozen modules (e.g., os module in some Python distributions)
if origin_path == 'frozen':
return True
origin_path = osp.abspath(origin_path)
if ('site-package' in origin_path or 'dist-package' in origin_path
or not origin_path.startswith(
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [

[dependency-groups]
test = [
"aim<=3.17.5; sys_platform != 'win32'",
"aim<=3.17.5; sys_platform != 'win32' and python_version < '3.13'",
"bitsandbytes",
"clearml",
"coverage",
Expand Down Expand Up @@ -77,7 +77,7 @@ all = [
"termcolor",
"yapf",
"regex; sys_platform == 'win32'",
"aim<=3.17.5; sys_platform != 'win32'",
"aim<=3.17.5; sys_platform != 'win32' and python_version < '3.13'",
"bitsandbytes",
"clearml",
"coverage",
Expand Down
12 changes: 6 additions & 6 deletions tests/test_config/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from unittest import TestCase

import numpy
import numpy.compat
import numpy.fft
import numpy.linalg as linalg
from rich.progress import Progress

Expand Down Expand Up @@ -56,17 +56,17 @@ def test_lazy_module(self):

# 1.2 getattr as LazyAttr
self.assertIsInstance(lazy_numpy.linalg, LazyAttr)
self.assertIsInstance(lazy_numpy.compat, LazyAttr)
self.assertIsInstance(lazy_numpy.fft, LazyAttr)

# 1.3 Build module from LazyObject. amp and functional can be accessed
# 1.3 Build module from LazyObject. linalg and fft can be accessed
imported_numpy = lazy_numpy.build()
self.assertIs(imported_numpy.linalg, linalg)
self.assertIs(imported_numpy.compat, numpy.compat)
self.assertIs(imported_numpy.fft, numpy.fft)

# 1.4.1 Build module from LazyAttr
imported_linalg = lazy_numpy.linalg.build()
imported_compat = lazy_numpy.compat.build()
self.assertIs(imported_compat, numpy.compat)
imported_fft = lazy_numpy.fft.build()
self.assertIs(imported_fft, numpy.fft)
self.assertIs(imported_linalg, linalg)

# 1.4.2 build class method from LazyAttr
Expand Down
Loading