-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·135 lines (109 loc) · 3.38 KB
/
install.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# Script name: install-deps.sh
# Description: Check system dependencies for Tracklistify
# Configuration
VENV_DIR=".venv"
PYTHON="python3"
MIN_PYTHON_VERSION="3.11"
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Function to print status messages
print_status() {
echo -e "${GREEN}==>${NC} $1"
}
# Function to print warnings
print_warning() {
echo -e "${YELLOW}Warning:${NC} $1"
}
# Function to print errors
print_error() {
echo -e "${RED}Error:${NC} $1"
}
# Check Python version
check_python_version() {
local python_version
python_version=$($PYTHON --version 2>&1 | cut -d' ' -f2)
# Convert versions to comparable integers (e.g., 3.11.1 -> 3011001)
local min_version_int=$(echo $MIN_PYTHON_VERSION | awk -F. '{ printf("%d%03d%03d\n", $1, $2, $3) }')
local current_version_int=$(echo $python_version | awk -F. '{ printf("%d%03d%03d\n", $1, $2, $3) }')
if [ "$current_version_int" -lt "$min_version_int" ]; then
print_error "Python version must be >= $MIN_PYTHON_VERSION (found $python_version)"
exit 1
fi
}
# Check if Python is installed
check_python() {
if ! command -v $PYTHON &> /dev/null; then
print_error "Python 3 is not installed"
exit 1
fi
check_python_version
}
# Check if system has required system dependencies
check_system_deps() {
local missing_deps=()
# Check for poetry
if ! command -v poetry &> /dev/null; then
echo "Poetry is not installed."
missing_deps+=("poetry")
fi
# Check for ffmpeg
if ! command -v ffmpeg &> /dev/null; then
echo "FFmpeg is not installed."
missing_deps+=("ffmpeg")
fi
# Check for git (needed for setuptools_scm)
if ! command -v git &> /dev/null; then
echo "Git is not installed."
missing_deps+=("git")
fi
# Check for rustc (needed for shazamio-core)
if ! command -v rustc &> /dev/null; then
missing_deps+=("rustup")
fi
# If there are missing dependencies, print instructions
if [ ${#missing_deps[@]} -ne 0 ]; then
print_error "Missing system dependencies: ${missing_deps[*]}"
echo "Please install them using your package manager:"
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "brew install ${missing_deps[*]}"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "sudo apt-get install ${missing_deps[*]}"
fi
exit 1
fi
}
# Install package and dependencies
install_package() {
print_status "Installing package and dependencies..."
if [ "$1" == "--dev" ]; then
print_status "Installing in development mode with dev dependencies..."
poetry install --with dev
poetry run pre-commit install
else
print_status "Installing in default mode..."
poetry install
fi
}
# Main execution
main() {
print_status "Starting Tracklistify setup..."
# Check Python installation
check_python
# Check system dependencies
check_system_deps
# Install package and dependencies
install_package "$1"
print_status "Setup complete! You can now:"
echo " "
echo "1. Edit .env with your credentials"
echo "2. Activate the virtual environment:"
echo " poetry shell"
echo "3. Run Tracklistify:"
echo " tracklistify <command>"
}
# Run main function with all arguments
main "$@"