PyDocs

Nav

Software Packaging and Distribution

EnvBuilder

venv

class (source) not Androidnot iOSnot WASI
  • 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.

By default, the builder makes the system (global) site-packages dir
*un*available to the created environment.

If invoked using the Python -m option, the default is to use copying
on Windows platforms but symlinks elsewhere. If instantiated some
other way, the default is to *not* use symlinks.

:param system_site_packages: If True, the system (global) site-packages
                             dir is available to created environments.
:param clear: If True, delete the contents of the environment directory if
              it already exists, before environment creation.
:param symlinks: If True, attempt to symlink rather than copy files into
                 virtual environment.
:param upgrade: If True, upgrade an existing virtual environment.
:param with_pip: If True, ensure pip is installed in the virtual
                 environment
:param prompt: Alternative terminal prefix for the environment.
:param upgrade_deps: Update the base venv modules to the latest on PyPI
:param scm_ignore_files: Create ignore files for the SCMs specified by the
                         iterable.
Changed in 3.4, 3.6, 3.7.2, 3.7.3, 3.9, 3.13
  • 3.4: Added the with_pip parameter
  • 3.6: Added the prompt parameter
  • 3.7.2: Windows now uses redirector scripts for python[w].exe instead of copying the actual binaries. In 3.7.2 only setup_python() does nothing unless running from a build in the source tree.
  • 3.7.3: Windows copies the redirector scripts as part of setup_python() instead of setup_scripts(). This was not the case in 3.7.2. When using symlinks, the original executables will be linked.
  • 3.9: Added the upgrade_deps parameter
  • 3.13: Added the scm_ignore_files parameter
Members of EnvBuilder

c

create
Create a virtual environment in a directory.
create_configuration
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.
create_git_ignore_file
Create a .gitignore file in the environment directory.

e

ensure_directories
Create the directories for the environment.

i

install_scripts
Install scripts into the created environment from a directory.

p

post_setup
Hook for post-setup modification of the venv.

s

setup_python
Set up a Python executable in the environment.
setup_scripts
Set up scripts into the created environment from a directory.

u

upgrade_dependencies
Upgrades the core venv dependency packages (currently pip) in the environment.
0 Examples
No examples for venv/EnvBuilder.
See Also
No see-alsos for venv/EnvBuilder
0 Notes
No notes for EnvBuilder