More explicit failures

This commit is contained in:
Tzu-ping Chung
2018-07-05 01:35:34 +08:00
parent 1d3f46653c
commit 76e7b3e63f
2 changed files with 8 additions and 2 deletions
+5 -1
View File
@@ -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)
+3 -1
View File
@@ -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