-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: script for creation of virtual python environment.
- Loading branch information
1 parent
085ac1e
commit 59ffc92
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
# | ||
# create_python_env.sh (C) 2023, Peter Sulyok | ||
# This script will install python in a virtual environment with project dependencies. | ||
# | ||
|
||
# Check the first command-line parameter. | ||
if [ "$1" = "" ]; | ||
then | ||
echo "Use: "$(basename "$0")" 3.12.1" | ||
exit -1 | ||
fi | ||
|
||
# Install the specified python version if it hasn't been already installed. | ||
python_version=$(pyenv version --bare|grep $1) | ||
if [[ "$python_version" = "" || "$?" = "1" ]]; | ||
then | ||
pyenv install $1 | ||
fi | ||
python_version=$1 | ||
|
||
# Select the python version locally. | ||
pyenv local $python_version | ||
|
||
# Create and activate a virtual environment. | ||
python -m venv .venv-$python_version | ||
. .venv-$python_version/bin/activate | ||
|
||
# Upgrade pip and install required python modules. | ||
pip install --upgrade pip | ||
pip install -r requirements-dev.txt | ||
pip install -r docs/requirements-docs.txt | ||
|
||
# Notify user about required activation. | ||
echo "" | ||
echo "Do not forget to activate the new Python virtual environment:" | ||
echo "-> source .venv-$python_version/bin/activate" |