This repository was archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·58 lines (51 loc) · 1.57 KB
/
setup.sh
File metadata and controls
executable file
·58 lines (51 loc) · 1.57 KB
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
#!/bin/bash
# Set up pyenv
if ! command -v pyenv &> /dev/null
then
echo "pyenv could not be found, please install pyenv first."
exit 1
fi
# Initialize pyenv
export PATH="$HOME/.pyenv/bin:$PATH"s
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# Set environment variables from chartify.env file
if [ -f chartify.env ]; then
export $(grep -v '^#' chartify.env | xargs)
else
echo "chartify.env file not found. Please create the file with the necessary environment variables."
exit 1
fi
# Check if Python is installed and set the version
if command -v python3 &> /dev/null; then
PYTHON_VERSION=$(python3 --version | awk '{print $2}')
else
echo "Python is not installed. Please install Python first."
exit 1
fi
# Check if the specified Python version is installed
if ! pyenv versions --bare | grep -q "^${PYTHON_VERSION}$"; then
echo "Python version ${PYTHON_VERSION} is not installed. Falling back to system Python."
unset PYTHON_VERSION
else
# Set the local Python version
pyenv local ${PYTHON_VERSION}
fi
# Create and activate virtual environment if it doesn't exist
if ! pyenv virtualenvs --bare | grep -q "^chartify-env$"; then
pyenv virtualenv chartify-env
if [ $? -ne 0 ]; then
echo "Failed to create virtual environment."
exit 1
fi
else
echo "Virtual environment 'chartify-env' already exists."
fi
pyenv activate chartify-env
# Install requirements
pip install -r requirements.txt
# Run Flask application
flask run
#deactivate virtual environment when app closes
pyenv deactivate