forked from beeware/mobile-forge
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·144 lines (120 loc) · 4.57 KB
/
setup.sh
File metadata and controls
executable file
·144 lines (120 loc) · 4.57 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
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
usage() {
echo "Usage:"
echo
echo " source $1 <python version>"
echo
echo "for example:"
echo
echo " source $1 3.13"
echo
}
# make sure the script is sourced
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
echo "This script must be sourced."
echo
usage $0
exit 1
fi
if [ -z "$1" ]; then
echo "Python version is not provided."
echo
usage $0
return
fi
if ! command -v uv &> /dev/null; then
echo "Error: uv is not installed. Install it with:"
echo " curl -LsSf https://astral.sh/uv/install.sh | sh"
return
fi
PYTHON_VERSION=$1
PYTHON_VER="${PYTHON_VERSION%.*}"
echo "Python version: $PYTHON_VERSION"
echo "Python short version: $PYTHON_VER"
if [[ -z "$MOBILE_FORGE_IOS_SUPPORT_PATH" && -z "$MOBILE_FORGE_ANDROID_SUPPORT_PATH" ]]; then
echo "Neither MOBILE_FORGE_IOS_SUPPORT_PATH nor MOBILE_FORGE_ANDROID_SUPPORT_PATH are defined."
return
fi
venv_dir="$(pwd)/venv$PYTHON_VER"
if [ ! -d $venv_dir ]; then
echo "Creating Python $PYTHON_VER virtual environment for build in $venv_dir..."
uv venv --seed --python="$PYTHON_VERSION" $venv_dir
source $venv_dir/bin/activate
uv pip install -e .
echo "Building platform dependency wheels..."
if [ ! -z "$MOBILE_FORGE_IOS_SUPPORT_PATH" ]; then
python -m make_dep_wheels iOS
if [ $? -ne 0 ]; then
return
fi
fi
if [ ! -z "$MOBILE_FORGE_ANDROID_SUPPORT_PATH" ]; then
python -m make_dep_wheels android
if [ $? -ne 0 ]; then
return
fi
fi
echo "Python $PYTHON_VERSION environment has been created."
echo
else
echo "Using existing Python $PYTHON_VERSION environment."
source $venv_dir/bin/activate
fi
# configure iOS paths
if [ ! -z "$MOBILE_FORGE_IOS_SUPPORT_PATH" ]; then
if [ ! -d $MOBILE_FORGE_IOS_SUPPORT_PATH/support/$PYTHON_VER/iOS/Python.xcframework ]; then
echo "MOBILE_FORGE_IOS_SUPPORT_PATH does not point at a valid location."
return
fi
if [ ! -e $MOBILE_FORGE_IOS_SUPPORT_PATH/support/$PYTHON_VER/iOS/Python.xcframework/ios-arm64/bin/python$PYTHON_VER ]; then
echo "MOBILE_FORGE_IOS_SUPPORT_PATH does not appear to contain a Python $PYTHON_VERSION iOS ARM64 device binary."
return
fi
if [ ! -e $MOBILE_FORGE_IOS_SUPPORT_PATH/support/$PYTHON_VER/iOS/Python.xcframework/ios-arm64_x86_64-simulator/bin/python$PYTHON_VER ]; then
echo "MOBILE_FORGE_IOS_SUPPORT_PATH does not appear to contain a Python $PYTHON_VERSION iOS ARM64/x86_64 simulator binaries."
return
fi
echo "MOBILE_FORGE_IOS_SUPPORT_PATH: $MOBILE_FORGE_IOS_SUPPORT_PATH"
fi
# configure Android paths
if [ ! -z "$MOBILE_FORGE_ANDROID_SUPPORT_PATH" ]; then
if [ ! -e $MOBILE_FORGE_ANDROID_SUPPORT_PATH/install/android/arm64-v8a/python-$PYTHON_VERSION/bin/python$PYTHON_VER ]; then
echo "MOBILE_FORGE_ANDROID_SUPPORT_PATH does not appear to contain a Python $PYTHON_VERSION Android arm64-v8a device binary."
return
fi
if [ ! -e $MOBILE_FORGE_ANDROID_SUPPORT_PATH/install/android/x86_64/python-$PYTHON_VERSION/bin/python$PYTHON_VER ]; then
echo "MOBILE_FORGE_ANDROID_SUPPORT_PATH does not appear to contain a Python $PYTHON_VERSION Android x86_64 device binary."
return
fi
if [ "$PYTHON_VER" = "3.12" ]; then
if [ ! -e $MOBILE_FORGE_ANDROID_SUPPORT_PATH/install/android/armeabi-v7a/python-$PYTHON_VERSION/bin/python$PYTHON_VER ]; then
echo "MOBILE_FORGE_ANDROID_SUPPORT_PATH does not appear to contain a Python $PYTHON_VERSION Android armeabi-v7a device binary."
return
fi
if [ ! -e $MOBILE_FORGE_ANDROID_SUPPORT_PATH/install/android/x86/python-$PYTHON_VERSION/bin/python$PYTHON_VER ]; then
echo "MOBILE_FORGE_ANDROID_SUPPORT_PATH does not appear to contain a Python $PYTHON_VERSION Android x86 device binary."
return
fi
fi
echo "MOBILE_FORGE_ANDROID_SUPPORT_PATH: $MOBILE_FORGE_ANDROID_SUPPORT_PATH"
fi
echo
echo "You can now build packages with forge; e.g.:"
echo
echo "Build all packages for all iOS targets:"
echo " forge iOS"
echo
echo "Build only the non-python packages, for all iOS targets:"
echo " forge iOS -s non-py"
echo
echo "Build all packages needed for a smoke test, for all iOS targets:"
echo " forge iOS -s smoke"
echo
echo "Build lru-dict for all iOS targets:"
echo " forge iOS lru-dict"
echo
echo "Build lru-dict for the ARM64 device target:"
echo " forge iphoneos:arm64 lru-dict"
echo
echo "Build all applicable versions of lru-dict for all iOS targets:"
echo " forge iOS --all-versions lru-dict"
echo