Skip to content

Commit

Permalink
Modified bindings to not error out if initialization doesn't work fro…
Browse files Browse the repository at this point in the history
…m beggining. Note, subsequent initialization can cause issues.
  • Loading branch information
themarpe committed May 18, 2022
1 parent c57279b commit e5996f2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 0 additions & 6 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ RUN apt-get update && apt-get install -y wget build-essential cmake pkg-config l

ADD ci/docker_dependencies.sh .
RUN ./docker_dependencies.sh
RUN wget https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.tar.bz2
RUN tar xf libusb-1.0.24.tar.bz2
RUN cd libusb-1.0.24 && \
./configure --disable-udev && \
make -j && make install


RUN pip install -U pip && pip install --extra-index-url https://www.piwheels.org/simple/ --prefer-binary opencv-python

Expand Down
2 changes: 1 addition & 1 deletion depthai-core
7 changes: 7 additions & 0 deletions generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
# CWD to to extdir where the built module can be found to extract the types
env = os.environ
env['PYTHONPATH'] = f'{DIRECTORY}{os.pathsep}{env.get("PYTHONPATH", "")}'

# Test importing depthai after PYTHONPATH is specified
try:
import depthai
except Exception as ex:
print(f'Could not import depthai: {ex}')

print(f'PYTHONPATH set to {env["PYTHONPATH"]}')
subprocess.check_call(['stubgen', '-p', MODULE_NAME, '-o', f'{DIRECTORY}'], cwd=DIRECTORY, env=env)

Expand Down
6 changes: 5 additions & 1 deletion src/py_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ PYBIND11_MODULE(depthai, m)
}

// Call dai::initialize on 'import depthai' to initialize asap with additional information to print
dai::initialize(std::string("Python bindings - version: ") + DEPTHAI_PYTHON_VERSION + " from " + DEPTHAI_PYTHON_COMMIT_DATETIME + " build: " + DEPTHAI_PYTHON_BUILD_DATETIME, installSignalHandler);
try {
dai::initialize(std::string("Python bindings - version: ") + DEPTHAI_PYTHON_VERSION + " from " + DEPTHAI_PYTHON_COMMIT_DATETIME + " build: " + DEPTHAI_PYTHON_BUILD_DATETIME, installSignalHandler);
} catch (const std::exception&) {
// ignore, will be initialized later on if possible
}

}

0 comments on commit e5996f2

Please sign in to comment.