dephell venv entrypoint¶
The command creates a script in user bin dir that does the next things:
- Export env vars that specified in
vars
dictionary in the config. - Sources dotenv file specified in
dotenv
configuration. - Changes current dir for the command on the project path.
- Runs
command
in thevenv
.
Before making the script, the command also does a few more things:
- Creates the given
venv
if it doesn’t exist yet. - Installs the given executable from the
command
if it’s not installed in thevenv
yet.
Example¶
DepHell itself has the next section in pyproject.toml
:
[tool.dephell.typing]
from = {format = "poetry", path = "pyproject.toml"}
command = "mypy --ignore-missing-imports --allow-redefinition dephell"
First of all, let’s create a virtual environment and install dependencies:
$ dephell venv create --env=typing
$ dephell deps install --env=typing
And now we can expose entrypoint for the command:
$ dephell venv entrypoint --env=typing
WARNING executable is not found in venv, trying to install... (executable=mypy)
INFO build dependencies graph...
INFO installation... (executable=/home/gram/.local/share/dephell/venvs/dephell-nLn6/typing/bin/python3.8, packages=5)
Collecting mypy-extensions==0.4.3
Collecting typed-ast==1.4.1
Collecting typing-extensions==3.7.4.1
Collecting mypy==0.770
Installing collected packages: mypy-extensions, typed-ast, typing-extensions, mypy
Successfully installed mypy-0.770 mypy-extensions-0.4.3 typed-ast-1.4.1 typing-extensions-3.7.4.1
INFO installed
INFO script created (path=/home/gram/.local/bin/dephell-mypy)
MyPy isn’t specified in from
dependency file and wasn’t installed by dephell deps install
. So, dephell venv entrypoint
does the installation by itself. Another thing to note is that the command has generated script name on the base of project name and the given executable (dephell-mypy
). You can explicitly specify binary name to use:
dephell venv entrypoint --env=typing dephell-typing
Let’s see what’s inside the script (cat /home/gram/.local/bin/dephell-mypy
):
#!/usr/bin/env bash
cd /home/gram/Documents/dephell
/home/gram/.local/share/dephell/venvs/dephell-nLn6/typing/bin/mypy --ignore-missing-imports --allow-redefinition dephell $@
Now we can call the given script from another project without changing dirs and poking around with environments:
dephell-mypy --help
Use cases¶
- Make a quick alias for a command you run really often. In the example above, we can type
dephell-mypy
instead ofdephell venv run --env=typing
and save a few precious seconds of life every day. - Create entrypoint to quickly get inside of project’s ipython shell on your production server:
dephell venv entrypoint --command=ipython
- Expose your project’s entrypoint from it’s venv into the system. Almost the same as dephell jail install but for your local project.
See also¶
- dephell venv create to create a venv.
- dephell deps install to install project deps in a venv.
- dephell venv run to run a command in a venv.
- dephell venv shell to activate a venv for your current shell.
- dephell jail install to install a third-party CLI tool into a separate venv.
- dephell project register to make the project importable from anywhere in your system.