Skip to content

Commit

Permalink
Need to be able to get venv path before creating
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Jul 4, 2018
1 parent 96c2517 commit 2dd6a1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,9 @@ def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
sys.executable,
"-m",
"virtualenv",
project.virtualenv_location,
"--prompt=({0})".format(project.name),
"--python={0}".format(python),
project.get_location_for_virtualenv(),
]

# Pass site-packages flag to virtualenv, if desired…
Expand Down
27 changes: 8 additions & 19 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,10 @@ def virtualenv_exists(self):

return False

@classmethod
def _get_virtualenv_location(cls, name):
venv = get_workon_home() / name
if not venv.exists():
return ""
return "{0}".format(venv)
def get_location_for_virtualenv(self):
if PIPENV_VENV_IN_PROJECT:
return os.path.join(self.project_directory, ".venv")
return str(get_workon_home().joinpath(self.virtualenv_name))

@classmethod
def _sanitize(cls, name):
Expand Down Expand Up @@ -316,19 +314,10 @@ def virtualenv_location(self):
return PIPENV_VIRTUALENV

# Use cached version, if available.
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.path.join(self.project_directory, ".venv")
self._virtualenv_location = loc
return loc
if not self._virtualenv_location:
assert self.project_directory, "project not created"
self._virtualenv_location = self.get_location_for_virtualenv()
return self._virtualenv_location

@property
def virtualenv_src_location(self):
Expand Down

0 comments on commit 2dd6a1a

Please sign in to comment.