diff --git a/CMakeLists.txt b/CMakeLists.txt index d8fc4fee8..ac3c48597 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,8 +173,8 @@ endif() # Add stubs (pyi) generation step after building bindings execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "from mypy import api" RESULT_VARIABLE error OUTPUT_QUIET ERROR_QUIET) -if(error) - message(WARNING "Mypy not available - stubs won't be generated or checked") +if(error OR CMAKE_CROSSCOMPILING) + message(WARNING "Mypy not available or cross compiling - stubs won't be generated or checked") else() get_target_property(bindings_directory ${TARGET_NAME} LIBRARY_OUTPUT_DIRECTORY) if(NOT bindings_directory) diff --git a/depthai-core b/depthai-core index faa86aea3..a730a33ee 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit faa86aea31011fdabf52370f4defd5deddff08e3 +Subproject commit a730a33ee29cdbe5d6110cb2bedff8a78cf20093 diff --git a/setup.py b/setup.py index 341ab5f24..7dfd75015 100644 --- a/setup.py +++ b/setup.py @@ -142,6 +142,11 @@ def build_extension(self, ext): freeMemory = 4000 # Configure and build + + # Add additional cmake build args from environment + if 'CMAKE_BUILD_ARGS' in os.environ: + build_args += [os.environ['CMAKE_BUILD_ARGS']] + # Windows if platform.system() == "Windows": cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)] diff --git a/src/py_bindings.cpp b/src/py_bindings.cpp index e6db7796f..864704a74 100644 --- a/src/py_bindings.cpp +++ b/src/py_bindings.cpp @@ -82,9 +82,33 @@ PYBIND11_MODULE(depthai, m) // ignore } + // Apply JavaVM pointer + std::string javavmEnvStr; + constexpr static const char* javavmEnvKey = "DEPTHAI_LIBUSB_ANDROID_JAVAVM"; + try { + auto sysModule = py::module_::import("sys"); + if(py::hasattr(sysModule, javavmEnvKey)){ + javavmEnvStr = sysModule.attr(javavmEnvKey).cast(); + } + } catch (...) { + // ignore + } + try { + auto builtinsModule = py::module_::import("builtins"); + if(py::hasattr(builtinsModule, javavmEnvKey)){ + javavmEnvStr = builtinsModule.attr(javavmEnvKey).cast(); + } + } catch (...){ + // ignore + } + // JNIEnv handling + void* javavm = nullptr; + // Read the uintptr_t value from the decimal string + sscanf(javavmEnvStr.c_str(), "%" SCNuPTR, reinterpret_cast(&javavm)); + // Call dai::initialize on 'import depthai' to initialize asap with additional information to print try { - dai::initialize(std::string("Python bindings - version: ") + DEPTHAI_PYTHON_VERSION + " from " + DEPTHAI_PYTHON_COMMIT_DATETIME + " build: " + DEPTHAI_PYTHON_BUILD_DATETIME, installSignalHandler); + dai::initialize(std::string("Python bindings - version: ") + DEPTHAI_PYTHON_VERSION + " from " + DEPTHAI_PYTHON_COMMIT_DATETIME + " build: " + DEPTHAI_PYTHON_BUILD_DATETIME, installSignalHandler, javavm); } catch (const std::exception&) { // ignore, will be initialized later on if possible }