Skip to content

Commit

Permalink
Merge pull request #18 from sarugaku/pipenv-2421-setuppy-modulenotfou…
Browse files Browse the repository at this point in the history
…nderror

Be more resilient when running setup.py
  • Loading branch information
techalchemy authored Jun 26, 2018
2 parents 83d3b9f + f2500c6 commit d2c3b50
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/18.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue with resolving certain packages which imported and executed other libraries (such as ``versioneer``) during ``setup.py`` execution.
2 changes: 1 addition & 1 deletion src/requirementslib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding=utf-8 -*-
__version__ = "1.0.6"
__version__ = "1.0.7"


from .exceptions import RequirementError
Expand Down
6 changes: 5 additions & 1 deletion src/requirementslib/models/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,14 @@ def get_name(self):
):
from distutils.core import run_setup

old_curdir = os.path.abspath(os.getcwd())
try:
os.chdir(str(self.setup_path.parent))
dist = run_setup(self.setup_path.as_posix(), stop_after="init")
name = dist.get_name()
except (FileNotFoundError, IOError) as e:
dist = None
except (NameError, RuntimeError) as e:
except Exception as e:
from .._compat import InstallRequirement, make_abstract_dist

try:
Expand All @@ -257,6 +259,8 @@ def get_name(self):
name = dist.project_name
except (TypeError, ValueError, AttributeError) as e:
dist = None
finally:
os.chdir(old_curdir)
hashed_loc = hashlib.sha256(loc.encode("utf-8")).hexdigest()
hashed_name = hashed_loc[-7:]
if not name or name == "UNKNOWN":
Expand Down

0 comments on commit d2c3b50

Please sign in to comment.