Skip to content

Commit 173aa97

Browse files
committed
feat: add module build setup, initial pyorbbecsdk integration
1 parent d1e4344 commit 173aa97

File tree

17 files changed

+2568
-34
lines changed

17 files changed

+2568
-34
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,6 @@ cython_debug/
162162
# and can be added to the global gitignore or merged into this file. For a more nuclear
163163
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
164164
#.idea/
165+
166+
archive.tar.gz
167+
examples/

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "pyorbbecsdk"]
2+
path = pyorbbecsdk
3+
url = https://github.com/orbbec/pyorbbecsdk.git
4+
branch = v2-main

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.9

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
setup:
22
./setup.sh
33

4-
dist/archive.tar.gz: setup
4+
archive.tar.gz: setup
55
./build.sh

build.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ set -euo pipefail
55
cd $(dirname $0)
66

77
export PATH=$PATH:$HOME/.local/bin
8-
VENV_NAME="./venv-build"
8+
VENV_NAME=".venv"
99

1010
source "./$VENV_NAME/bin/activate"
1111

12-
if ! uv pip install pyinstaller -q; then
13-
exit 1
14-
fi
12+
# if ! uv pip install pyinstaller -q; then
13+
# exit 1
14+
# fi
1515

16-
uv run pyinstaller --onefile -p src src/main.py
17-
tar -czvf dist/archive.tar.gz ./dist/main meta.json
16+
uv build --wheel
17+
18+
cp ./pyorbbecsdk/dist/*.whl ./dist/
19+
20+
# uv run pyinstaller --onefile -p src src/main.py
21+
tar -czvf archive.tar.gz ./dist/ meta.json first_run.sh run.sh

build_sdk.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Check if pyorbbecsdk directory exists
5+
if [ ! -d "pyorbbecsdk" ]; then
6+
echo "Error: pyorbbecsdk directory not found."
7+
echo "Please run: git submodule update --init --recursive"
8+
exit 1
9+
fi
10+
11+
sudo apt install -y cmake gcc
12+
13+
# Build pyorbbecsdk
14+
cd pyorbbecsdk
15+
if [ -d "build" ]; then
16+
rm -rf build
17+
fi
18+
mkdir -p build
19+
cd build
20+
cmake -Dpybind11_DIR=$(pybind11-config --cmakedir) ..
21+
make -j4
22+
make install
23+
cd ..
24+
25+
# Build wheel
26+
# uv pip install wheel
27+
python setup.py bdist_wheel
28+
29+
# Install the wheel
30+
uv pip install dist/*.whl
31+
32+
echo "pyorbbecsdk built and installed successfully!"
33+
cd ..

first_run.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
cd $(dirname $0)
6+
7+
VENV_NAME="${VIAM_MODULE_DATA}/.venv"
8+
9+
# Create a virtual environment to run our code
10+
export PATH=$PATH:$HOME/.local/bin
11+
12+
if [ ! "$(command -v uv)" ]; then
13+
if [ ! "$(command -v curl)" ]; then
14+
echo "curl is required to install UV. please install curl on this system to continue."
15+
exit 1
16+
fi
17+
echo "Installing uv command"
18+
curl -LsSf https://astral.sh/uv/install.sh | sh
19+
fi
20+
21+
if ! uv venv $VENV_NAME --python 3.10; then
22+
echo "unable to create required virtual environment"
23+
exit 1
24+
fi
25+
26+
source "$VENV_NAME/bin/activate"
27+
28+
# if ! uv pip install -r requirements.txt; then
29+
# echo "unable to sync requirements to venv"
30+
# exit 1
31+
# fi
32+
33+
# uv pip install

install_requirements.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Initialize and update the git submodule
5+
git submodule update --init --recursive
6+
7+
# Check if the submodule is on the correct branch
8+
cd pyorbbecsdk
9+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
10+
if [ "$CURRENT_BRANCH" != "v2-main" ]; then
11+
echo "Switching pyorbbecsdk to v2-main branch"
12+
git checkout v2-main
13+
fi
14+
cd ..

main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def main():
2+
print("Hello from orbbec-camera!")
3+
4+
5+
if __name__ == "__main__":
6+
main()

meta.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
],
1515
"applications": null,
1616
"markdown_link": "README.md",
17-
"entrypoint": "dist/main",
18-
"first_run": "",
17+
"entrypoint": "./run.sh",
18+
"first_run": "./first_run.sh",
1919
"build": {
2020
"build": "./build.sh",
2121
"setup": "./setup.sh",
22-
"path": "dist/archive.tar.gz",
22+
"path": "archive.tar.gz",
2323
"arch": [
2424
"linux/amd64",
2525
"linux/arm64"

0 commit comments

Comments
 (0)