diff --git a/server/pypi/README.md b/server/pypi/README.md index 014d21ebaa..f141ca0d3c 100644 --- a/server/pypi/README.md +++ b/server/pypi/README.md @@ -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. diff --git a/server/pypi/build-wheel.py b/server/pypi/build-wheel.py index 13794806d3..d055766664 100755 --- a/server/pypi/build-wheel.py +++ b/server/pypi/build-wheel.py @@ -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}") diff --git a/server/pypi/packages/cmake-example/meta.yaml b/server/pypi/packages/cmake-example/meta.yaml index 1ce1e9cf32..72ad05fc14 100644 --- a/server/pypi/packages/cmake-example/meta.yaml +++ b/server/pypi/packages/cmake-example/meta.yaml @@ -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 diff --git a/server/pypi/packages/cmake-example/patches/chaquopy.patch b/server/pypi/packages/cmake-example/patches/chaquopy.patch index 7db8d5ec9c..c6976b23dd 100644 --- a/server/pypi/packages/cmake-example/patches/chaquopy.patch +++ b/server/pypi/packages/cmake-example/patches/chaquopy.patch @@ -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 $) + 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 diff --git a/server/pypi/packages/cmake-example/test.py b/server/pypi/packages/cmake-example/test.py index dd8e7dc66a..552df20ec6 100644 --- a/server/pypi/packages/cmake-example/test.py +++ b/server/pypi/packages/cmake-example/test.py @@ -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)) diff --git a/server/pypi/packages/depthai/meta.yaml b/server/pypi/packages/depthai/meta.yaml new file mode 100644 index 0000000000..2209f1c5a8 --- /dev/null +++ b/server/pypi/packages/depthai/meta.yaml @@ -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 diff --git a/server/pypi/packages/depthai/patches/dependencies.patch b/server/pypi/packages/depthai/patches/dependencies.patch new file mode 100644 index 0000000000..e4c1140000 --- /dev/null +++ b/server/pypi/packages/depthai/patches/dependencies.patch @@ -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 + ) diff --git a/server/pypi/packages/depthai/patches/linking.patch b/server/pypi/packages/depthai/patches/linking.patch new file mode 100644 index 0000000000..9271f77717 --- /dev/null +++ b/server/pypi/packages/depthai/patches/linking.patch @@ -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 diff --git a/server/pypi/packages/depthai/test.py b/server/pypi/packages/depthai/test.py new file mode 100644 index 0000000000..0aa6f52a7b --- /dev/null +++ b/server/pypi/packages/depthai/test.py @@ -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