-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·187 lines (148 loc) · 6.62 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/bash
# Determine OS and Architecture
OS=$(uname -s)
ARCH=$(uname -m)
# Determine correct platform tag based on OS and architecture
case "$OS" in
Darwin)
if [[ "$ARCH" == "arm64" ]]; then
PLATFORM_TAG="macosx_11_0_arm64"
else
PLATFORM_TAG="macosx_10_9_x86_64"
fi
;;
Linux)
PLATFORM_TAG="linux_x86_64"
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac
# Get latest tag using GitHub API
LATEST_TAG=$(curl -s "https://api.github.com/repos/ecotaxa/cytosense_to_ecotaxa_pipeline/releases/latest" | jq -r '.tag_name')
if [[ -z "$LATEST_TAG" ]]; then
echo "Error getting latest tag. Exiting."
exit 1
fi
# Remove the "v" prefix if it exists
TAG_WITHOUT_V="${LATEST_TAG#v}"
# Check for --github flag
if [[ "$1" == "--github" ]]; then
WHEEL_FILE_NAME="cytosense_to_ecotaxa_pipeline-${TAG_WITHOUT_V}-py3-none-${PLATFORM_TAG}.whl"
WHEEL_URL="https://github.com/ecotaxa/cytosense_to_ecotaxa_pipeline/releases/download/${LATEST_TAG}/${WHEEL_FILE_NAME}"
echo "System architecture: $ARCH"
echo "Using platform tag: $PLATFORM_TAG"
echo "Latest tag: $LATEST_TAG"
echo "Tag without 'v': $TAG_WITHOUT_V"
echo "Wheel file name: $WHEEL_FILE_NAME"
echo "Wheel URL: $WHEEL_URL"
# Download the wheel file
WHEEL_FILE="/tmp/${WHEEL_FILE_NAME}"
echo "Downloading wheel from: $WHEEL_URL"
if ! curl -s -L "$WHEEL_URL" -o "$WHEEL_FILE"; then
echo "Error downloading wheel file. Exiting."
exit 1
fi
if [[ ! -f "$WHEEL_FILE" ]]; then
echo "Downloaded file not found: $WHEEL_FILE"
exit 1
fi
echo "-------------------------------------------------------------"
ls -l "$WHEEL_FILE"
echo "-------------------------------------------------------------"
# Verify the file is actually a wheel
if ! unzip -l "$WHEEL_FILE" >/dev/null 2>&1; then
echo "Error: Downloaded file is not a valid wheel file"
exit 1
fi
echo "Downloaded wheel file: $WHEEL_FILE"
# Remove quarantine on macOS
if [[ "$OS" == "Darwin" ]]; then
if [[ -f "$WHEEL_FILE" ]]; then
xattr -d com.apple.quarantine "$WHEEL_FILE" 2>/dev/null || true
echo "Removed quarantine attribute on macOS (if present)."
fi
fi
elif [[ "$1" == "--local" || -z "$1" ]]; then
# Install from local dist directory
WHEEL_FILE=$(ls dist/*.whl 2>/dev/null | head -n 1)
if [[ -z "$WHEEL_FILE" ]]; then
echo "No wheel file found in dist/. Exiting."
exit 1
fi
# Remove quarantine on macOS
if [[ "$OS" == "Darwin" && -f "$WHEEL_FILE" ]]; then
xattr -d com.apple.quarantine "$WHEEL_FILE" 2>/dev/null || true
echo "Removed quarantine attribute on macOS (if present)."
fi
else
echo "Invalid argument. Use --github or --local."
exit 1
fi
# Create system-wide virtual environment
echo "Creating virtual environment..."
echo "in system folder with sudo command, then you need to type your password"
sudo python3 -m venv /opt/cytosense_to_ecotaxa_pipeline_venv
sudo chmod +x /opt/cytosense_to_ecotaxa_pipeline_venv/bin/*
source /opt/cytosense_to_ecotaxa_pipeline_venv/bin/activate
# Get the Python executable path within the virtual environment
PYTHON_EXECUTABLE=$(which python)
# Get the Python major and minor version
PYTHON_VERSION=$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
# Construct the site-packages path using the determined version
SITE_PACKAGES_PATH=$(python -c "import site; print(site.getsitepackages()[0])")
echo "Python executable: $PYTHON_EXECUTABLE"
echo "Python version: $PYTHON_VERSION"
echo "Site-packages path: $SITE_PACKAGES_PATH"
# sudo /opt/cytosense_to_ecotaxa_pipeline_venv/bin/pip install --upgrade pip
pip install --upgrade pip
# Install the wheel
echo "Installing wheel file: $WHEEL_FILE"
# sudo /opt/cytosense_to_ecotaxa_pipeline_venv/bin/pip install "$WHEEL_FILE" || { echo "Failed to create virtual environment. Exiting."; exit 1; }
sudo /opt/cytosense_to_ecotaxa_pipeline_venv/bin/pip install "$WHEEL_FILE" || { echo "Failed to create virtual environment. Exiting."; exit 1; }
# Check installation status
# if [ $? -ne 0 ]; then
# echo "Installation failed!"
# exit 1
# fi
# debug to show the files
# /opt/cytosense_to_ecotaxa_pipeline_venv/bin/pip show -f cytosense_to_ecotaxa_pipeline
# sudo ln -s /opt/cytosense_to_ecotaxa_pipeline_venv/lib/python3.13/site-packages/cytosense_to_ecotaxa_pipeline/bin/Cyz2Json /opt/cytosense_to_ecotaxa_pipeline_venv/bin/Cyz2Json
# sudo ln -s /opt/cytosense_to_ecotaxa_pipeline_venv/lib/python3.13/site-packages/cytosense_to_ecotaxa_pipeline/pipeline.py /opt/cytosense_to_ecotaxa_pipeline_venv/bin/pipeline.py
# sudo ln -s /opt/cytosense_to_ecotaxa_pipeline_venv/lib/python3.13/site-packages/cytosense_to_ecotaxa_pipeline/main.py /opt/cytosense_to_ecotaxa_pipeline_venv/bin/main.py
sudo ln -s "$SITE_PACKAGES_PATH/cytosense_to_ecotaxa_pipeline/bin/Cyz2Json" /opt/cytosense_to_ecotaxa_pipeline_venv/bin/Cyz2Json
sudo ln -s "$SITE_PACKAGES_PATH/cytosense_to_ecotaxa_pipeline/pipeline.py" /opt/cytosense_to_ecotaxa_pipeline_venv/bin/pipeline.py
sudo ln -s "$SITE_PACKAGES_PATH/cytosense_to_ecotaxa_pipeline/main.py" /opt/cytosense_to_ecotaxa_pipeline_venv/bin/main.py
export LD_LIBRARY_PATH=/opt/cytosense_to_ecotaxa_pipeline_venv/lib/python3.13/site-packages/cytosense_to_ecotaxa_pipeline/lib
sudo chmod ago+x /opt/cytosense_to_ecotaxa_pipeline_venv/lib/python3.13/site-packages/cytosense_to_ecotaxa_pipeline/bin/*
desactivate
# if [[-f /opt/cytosense_to_ecotaxa_pipeline_venv/bin/Cyz2Json]]; then
# echo "missing Cyz2Json"
# exit 1
# fi
# if [[-f /opt/cytosense_to_ecotaxa_pipeline_venv/bin/pipeline.py]]; then
# echo "missing pipeline.py"
# exit 1
# fi
# if [[-f /opt/cytosense_to_ecotaxa_pipeline_venv/bin/main.py]]; then
# echo "missing main.py"
# exit 1
# fi
# echo "Installing main.py to virtual environment..."
# sudo cp src/cytosense_to_ecotaxa_pipeline/pipeline.py /opt/cytosense_to_ecotaxa_pipeline_venv/bin/
# sudo cp src/cytosense_to_ecotaxa_pipeline/main.py /opt/cytosense_to_ecotaxa_pipeline_venv/bin/
# sudo cp src/cytosense_to_ecotaxa_pipeline/bin/* /opt/cytosense_to_ecotaxa_pipeline_venv/bin/
# sudo chmod +x /opt/cytosense_to_ecotaxa_pipeline_venv/bin/pipeline.py
# sudo chmod +x /opt/cytosense_to_ecotaxa_pipeline_venv/bin/main.py
# sudo chmod +x /opt/cytosense_to_ecotaxa_pipeline_venv/bin/Cyz2Json
# Install execution script
echo "Creating launcher script..."
sudo tee /usr/local/bin/cytosense_to_ecotaxa_pipeline << 'EOF'
#!/bin/bash
source /opt/cytosense_to_ecotaxa_pipeline_venv/bin/activate
python /opt/cytosense_to_ecotaxa_pipeline_venv/bin/pipeline.py "$@"
deactivate
EOF
sudo chmod +x /usr/local/bin/cytosense_to_ecotaxa_pipeline
echo "Installation completed successfully!"