mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +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._installed_pkgs = installed_pkgs
|
||||||
self._maybe_local_mods = set()
|
self._maybe_local_mods = set()
|
||||||
self._local_mods = dict()
|
self._local_mods = dict()
|
||||||
|
self._relative_imports = set()
|
||||||
self._comparison_operator = comparison_operator
|
self._comparison_operator = comparison_operator
|
||||||
|
|
||||||
def extract_reqs(self, module_callback=None, entry_point_filename=None):
|
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 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 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(
|
modules, try_imports, local_mods = project_import_modules(
|
||||||
self._project_path, self._ignores)
|
self._project_path, self._ignores)
|
||||||
|
|
||||||
@ -149,7 +150,10 @@ class GenerateReqs(object):
|
|||||||
logger.info('Filtering modules ...')
|
logger.info('Filtering modules ...')
|
||||||
for module in modules:
|
for module in modules:
|
||||||
logger.info('Checking module: %s', module)
|
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
|
continue
|
||||||
if module in local_mods:
|
if module in local_mods:
|
||||||
self._maybe_local_mods.add(module)
|
self._maybe_local_mods.add(module)
|
||||||
|
@ -39,11 +39,14 @@ def project_import_modules(project_path, ignores):
|
|||||||
ignore_paths.add(Path(path).name)
|
ignore_paths.add(Path(path).name)
|
||||||
|
|
||||||
if os.path.isfile(project_path):
|
if os.path.isfile(project_path):
|
||||||
fake_path = Path(project_path).name
|
try:
|
||||||
with open(project_path, 'rb') as f:
|
fake_path = Path(project_path).name
|
||||||
fmodules, try_ipts = file_import_modules(fake_path, f.read())
|
with open(project_path, 'rb') as f:
|
||||||
modules |= fmodules
|
fmodules, try_ipts = file_import_modules(fake_path, f.read())
|
||||||
try_imports |= try_ipts
|
modules |= fmodules
|
||||||
|
try_imports |= try_ipts
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
cur_dir = project_path
|
cur_dir = project_path
|
||||||
for dirpath, dirnames, files in os.walk(os.path.abspath(project_path), followlinks=True):
|
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:
|
if '__init__.py' in files:
|
||||||
local_mods.append(os.path.basename(dirpath))
|
local_mods.append(os.path.basename(dirpath))
|
||||||
for file in py_files:
|
for file in py_files:
|
||||||
fpath = os.path.join(dirpath, file)
|
try:
|
||||||
fake_path = fpath.split(cur_dir)[1][1:]
|
fpath = os.path.join(dirpath, file)
|
||||||
with open(fpath, 'rb') as f:
|
fake_path = Path(fpath).relative_to(cur_dir).as_posix()
|
||||||
fmodules, try_ipts = file_import_modules(fake_path, f.read())
|
with open(fpath, 'rb') as f:
|
||||||
modules |= fmodules
|
fmodules, try_ipts = file_import_modules(fake_path, f.read())
|
||||||
try_imports |= try_ipts
|
modules |= fmodules
|
||||||
|
try_imports |= try_ipts
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
return modules, try_imports, local_mods
|
return modules, try_imports, local_mods
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user