pyproject-devenv¶
Create virtual environments using pyproject.toml metadata.
Installation¶
python3 -m pip install pyproject-devenv --user
python3 -m pip install git+https://github.com/repo-helper/pyproject-devenv@master --user
Contents¶
Usage¶
pyproject-devenv
creates a virtualenv using metadata defined in pyproject.toml
.
Configuration¶
pyproject-devenv
is configured using the project table in pyproject.toml
,
as defined in PEP 621.
At a minimum, a value must be provided for name,
and dependencies must have a value or be marked as dynamic.
A value can also be provided for optional-dependencies, but this cannot be dynamic.
Any requirements listed in dependencies or optional-dependencies are installed.
pyproject-devenv
will also install anything listed in build-system.requires
,
which lists the project’s build dependencies.
Refer to PEP 518 for more information on the build-system
table.
Any requirements listed in <pyproject_dir>/tests/requirements.txt
are also installed if the file exists.
Command Line Usage¶
Create virtual environments using pyproject.toml metadata.
devenv [OPTIONS] [DEST]
Options
-
-U
,
--upgrade
¶
Upgrade all specified packages to the newest available version.
-
-v
,
--verbose
¶
Show verbose output.
-
--colour
,
--no-colour
¶
Whether to use coloured output.
-
-T
,
--traceback
¶
Show the complete traceback on error.
-
--version
¶
Show the version and exit.
Arguments
-
DEST
¶
The directory to create the virtual environment in.
Optional argument. Default
'venv'
Example Configuration¶
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel"] # PEP 508 specifications.
[project]
name = "spam"
version = "2020.0.0"
description = "Lovely Spam! Wonderful Spam!"
dependencies = [
"httpx",
"gidgethub[httpx]>4.0.0",
"django>2.1; os_name != 'nt'",
"django>2.0; os_name == 'nt'"
]
[project.optional-dependencies]
test = [
"pytest[testing]<5.0.0",
"pytest-cov"
]
Then run:
pyproject-devenv
Successfully created development virtualenv.
Output of pip list
:
Public API¶
Create virtual environments using pyproject.toml
metadata.
Exceptions:
Base |
|
|
|
|
|
Functions:
|
Create a “devenv”. |
-
mkdevenv
(project_dir, venv_dir='venv', *, verbosity=1, upgrade=False)[source]¶ Create a “devenv”.
- Parameters
project_dir (
Union
[str
,Path
,PathLike
]) – The root of the project to create the devenv for.venv_dir (
Union
[str
,Path
,PathLike
]) – The directory to create the devenv in, relative torepo_dir
. Default'venv'
.verbosity (
int
) – The verbosity of the function.0
= quiet,2
= very verbose. Default1
.upgrade (
bool
) – Whether to upgrade all specified packages to the newest available version. DefaultFalse
.
- Return type
-
exception
BaseInstallError
[source]¶ Bases:
RuntimeError
Base
Exception
to indicate an error occurred when installing packages.
-
exception
InstallFromFileError
(filename)[source]¶ Bases:
pyproject_devenv.BaseInstallError
Exception
to indicate an error occurred when installing packages from a requirements file.
-
exception
InstallError
(*requirements)[source]¶ Bases:
pyproject_devenv.BaseInstallError
Exception
to indicate an error occurred when installing packages.- Parameters
*requirements (
Union
[str
,Requirement
]) – The requirements being installed.
pyproject_devenv.config
¶
Read the pyproject-devenv
config from pyproject.toml
.
Classes:
|
|
|
|
|
Parser for a reduced subset of the PEP 621 metadata from |
Functions:
|
Load the |
-
load_toml
(filename)[source]¶ Load the
pyproject-devenv
configuration mapping from the given TOML file.- Parameters
- Return type
-
class
ConfigTracebackHandler
[source]¶ Bases:
pyproject_parser.cli.ConfigTracebackHandler
consolekit.tracebacks.TracebackHandler
which handlesdom_toml.parser.BadConfigError
andBaseInstallError
.
-
typeddict
ConfigDict
[source]¶ Bases:
TypedDict
typing.TypedDict
representing the configuration returned byload_toml()
.- Required Keys
name (
str
)dependencies (
List
[ComparableRequirement
])optional_dependencies (
Dict
[str
,List
[ComparableRequirement
]])build_dependencies (
Optional
[List
[ComparableRequirement
]])
-
class
PEP621Parser
[source]¶ Bases:
PEP621Parser
Parser for a reduced subset of the PEP 621 metadata from
pyproject.toml
.-
keys
= ['name', 'dependencies', 'optional-dependencies']¶ -
The list of keys parsed from
pyproject.toml
-
parse
(config, set_defaults=False)[source]¶ Parse the TOML configuration.
- Parameters
set_defaults (
bool
) – IfTrue
, the values inself.defaults
andself.factories
will be set as defaults for the returned mapping. DefaultFalse
.
- Return type
-
Downloading source code¶
The pyproject-devenv
source code is available on GitHub,
and can be accessed from the following URL: https://github.com/repo-helper/pyproject-devenv
If you have git
installed, you can clone the repository with the following command:
git clone https://github.com/repo-helper/pyproject-devenv
Cloning into 'pyproject-devenv'...
remote: Enumerating objects: 47, done.
remote: Counting objects: 100% (47/47), done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 173 (delta 16), reused 17 (delta 6), pack-reused 126
Receiving objects: 100% (173/173), 126.56 KiB | 678.00 KiB/s, done.
Resolving deltas: 100% (66/66), done.

Downloading a ‘zip’ file of the source code¶
Building from source¶
The recommended way to build pyproject-devenv
is to use tox:
tox -e build
The source and wheel distributions will be in the directory dist
.
If you wish, you may also use pep517.build or another PEP 517-compatible build tool.
License¶
pyproject-devenv
is licensed under the MIT License
A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.
Permissions | Conditions | Limitations |
---|---|---|
|
|
Copyright (c) 2021 Dominic Davis-Foster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
View the Function Index or browse the Source Code.