@@ -92,69 +92,69 @@ def is_library_module(module_name):
9292 ):
9393 return False
9494
95- # if module_name in sys.modules:
96- # return True
95+ if module_name in sys .modules :
96+ return True
9797
98- # try:
99- # importlib.import_module(module_name)
100- # return True
101- # except:
102- # return False
98+ try :
99+ importlib .import_module (module_name )
100+ return True
101+ except :
102+ return False
103103
104- if module_name not in sys .modules :
105- try :
106- __import__ (module_name )
107- except ImportError :
108- return False
104+ # if module_name not in sys.modules:
105+ # try:
106+ # __import__(module_name)
107+ # except ImportError:
108+ # return False
109109
110- module = sys .modules [module_name ]
110+ # module = sys.modules[module_name]
111111
112- # Built-in modules
113- if not hasattr (module , "__file__" ) or module .__file__ is None :
114- return True
112+ # # Built-in modules
113+ # if not hasattr(module, "__file__") or module.__file__ is None:
114+ # return True
115115
116- file_path = module .__file__
116+ # file_path = module.__file__
117117
118- # Check for standard library patterns
119- import sysconfig
118+ # # Check for standard library patterns
119+ # import sysconfig
120120
121- stdlib_path = sysconfig .get_path ("stdlib" )
121+ # stdlib_path = sysconfig.get_path("stdlib")
122122
123- # Direct match
124- if file_path .startswith (stdlib_path ):
125- return True
123+ # # Direct match
124+ # if file_path.startswith(stdlib_path):
125+ # return True
126126
127- # Handle different Python installations (Homebrew, pyenv, etc.)
128- # Look for common stdlib patterns: .../lib/python3.x/...
129- import re
127+ # # Handle different Python installations (Homebrew, pyenv, etc.)
128+ # # Look for common stdlib patterns: .../lib/python3.x/...
129+ # import re
130130
131- if (
132- re .search (r"/lib/python\d+\.\d+/" , file_path )
133- and "site-packages" not in file_path
134- ):
135- return True
131+ # if (
132+ # re.search(r"/lib/python\d+\.\d+/", file_path)
133+ # and "site-packages" not in file_path
134+ # ):
135+ # return True
136136
137- # Check if it's an installed package
138- if any (pkg_dir in file_path for pkg_dir in ["site-packages" , "dist-packages" ]):
139- return True # Regular installed package
137+ # # Check if it's an installed package
138+ # if any(pkg_dir in file_path for pkg_dir in ["site-packages", "dist-packages"]):
139+ # return True # Regular installed package
140140
141- # Check if it's an editable install (file outside site-packages but package is installed)
142- site_packages = sysconfig .get_path ("purelib" )
143- package_name = module_name .split ("." )[0 ]
141+ # # Check if it's an editable install (file outside site-packages but package is installed)
142+ # site_packages = sysconfig.get_path("purelib")
143+ # package_name = module_name.split(".")[0]
144144
145- import glob
145+ # import glob
146146
147- # Check for various editable install patterns
148- egg_links = glob .glob (os .path .join (site_packages , f"{ package_name } *.egg-link" ))
149- pth_files = glob .glob (os .path .join (site_packages , f"*{ package_name } *.pth" ))
150- editable_pth = glob .glob (
151- os .path .join (site_packages , f"__editable__.{ package_name } *.pth" )
152- )
147+ # # Check for various editable install patterns
148+ # egg_links = glob.glob(os.path.join(site_packages, f"{package_name}*.egg-link"))
149+ # pth_files = glob.glob(os.path.join(site_packages, f"*{package_name}*.pth"))
150+ # editable_pth = glob.glob(
151+ # os.path.join(site_packages, f"__editable__.{package_name}*.pth")
152+ # )
153153
154- if egg_links or pth_files or editable_pth :
155- return True # It's an editable install, still a library
154+ # if egg_links or pth_files or editable_pth:
155+ # return True # It's an editable install, still a library
156156
157- return False
157+ # return False
158158
159159
160160def import_module_from_file (file_path ):
0 commit comments