Skip to content

Commit

Permalink
fix(venv): add prompt for virtual env directory name, default .venv
Browse files Browse the repository at this point in the history
  • Loading branch information
fblanchetNaN authored and Julien00859 committed Apr 9, 2023
1 parent db2e680 commit 90a2f4e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions incipyt/tools/venv.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import os

from incipyt import commands, signals, tools
from incipyt import commands, project, signals, tools


class Venv(tools.Tool):
"""Scripts to add virtualenv to :class:`incipyt.project._Structure`."""

def add_to_structure(self):
"""Add venv configuration to `project.structure`, do nothing."""
signals.vcs_ignore.emit(pattern=".env/")
signals.vcs_ignore.emit(pattern="{VIRTUAL_ENV_DIRECTORY}/")

def pre(self, workon):
"""Run `python -m venv .env`.
:param workon: Work-on folder.
:type workon: :class:`pathlib.Path`
"""
env_path = workon / ".env"
project.environ.setdefault("VIRTUAL_ENV_DIRECTORY", ".venv")
env_path = workon / project.environ["VIRTUAL_ENV_DIRECTORY"]
commands.venv([os.fspath(env_path)])
commands.setenv_python_cmd(
env_path.resolve() / ("Scripts" if os.name == "nt" else "bin") / "python"
Expand Down

0 comments on commit 90a2f4e

Please sign in to comment.