Skip to content

Commit 86174f0

Browse files
RahulHereRahulHere
authored andcommitted
Improve pip example to install platform-specific native package
Detect platform and architecture at runtime and install the correct native package (e.g., gopher-orch-native-darwin-arm64) alongside the main gopher-orch package.
1 parent 9fbe3f0 commit 86174f0

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

examples/pip/client_example_json_run.sh

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,33 @@ WORK_DIR="$SCRIPT_DIR/test-project"
2121
# SDK version to install (can be overridden via environment variable)
2222
SDK_VERSION="${SDK_VERSION:-}"
2323

24+
# Detect platform and architecture
25+
detect_platform() {
26+
local os=$(uname -s | tr '[:upper:]' '[:lower:]')
27+
local arch=$(uname -m)
28+
29+
# Map OS
30+
case "$os" in
31+
darwin) PLATFORM="darwin" ;;
32+
linux) PLATFORM="linux" ;;
33+
mingw*|msys*|cygwin*) PLATFORM="win32" ;;
34+
*) echo -e "${RED}Unsupported OS: $os${NC}"; exit 1 ;;
35+
esac
36+
37+
# Map architecture
38+
case "$arch" in
39+
x86_64|amd64) ARCH="x64" ;;
40+
arm64|aarch64) ARCH="arm64" ;;
41+
*) echo -e "${RED}Unsupported architecture: $arch${NC}"; exit 1 ;;
42+
esac
43+
44+
NATIVE_PACKAGE="gopher-orch-native-${PLATFORM}-${ARCH}"
45+
echo -e "${CYAN}Detected platform: ${PLATFORM}-${ARCH}${NC}"
46+
echo -e "${CYAN}Native package: ${NATIVE_PACKAGE}${NC}"
47+
}
48+
49+
detect_platform
50+
2451
# Kill any existing processes on ports 3001 and 3002
2552
kill_port() {
2653
local port=$1
@@ -61,18 +88,20 @@ echo -e "${YELLOW}Creating virtual environment...${NC}"
6188
python3 -m venv venv
6289
source venv/bin/activate
6390

64-
# Install SDK from TestPyPI
91+
# Install SDK and native package from TestPyPI
6592
echo -e "${YELLOW}Installing gopher-orch from TestPyPI...${NC}"
6693
if [ -n "$SDK_VERSION" ]; then
6794
echo -e "${CYAN}Installing version: $SDK_VERSION${NC}"
6895
pip install --index-url https://test.pypi.org/simple/ \
6996
--extra-index-url https://pypi.org/simple/ \
70-
"gopher-orch==$SDK_VERSION"
97+
"gopher-orch==$SDK_VERSION" \
98+
"${NATIVE_PACKAGE}==$SDK_VERSION"
7199
else
72100
echo -e "${CYAN}Installing latest version${NC}"
73101
pip install --index-url https://test.pypi.org/simple/ \
74102
--extra-index-url https://pypi.org/simple/ \
75-
gopher-orch
103+
gopher-orch \
104+
"$NATIVE_PACKAGE"
76105
fi
77106

78107
# Show installed version
@@ -126,7 +155,7 @@ echo -e "${GREEN}Example completed${NC}"
126155
echo ""
127156
echo -e "${CYAN}To run this example manually:${NC}"
128157
echo " 1. python3 -m venv venv && source venv/bin/activate"
129-
echo " 2. pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ gopher-orch"
158+
echo " 2. pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ gopher-orch $NATIVE_PACKAGE"
130159
echo " 3. python client_example_json.py"
131160

132161
exit 0

0 commit comments

Comments
 (0)