Skip to content

Commit

Permalink
Merge branch 'depthai_package'
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Jan 16, 2024
2 parents 9b993c7 + 739d881 commit 1d2f44e
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 16 deletions.
3 changes: 1 addition & 2 deletions server/pypi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ Here are some examples of existing recipes:
* multidict: a minimal example, downloaded from PyPI.
* cython-example: a minimal example, built from a local directory.
* python-example: a pybind11-based package, downloaded from a Git repository.
* cmake-example: similar to python-example, but uses CMake. A patch is used to help CMake
find the Android toolchain file.
* cmake-example: similar to python-example, but uses CMake.
* chaquopy-libzmq: a non-Python library, downloaded from a URL.
* pyzmq: a Python package which depends on chaquopy-libzmq. A patch is used to help
`setup.py` find the library.
Expand Down
2 changes: 1 addition & 1 deletion server/pypi/build-wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def download_git(self, source):
run(f"{clone_cmd} {source['git_url']} {temp_dir}")
if is_hash:
run(f"git -C {temp_dir} checkout {git_rev}")
run(f"git -C {temp_dir} submodule update --init")
run(f"git -C {temp_dir} submodule update --init --recursive")

run(f"tar -c -C {temp_dir} . -z -f {tgz_filename}")
run(f"rm -rf {temp_dir}")
Expand Down
11 changes: 10 additions & 1 deletion server/pypi/packages/cmake-example/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# This recipe contains three patches to add libpython to the link. Each package will
# probably only need one of those patches, but we keep them all for two reasons:
#
# * To serve as an example for other packages.
# * As the basis for a future PR to merge this into upstream pybind11.

package:
name: cmake_example
version: "0.0.1"

build:
number: 1

source:
git_url: https://github.com/pybind/cmake_example.git
git_rev: 8818f493e3698a3ab936cdd8e7144afae85df3f8

requirements:
build:
- cmake
- cmake 3.28.1
host:
- python
50 changes: 39 additions & 11 deletions server/pypi/packages/cmake-example/patches/chaquopy.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
diff -ur src-original/setup.py src/setup.py
--- src-original/setup.py 2018-08-26 13:00:28.012674587 +0000
+++ src/setup.py 2018-08-26 13:52:26.893666837 +0000
@@ -36,6 +36,9 @@
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
'-DPYTHON_EXECUTABLE=' + sys.executable]
diff --git a/pybind11/CMakeLists.txt b/pybind11/CMakeLists.txt
index 2a3e1ed7..dcd8f98a 100644
--- a/pybind11/CMakeLists.txt
+++ b/pybind11/CMakeLists.txt
@@ -105,7 +105,7 @@ if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) # CMake >= 3.0
target_compile_options(module INTERFACE -fvisibility=hidden)
endif()
target_link_libraries(module INTERFACE pybind11::pybind11)
- if(WIN32 OR CYGWIN)
+ if(WIN32 OR CYGWIN OR ANDROID) # Chaquopy: added ANDROID
target_link_libraries(module INTERFACE $<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
elseif(APPLE)
target_link_libraries(module INTERFACE "-undefined dynamic_lookup")
diff --git a/pybind11/tools/pybind11Config.cmake.in b/pybind11/tools/pybind11Config.cmake.in
index 3dd1b2c1..3e96af80 100644
--- a/pybind11/tools/pybind11Config.cmake.in
+++ b/pybind11/tools/pybind11Config.cmake.in
@@ -86,7 +86,7 @@ if(NOT TARGET ${PN}::pybind11)
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED)
set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
set_property(TARGET ${PN}::embed APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES})
- if(WIN32 OR CYGWIN)
+ if(WIN32 OR CYGWIN OR ANDROID) # Chaquopy: added ANDROID
set_property(TARGET ${PN}::module APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES})
endif()

+ # Chaquopy added
+ cmake_args += ["-DCMAKE_TOOLCHAIN_FILE=" + os.path.abspath("../chaquopy.toolchain.cmake")]
+
cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]
diff --git a/pybind11/tools/pybind11Tools.cmake b/pybind11/tools/pybind11Tools.cmake
index a7c471a0..dbb84c3f 100644
--- a/pybind11/tools/pybind11Tools.cmake
+++ b/pybind11/tools/pybind11Tools.cmake
@@ -146,8 +146,8 @@ function(pybind11_add_module target_name)
# potential warnings or issues from having mixed hidden/non-hidden types.
set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden")

- if(WIN32 OR CYGWIN)
- # Link against the Python shared library on Windows
+ if(WIN32 OR CYGWIN OR ANDROID) # Chaquopy: added ANDROID
+ # Link against the Python shared library on these platforms
target_link_libraries(${target_name} PRIVATE ${PYTHON_LIBRARIES})
elseif(APPLE)
# It's quite common to have multiple copies of the same Python version
2 changes: 1 addition & 1 deletion server/pypi/packages/cmake-example/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TestCmakeExample(unittest.TestCase):
def test_basic(self):
import cmake_example
self.assertEqual(4, cmake_example.add(2, 2))
with self.assertRaisesRegexp(TypeError, "incompatible function arguments"):
with self.assertRaisesRegex(TypeError, "incompatible function arguments"):
cmake_example.add("one", "two")

self.assertEqual(1, cmake_example.subtract(3, 2))
Expand Down
18 changes: 18 additions & 0 deletions server/pypi/packages/depthai/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% set version = "2.24.0.0" %}

package:
name: depthai
version: "{{ version }}"

build:
number: 2
script_env:
- CI=1 # Set to build a release package

source:
git_url: https://github.com/luxonis/depthai-python.git
git_rev: v{{ version }}

requirements:
host:
- python
12 changes: 12 additions & 0 deletions server/pypi/packages/depthai/patches/dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/depthai-core/cmake/Hunter/config.cmake b/depthai-core/cmake/Hunter/config.cmake
index 8b1ec798..1e4c58d8 100644
--- a/depthai-core/cmake/Hunter/config.cmake
+++ b/depthai-core/cmake/Hunter/config.cmake
@@ -124,5 +124,6 @@ hunter_config(
CMAKE_ARGS
WITH_UDEV=OFF
# Build shared libs by default to not cause licensing issues
- BUILD_SHARED_LIBS=ON
+ # Chaquopy: changed to OFF
+ BUILD_SHARED_LIBS=OFF
)
13 changes: 13 additions & 0 deletions server/pypi/packages/depthai/patches/linking.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cddfd09b..3d9e4eea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -255,6 +255,8 @@ target_link_libraries(${TARGET_NAME}
depthai::core # Use non-opencv target as we use opencv-python in bindings
hedley
pybind11_json
+ # Chaquopy: added
+ ${PYTHON_LIBRARY}
)

# Find Git
9 changes: 9 additions & 0 deletions server/pypi/packages/depthai/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import unittest

class TestDepthAI(unittest.TestCase):
def test_import(self):
try:
import depthai
except ImportError:
print("Unable to import DepthAI module!")
raise

0 comments on commit 1d2f44e

Please sign in to comment.