-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·62 lines (51 loc) · 2.08 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·62 lines (51 loc) · 2.08 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
59
60
61
62
#!/bin/bash
# ------------------------------------------------------------------------
# This is the setup.sh script for the dev-cli project.
# It is used to set up the environment and install dependencies for the dev-cli
# command-line tool. The script performs the following tasks:
# - Checks if Python 3 and the venv module are installed.
# - Creates a virtual environment (venv) to isolate the project's dependencies.
# - Installs all required dependencies from requirements.txt or setup.py.
# - Installs the dev-cli package globally in editable mode.
# - Ensures that the dev-cli tool is available for use in any directory.
# ------------------------------------------------------------------------
# Exit the script if any command fails
set -e
# Get the current project directory
PROJECT_DIR="$(pwd)"
# 1. Check if Python and venv are installed
echo "Checking for Python and venv..."
if ! command -v python3 &> /dev/null
then
echo "Python3 is not installed. Please install Python 3."
exit 1
fi
if ! command -v python3 -m venv &> /dev/null
then
echo "venv module is not available. Installing virtualenv..."
python3 -m pip install --user virtualenv
fi
# 2. Create a virtual environment
echo "Creating virtual environment..."
python3 -m venv venv
# 3. Activate the virtual environment
echo "Activating the virtual environment..."
source venv/bin/activate
# 4. Install dependencies from requirements.txt (or setup.py if no requirements.txt)
echo "Installing dependencies..."
if [[ -f "$PROJECT_DIR/requirements.txt" ]]; then
# If requirements.txt exists, install the packages
pip install -r "$PROJECT_DIR/requirements.txt"
else
# If no requirements.txt, install from setup.py
echo "No requirements.txt found, installing from setup.py..."
pip install .
fi
# 5. Install the dev-cli package globally in editable mode
echo "Installing dev-cli globally in editable mode..."
pip install -e .
# 6. Deactivate the virtual environment after setup is complete
echo "Deactivating the virtual environment..."
deactivate
# Final message
echo "Setup complete! You can now use dev-cli globally."