On this page
venv.EnvBuilder
Prev: venv.create | Up: venv | Next: venv.main
Rel: venv.create, venv.main
Ref: docs.python.org — venv.EnvBuilder
Tags: #public #python3 #stdlib #venv
Import
import venv
from venv import EnvBuilder
Signature & Overview
venv.EnvBuilder(system_site_packages=False, clear=False, symlinks=False, upgrade=False, with_pip=False, prompt=None, upgrade_deps=False, *, scm_ignore_files=frozenset())
This class exists to allow virtual environment creation to be customized. The constructor parameters determine the builder's behaviour when called upon to create a virtual environment.
Methods & Attributes
EnvBuilder.clear_directory(self, path)—EnvBuilder.clear_directorymethod/property.EnvBuilder.create(self, env_dir)— Create a virtual environment in a directory.EnvBuilder.create_configuration(self, context)— Create a configuration file indicating where the environment's Python was copied from, and whether the system site-packages should be made available in the environment.EnvBuilder.create_git_ignore_file(self, context)— Create a .gitignore file in the environment directory.EnvBuilder.ensure_directories(self, env_dir)— Create the directories for the environment.EnvBuilder.install_scripts(self, context, path)— Install scripts into the created environment from a directory.EnvBuilder.post_setup(self, context)— Hook for post-setup modification of the venv. Subclasses may install additional packages or scripts here, add activation shell scripts, etc.EnvBuilder.replace_variables(self, text, context)— Replace variable placeholders in script text with context-specific variables.EnvBuilder.setup_python(self, context)— Set up a Python executable in the environment.EnvBuilder.setup_scripts(self, context)— Set up scripts into the created environment from a directory.EnvBuilder.symlink_or_copy(self, src, dst, relative_symlinks_ok=False)— Try symlinking a file, and if that fails, fall back to copying.EnvBuilder.upgrade_dependencies(self, context)—EnvBuilder.upgrade_dependenciesmethod/property.
Usage
import venv
builder = venv.EnvBuilder(with_pip=False, symlinks=True)
assert builder.with_pip is False
Gotchas
- Subclass
EnvBuilderand overridepost_setup()to install starter packages automatically.
REPL Inspect
from venv import EnvBuilder
help(EnvBuilder)
Linked from
Related notes
- tuts/python3/stdlib_module/venv/create Linked here; links to this page; shared tags: #stdlib, #venv
- tuts/python3/stdlib_module/venv/main Linked here; links to this page; shared tags: #stdlib, #venv
- tuts/python3/stdlib_module/venv Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib