-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild-install.sh
105 lines (88 loc) · 3.03 KB
/
build-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
#!/bin/bash
# This script is used to automate the process of building and installing
# local dependencies for the Meeseeks project. It accepts an argument
# to decide which submodule to install or if all submodules need to be installed.
# Usage:
# ./build-install.sh all # Build and install all submodules
# ./build-install.sh api # Build and install the meeseeks-api submodule
# ./build-install.sh chat # Build and install the meeseeks-chat submodule
# ./build-install.sh fallback-install # Install the meeseeks-chat submodule when on non package mode
function print_usage {
echo "Usage: $0 {fallback-install|all|api|chat}"
echo "fallback-install: Install the meeseeks-chat submodule when on non package mode"
# ! Commented since not fully baked yet.
# echo "all: Build and install all submodules"
# echo "api: Build and install the meeseeks-api submodule"
# echo "chat: Build and install the meeseeks-chat submodule"
}
function build_and_install() {
# Navigate to the submodule directory
script_dir=$(dirname "$(readlink -f "$0")")
cd "$script_dir/$1"
# Build the package
if poetry build; then
# Move the wheel file to the root directory
mv dist/*.whl ../
# Install the package
if ! pip install ../$1-1.0.0-py3-none-any.whl; then
echo "Error: Failed to install the $1 package"
exit 1
fi
else
echo "Error: Failed to build the $1 package"
exit 1
fi
# Clean up unwanted files and folders
rm -rf dist
rm -rf $1.egg-info
# Navigate back to the root directory
cd ..
}
# It manually installs dependencies when in non-package mode.
fallback_install() {
# TODO: Fallback for when non package mode installation fails.
# Get the absolute path of the script directory
script_dir=$(dirname "$(readlink -f "$0")")
# Log the file being installed
# Navigate to the submodule directory
cd "$script_dir/$1"
echo "Installing $script_dir/$1"
# Install the dependencies
if ! poetry install; then
echo "Error: Failed to install the dependencies for the $1 module"
exit 1
fi
# Navigate back to the root directory
cd "$script_dir"
}
if [ "$#" -ne 1 ]; then
echo "Error: Invalid number of arguments"
print_usage
exit 1
fi
# Update the case statement in your build.sh script to support 'fallback-install' and 'fallback-build' arguments
case $1 in
all)
build_and_install "meeseeks-api"
build_and_install "meeseeks-chat"
poetry install --extras "api chat"
;;
api)
build_and_install "meeseeks-api"
poetry install --extras "api"
;;
chat)
build_and_install "meeseeks-chat"
poetry install --extras "chat"
;;
fallback-install)
fallback_install "."
fallback_install "meeseeks-api"
fallback_install "meeseeks-chat"
;;
*)
echo "Error: Invalid argument"
print_usage
exit 1
;;
esac