mirror of
https://github.com/clearml/clearml
synced 2025-02-07 21:33:25 +00:00
Fix Windows support for install package analysis
This commit is contained in:
parent
7eedd30097
commit
24ab1ecc2d
@ -22,6 +22,7 @@ class GenerateReqs(object):
|
||||
self._installed_pkgs = installed_pkgs
|
||||
self._maybe_local_mods = set()
|
||||
self._local_mods = dict()
|
||||
self._relative_imports = set()
|
||||
self._comparison_operator = comparison_operator
|
||||
|
||||
def extract_reqs(self, module_callback=None, entry_point_filename=None):
|
||||
@ -55,7 +56,7 @@ class GenerateReqs(object):
|
||||
|
||||
# if we have any module/package we cannot find, take no chances and scan the entire project
|
||||
# if we have local modules and they are not just us.
|
||||
if num_local_mod or local_mods:
|
||||
if num_local_mod or local_mods or self._relative_imports:
|
||||
modules, try_imports, local_mods = project_import_modules(
|
||||
self._project_path, self._ignores)
|
||||
|
||||
@ -149,7 +150,10 @@ class GenerateReqs(object):
|
||||
logger.info('Filtering modules ...')
|
||||
for module in modules:
|
||||
logger.info('Checking module: %s', module)
|
||||
if not module or module.startswith('.'):
|
||||
if not module:
|
||||
continue
|
||||
if module.startswith('.'):
|
||||
self._relative_imports.add(module)
|
||||
continue
|
||||
if module in local_mods:
|
||||
self._maybe_local_mods.add(module)
|
||||
|
@ -39,11 +39,14 @@ def project_import_modules(project_path, ignores):
|
||||
ignore_paths.add(Path(path).name)
|
||||
|
||||
if os.path.isfile(project_path):
|
||||
fake_path = Path(project_path).name
|
||||
with open(project_path, 'rb') as f:
|
||||
fmodules, try_ipts = file_import_modules(fake_path, f.read())
|
||||
modules |= fmodules
|
||||
try_imports |= try_ipts
|
||||
try:
|
||||
fake_path = Path(project_path).name
|
||||
with open(project_path, 'rb') as f:
|
||||
fmodules, try_ipts = file_import_modules(fake_path, f.read())
|
||||
modules |= fmodules
|
||||
try_imports |= try_ipts
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
cur_dir = project_path
|
||||
for dirpath, dirnames, files in os.walk(os.path.abspath(project_path), followlinks=True):
|
||||
@ -70,12 +73,15 @@ def project_import_modules(project_path, ignores):
|
||||
if '__init__.py' in files:
|
||||
local_mods.append(os.path.basename(dirpath))
|
||||
for file in py_files:
|
||||
fpath = os.path.join(dirpath, file)
|
||||
fake_path = fpath.split(cur_dir)[1][1:]
|
||||
with open(fpath, 'rb') as f:
|
||||
fmodules, try_ipts = file_import_modules(fake_path, f.read())
|
||||
modules |= fmodules
|
||||
try_imports |= try_ipts
|
||||
try:
|
||||
fpath = os.path.join(dirpath, file)
|
||||
fake_path = Path(fpath).relative_to(cur_dir).as_posix()
|
||||
with open(fpath, 'rb') as f:
|
||||
fmodules, try_ipts = file_import_modules(fake_path, f.read())
|
||||
modules |= fmodules
|
||||
try_imports |= try_ipts
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return modules, try_imports, local_mods
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user