Fix Python2 pigar compatibility

This commit is contained in:
allegroai 2021-08-30 20:56:10 +03:00
parent cab63faef3
commit 08f01967ce
2 changed files with 8 additions and 1 deletions

View File

@ -5,6 +5,8 @@ from __future__ import print_function, division, absolute_import
import os
import codecs
import six
from .reqs import project_import_modules, is_std_or_local_lib, is_base_module
from .utils import lines_diff
from .log import logger
@ -104,7 +106,9 @@ class GenerateReqs(object):
continue
# if this is a folder of our project, we can safely ignore it
if os.path.commonpath([project_path]) == os.path.commonpath([project_path, mod_path]):
if (six.PY3 and os.path.commonpath([project_path]) == os.path.commonpath([project_path, mod_path])) or \
(six.PY2 and
os.path.commonprefix([project_path]) == os.path.commonprefix([project_path, mod_path])):
continue
relpath = os.path.relpath(self._local_mods[name], self._project_path)

View File

@ -303,6 +303,9 @@ def is_std_or_local_lib(name):
if isinstance(module_info[0], FileType):
module_info[0].close() # noqa
mpath = module_info[1] # noqa
# make sure we remove built-in modules
if mpath and not os.path.exists(mpath):
mpath = None
else:
module_info = None
try: