From 76e7b3e63f3a3ca97af2961a04be3376e6c007b4 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Thu, 5 Jul 2018 01:35:34 +0800 Subject: [PATCH] More explicit failures --- pipenv/core.py | 6 +++++- pipenv/project.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index 918f9066..a14e1f68 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -102,7 +102,11 @@ if PIPENV_NOSPIN: def which(command, location=None, allow_global=False): if not allow_global and location is None: - location = project.virtualenv_location or os.environ.get("VIRTUAL_ENV") + location = ( + project.virtualenv_location + or os.environ.get("VIRTUAL_ENV", "") + ) + assert location, "virtual environment not created" if not allow_global: if os.name == "nt": p = find_windows_executable(os.path.join(location, "Scripts"), command) diff --git a/pipenv/project.py b/pipenv/project.py index c13cf597..6139112e 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -319,12 +319,14 @@ class Project(object): if self._virtualenv_location: return self._virtualenv_location + assert self.project_directory, "project not created" + # Default mode. if not self.is_venv_in_project(): loc = self._get_virtualenv_location(self.virtualenv_name) # The user wants the virtualenv in the project. else: - loc = os.sep.join(self.pipfile_location.split(os.sep)[:-1] + [".venv"]) + loc = os.path.join(self.project_directory, ".venv") self._virtualenv_location = loc return loc