-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
83 lines (62 loc) · 2.12 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
date
# Uncomment line below if you need to debug this script
# set -o xtrace
PS4='${LINENO}: '
# Usage:
# Call bash setup.sh if you want to spawn a subprocess and avoid changing directory after this script is finished
# or
# Call using source setup.sh to persist directory changes and also persist virtual environment activation in parent shell
# References: [Script to change current directory (cd, pwd)](https://unix.stackexchange.com/a/27140)
# [Bash Source Command](https://linuxize.com/post/bash-source-command/)
# Reference to function creation and calls: https://devqa.io/create-call-bash-functions/
function initializeDirectory() {
cd .venv312/Scripts
}
function activateEnvironment(){
source ./activate
}
function basicSetup(){
# where python
# This should display: Python 3.12.1
python.exe --version
# This command should display something like:
# pip 23.3.2 from {repository root folder}\.venv312\Lib\site-packages\pip (python 3.12)
python -m pip -V
python -m pip install pip-tools
python.exe -m pip install --upgrade pip
}
function runPipCompile(){
# https://pip.pypa.io/en/stable/topics/secure-installs/
# https://pip-tools.readthedocs.io/en/latest/cli/pip-compile/
pip-compile --generate-hashes --rebuild --no-strip-extras --emit-find-links ./../../requirements.in
}
function installRequiredDepedencies(){
python -m pip install -r ./../../requirements.txt
}
function freezeAllDependenciesInASeparateFile()
{
python -m pip freeze --all > ./../../requirementsALL.txt
}
function createEnvironment()
{
bash create_python3.12_environment.sh "$1"
creationCode=$?
if [[ $creationCode != 0 ]]
then
echo ""
echo "Since environment was not created correctly, the final setup of dependencies will not be performed now"
exit 1
fi
}
# Get the directory on which script was called
currentDirectory=$(pwd)
createEnvironment
initializeDirectory
activateEnvironment
basicSetup
runPipCompile
installRequiredDepedencies
freezeAllDependenciesInASeparateFile
# Restore the directory on which script was called
cd $currentDirectory