Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More granular control over PIPENV_VENV_IN_PROJECT variable. #5026

Merged
merged 3 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pipenv/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,13 @@ def initialize(self):
Default is 120 seconds, an arbitrary number that seems to work.
"""

self.PIPENV_VENV_IN_PROJECT = bool(os.environ.get("PIPENV_VENV_IN_PROJECT"))
self.PIPENV_VENV_IN_PROJECT = os.environ.get("PIPENV_VENV_IN_PROJECT")
if self.PIPENV_VENV_IN_PROJECT is not None:
self.PIPENV_VENV_IN_PROJECT = self.PIPENV_VENV_IN_PROJECT.lower() in (
"true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that some of these are already defined above with _true_values

"1",
"t",
)
"""If set, creates ``.venv`` in your project directory.
oz123 marked this conversation as resolved.
Show resolved Hide resolved

Default is to create new virtual environments in a global location.
Expand Down
4 changes: 3 additions & 1 deletion pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ def requirements_exists(self):

def is_venv_in_project(self):
# type: () -> bool
if self.s.PIPENV_VENV_IN_PROJECT is False:
return False
return self.s.PIPENV_VENV_IN_PROJECT or (
self.project_directory
and os.path.isdir(os.path.join(self.project_directory, ".venv"))
Expand Down Expand Up @@ -288,7 +290,7 @@ def get_location_for_virtualenv(self):
return str(get_workon_home().joinpath(self.virtualenv_name))

# If content looks like a path, use it as a relative path.
# Otherwise use directory named after content in WORKON_HOME.
# Otherwise, use directory named after content in WORKON_HOME.
if looks_like_dir(name):
path = Path(self.project_directory, name)
return path.absolute().as_posix()
Expand Down