-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstart-python-project.sh
executable file
·71 lines (53 loc) · 1.68 KB
/
start-python-project.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
#!/bin/bash
set -e
README='project-readme.md'
cat << EOF
A script to install create a new Python project and virtual environment.
This will:
1. create a new project folder
2. create a new python 3 virtual environment in that folder
3. add a simple readme file in the project folder with instructions
Use this script at your own risk. It may not work on all Chromebooks or setups.
This has been tested on a clean powerwashed Google Pixelbook.
EOF
read -p "Press Enter to continue ... or Ctrl-C to cancel." START
echo
read -e -i "$HOME/project" -p "Input name of project folder to be created: " PROJECT
echo
echo "Finding Python versions installed"
for I in python3.10 python3.9 python3.8 python3.7 python3.6 python3.5 python3
do
if [[ $(which $I) != "" ]]
then
echo "- $I is installed and available at '$(which $I)'"
read -n 1 -p "Shall I use $I for the virtual environment? (y/n): " CONFIRM
echo
if [[ $CONFIRM == "Y" || $CONFIRM == "y" ]]
then
PYTHON=$(which $I)
break
fi
fi
done
if [[ $PYTHON == "" ]]
then
echo
echo "Error - You need to select one of the python versions."
exit 1
fi
echo
read -e -i ".venv" -p "Name of virtual environment to be created: " VENV
echo
echo "Creating '$PROJECT' project folder ..."
mkdir $PROJECT
echo
echo "Creating virtual environment $VENV ..."
virtualenv -p $PYTHON $PROJECT/$VENV
echo
echo "Virtual environment created at $PROJECT/$VENV "
echo "Activate it from the project directory by typing 'source venv/bin/activate'"
cp readme-files/$README $PROJECT
echo
echo "Check out the $README file in the project folder for more basic instructions."
echo
echo "Finished."