Reputation: 27375
I'm looking for a way to do a single-command installation of the whole python application into a venv
by a specific path.
I did some research about this topic and particularly in this thread there was a discussion about Makefile
automation of the process. It also suggests to use pyinvoke, which appeared to me as a command line commands wrapped into python. So I currently wrote the following simple on-the-knee shell script:
install_venv.sh
#!/bin/bash
PYTHON="$1"
VENV_PATH="$2"
SOURCE_ROOT="$(dirname "$(readlink -f "$BASH_SOURCE")")"
echo "$PYTHON"
echo "$VENV_PATH"
echo "$SOURCE_ROOT"
cd $SOURCE_ROOT
$PYTHON -m venv $VENV_PATH
source "$VENV_PATH/bin/activate"
python -m pip install -r "$SOURCE_ROOT/requirements.txt"
python setup.py install
This script can be run, say as ./install_venv.sh python3.7 /tmp/test_venv
. It does not handle the case if venv
already exists by the path, but it can be extended in a straightforward way.
It looks like a very common task, so maybe setuptools
already has a way to do so or writing such scripts is still necessary? Or what is the preferred way?
Upvotes: 1
Views: 6226
Reputation: 22275
Not exactly sure what the true intention is...
Maybe one of these tools can help:
These tools allow you to install a Python application with all their required dependencies in an isolated way. Some are based on virtual environments some are not.
Maybe you are looking for a tool such as poetry (or pipenv but not sure if it's still being maintained or not).
More simple and straightforward, there is this plugin for setuptools:
Upvotes: 2