Skip to content

Commit 67296eb

Browse files
committed
Merge branch 'develop' into main
2 parents 2ee6aec + 43ffb18 commit 67296eb

File tree

67 files changed

+2591
-2333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2591
-2333
lines changed

.github/workflows/main.yml

Lines changed: 100 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ jobs:
3131
- name: Cache .hunter folder
3232
uses: actions/cache@v2
3333
with:
34-
path: ~/.hunter/
35-
key: hunter-clang
34+
path: ~/.hunter
35+
key: hunter-macos-latest
36+
- name: List .hunter cache directory
37+
run: ls -a -l ~/.hunter/_Base/ || true
3638
- uses: actions/checkout@v2
3739
with:
3840
submodules: 'recursive'
@@ -83,14 +85,22 @@ jobs:
8385
if: startsWith(github.ref, 'refs/tags/v') != true
8486
run: echo "BUILD_COMMIT_HASH=${{github.sha}}" >> $GITHUB_ENV
8587
- name: Building wheel
86-
run: python3 -m pip wheel . -w ./wheelhouse/
88+
run: python3 -m pip wheel . -w ./wheelhouse/ --verbose
8789
- name: Auditing wheel
8890
run: for whl in wheelhouse/*.whl; do auditwheel repair "$whl" --plat linux_armv7l -w wheelhouse/audited/; done
8991
- name: Archive wheel artifacts
9092
uses: actions/upload-artifact@v2
9193
with:
9294
name: audited-wheels
9395
path: wheelhouse/audited/
96+
- name: Deploy wheels to artifactory (if not a release)
97+
if: startsWith(github.ref, 'refs/tags/v') != true
98+
run: bash ./ci/upload-artifactory.sh
99+
env:
100+
ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL }}
101+
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
102+
ARTIFACTORY_PASS: ${{ secrets.ARTIFACTORY_PASS }}
103+
94104

95105
# This job builds wheels for Windows x86_64 arch
96106
build-windows-x86_64:
@@ -104,7 +114,7 @@ jobs:
104114
- name: Cache .hunter folder
105115
uses: actions/cache@v2
106116
with:
107-
path: ~/.hunter/
117+
path: C:/.hunter
108118
key: hunter-msvc
109119
- uses: actions/checkout@v2
110120
with:
@@ -129,12 +139,19 @@ jobs:
129139
run: |
130140
python -m pip install --upgrade pip
131141
- name: Building wheels
132-
run: python -m pip wheel . -w ./wheelhouse/
142+
run: python -m pip wheel . -w ./wheelhouse/audited/ --verbose
133143
- name: Archive wheel artifacts
134144
uses: actions/upload-artifact@v2
135145
with:
136146
name: audited-wheels
137-
path: wheelhouse/
147+
path: wheelhouse/audited/
148+
- name: Deploy wheels to artifactory (if not a release)
149+
if: startsWith(github.ref, 'refs/tags/v') != true
150+
run: bash ./ci/upload-artifactory.sh
151+
env:
152+
ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL }}
153+
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
154+
ARTIFACTORY_PASS: ${{ secrets.ARTIFACTORY_PASS }}
138155

139156
# This job builds wheels for macOS x86_64 arch
140157
build-macos-x86_64:
@@ -147,8 +164,11 @@ jobs:
147164
- name: Cache .hunter folder
148165
uses: actions/cache@v2
149166
with:
150-
path: ~/.hunter/
151-
key: hunter-clang
167+
path: ~/.hunter
168+
key: hunter-macos-latest
169+
- name: List .hunter cache directory
170+
run: ls -a -l ~/.hunter/_Base/ || true
171+
152172
- uses: actions/checkout@v2
153173
with:
154174
submodules: 'recursive'
@@ -175,14 +195,21 @@ jobs:
175195
- name: Set macos deployment target
176196
run: echo "MACOSX_DEPLOYMENT_TARGET=10.9" >> $GITHUB_ENV
177197
- name: Building wheels
178-
run: python -m pip wheel . -w ./wheelhouse/
198+
run: python -m pip wheel . -w ./wheelhouse/ --verbose
179199
- name: Auditing wheels
180200
run: ci/repair-whl-macos.sh `pwd`/wheelhouse/* `pwd`/wheelhouse/audited
181201
- name: Archive wheel artifacts
182202
uses: actions/upload-artifact@v2
183203
with:
184204
name: audited-wheels
185205
path: wheelhouse/audited/
206+
- name: Deploy wheels to artifactory (if not a release)
207+
if: startsWith(github.ref, 'refs/tags/v') != true
208+
run: bash ./ci/upload-artifactory.sh
209+
env:
210+
ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL }}
211+
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
212+
ARTIFACTORY_PASS: ${{ secrets.ARTIFACTORY_PASS }}
186213

187214
# This job builds wheels for x86_64 arch
188215
build-linux-x86_64:
@@ -196,7 +223,7 @@ jobs:
196223
- name: Cache .hunter folder
197224
uses: actions/cache@v2
198225
with:
199-
path: ~/.hunter/
226+
path: ~/.hunter
200227
key: hunter-x86_64
201228
- uses: actions/checkout@v2
202229
with:
@@ -217,69 +244,97 @@ jobs:
217244
- name: Specify docstring to use while building the wheel
218245
run: echo "DEPTHAI_PYTHON_DOCSTRINGS_INPUT=$PWD/docstrings/depthai_python_docstring.hpp" >> $GITHUB_ENV
219246

247+
- name: Build and install depthai-core
248+
run: |
249+
cmake -S depthai-core/ -B build_core -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/pic.cmake
250+
cmake --build build_core --parallel --target install
251+
echo "DEPTHAI_INSTALLATION_DIR=$PWD/build_core/install/" >> $GITHUB_ENV
252+
220253
- name: Append build hash if not a tagged commit
221254
if: startsWith(github.ref, 'refs/tags/v') != true
222255
run: echo "BUILD_COMMIT_HASH=${{github.sha}}" >> $GITHUB_ENV
223-
- name: Building a source distribution
256+
257+
- name: Building source distribution
224258
run: |
225259
/opt/python/cp38-cp38/bin/python3.8 setup.py sdist --formats=gztar
226260
mv dist/* wheelhouse/audited/
227-
- name: Building wheels
228-
run: for PYBIN in /opt/python/cp3*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/; done
229-
- name: Auditing wheels
261+
- name: Build wheels
262+
run: for PYBIN in /opt/python/cp3*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done
263+
- name: Audit wheels
230264
run: for whl in wheelhouse/*.whl; do auditwheel repair "$whl" --plat $PLAT -w wheelhouse/audited/; done
231265
- name: Archive wheel artifacts
232266
uses: actions/upload-artifact@v2
233267
with:
234268
name: audited-wheels
235269
path: wheelhouse/audited/
270+
- name: Deploy wheels to artifactory (if not a release)
271+
if: startsWith(github.ref, 'refs/tags/v') != true
272+
run: bash ./ci/upload-artifactory.sh
273+
env:
274+
ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL }}
275+
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
276+
ARTIFACTORY_PASS: ${{ secrets.ARTIFACTORY_PASS }}
236277

237-
238-
# # Run tests
239-
# tests:
240-
# runs-on: luxonis-arm-tests
241-
# needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64]
242-
# steps:
243-
# - uses: actions/checkout@v2
244-
# with:
245-
# submodules: 'recursive'
246-
# - uses: actions/download-artifact@v2
247-
# with:
248-
# name: audited-wheels
249-
# path: wheels/depthai/
250-
# - name: List files
251-
# run: ls -lah
252-
# - name: install DepthAI
253-
# run: python3.7 -m pip install depthai --no-index --find-links file://`pwd`/wheels/depthai/
254-
# - name: Run tests
255-
# run: python3.7 tests/test.py
256-
257-
# Deploy to artifactory
258-
deploy-artifacts:
259-
if: startsWith(github.ref, 'refs/tags/v') != true
260-
runs-on: ubuntu-latest
261-
needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64]
278+
# This job builds wheels for ARM64 arch
279+
build-linux-arm64:
280+
needs: build-docstrings
281+
runs-on: [self-hosted, linux, ARM64]
282+
container:
283+
image: quay.io/pypa/manylinux2014_aarch64
284+
env:
285+
PLAT: manylinux2014_aarch64
286+
# Mount local hunter cache directory, instead of transfering to Github and back
287+
volumes:
288+
- /.hunter:/github/home/.hunter
262289
steps:
263290
- uses: actions/checkout@v2
264291
with:
265292
submodules: 'recursive'
293+
- name: Installing libusb1-devel dependency
294+
run: yum install -y --disableplugin=fastestmirror libusb1-devel
295+
- name: Installing cmake dependency
296+
run: |
297+
/opt/python/cp38-cp38/bin/python3.8 -m pip install cmake
298+
ln -s /opt/python/cp38-cp38/bin/cmake /bin/
299+
- name: Create folder structure
300+
run: mkdir -p wheelhouse/audited/
301+
266302
- uses: actions/download-artifact@v2
303+
with:
304+
name: 'docstrings'
305+
path: docstrings
306+
- name: Specify docstring to use while building the wheel
307+
run: echo "DEPTHAI_PYTHON_DOCSTRINGS_INPUT=$PWD/docstrings/depthai_python_docstring.hpp" >> $GITHUB_ENV
308+
309+
- name: Build and install depthai-core
310+
run: |
311+
cmake -S depthai-core/ -B build_core -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/pic.cmake
312+
cmake --build build_core --parallel --target install
313+
echo "DEPTHAI_INSTALLATION_DIR=$PWD/build_core/install/" >> $GITHUB_ENV
314+
315+
- name: Append build hash if not a tagged commit
316+
if: startsWith(github.ref, 'refs/tags/v') != true
317+
run: echo "BUILD_COMMIT_HASH=${{github.sha}}" >> $GITHUB_ENV
318+
- name: Building wheels
319+
run: for PYBIN in /opt/python/cp3*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done
320+
- name: Auditing wheels
321+
run: for whl in wheelhouse/*.whl; do auditwheel repair "$whl" --plat $PLAT -w wheelhouse/audited/; done
322+
- name: Archive wheel artifacts
323+
uses: actions/upload-artifact@v2
267324
with:
268325
name: audited-wheels
269326
path: wheelhouse/audited/
270-
- name: List files
271-
run: ls -lah wheelhouse/audited/
272-
- name: Run deploy to artifacts
327+
- name: Deploy wheels to artifactory (if not a release)
328+
if: startsWith(github.ref, 'refs/tags/v') != true
273329
run: bash ./ci/upload-artifactory.sh
274330
env:
275331
ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL }}
276332
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
277333
ARTIFACTORY_PASS: ${{ secrets.ARTIFACTORY_PASS }}
278334

279-
280335
release:
281336
if: startsWith(github.ref, 'refs/tags/v')
282-
needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64]
337+
needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64, build-linux-arm64]
283338
runs-on: ubuntu-latest
284339

285340
steps:
@@ -301,7 +356,7 @@ jobs:
301356
# Create GitHub release
302357
- uses: actions/create-release@master
303358
id: createRelease
304-
name: Create ${{ steps.releaseNote.outputs.version }} depthai-core release
359+
name: Create ${{ steps.tag.outputs.version-without-v }} depthai-core release
305360
env:
306361
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
307362
with:
@@ -337,5 +392,3 @@ jobs:
337392
PYPI_SERVER: ${{ secrets.PYPI_SERVER }}
338393
PYPI_USER: ${{ secrets.PYPI_USER }}
339394
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
340-
341-

CMakeLists.txt

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ endif()
2929

3030
# Pybindings project
3131
set(TARGET_NAME depthai)
32-
project(depthai VERSION "1") # revision of bindings [depthai-core].[rev]
32+
project(depthai VERSION "0") # revision of bindings [depthai-core].[rev]
3333

3434
# Add module paths
3535
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
@@ -41,6 +41,7 @@ set(DOCSTRINGS_INCLUDE_PLACEHOLDER_PATH ${DOCSTRINGS_INCLUDE_PLACEHOLDER_DIR}/do
4141
set(DOCSTRINGS_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/include/depthai_python_docstring.hpp)
4242

4343
# First specify options
44+
option(DEPTHAI_PYTHON_USE_FIND_PACKAGE "Use find_package for depthai-core" OFF)
4445
option(DEPTHAI_PYTHON_ENABLE_TESTS "Enable tests" OFF)
4546
option(DEPTHAI_PYTHON_ENABLE_EXAMPLES "Enable examples" OFF)
4647
option(DEPTHAI_PYTHON_BUILD_DOCS "Build documentation - see docs/requirements.txt for needed dependencies" OFF)
@@ -54,8 +55,13 @@ endif()
5455
# Add external dependencies
5556
add_subdirectory(external)
5657

57-
# Add depthai-cpp dependency
58-
add_subdirectory(depthai-core)
58+
# Add depthai-core dependency
59+
if(DEPTHAI_PYTHON_USE_FIND_PACKAGE)
60+
find_package(depthai CONFIG REQUIRED)
61+
else()
62+
add_subdirectory(depthai-core)
63+
endif()
64+
5965

6066
# Add pybind11 dependency
6167
#add_subdirectory(pybind11-2.5.0)
@@ -88,8 +94,10 @@ configure_file(cmake/docstring.hpp.in ${DOCSTRINGS_INCLUDE_PLACEHOLDER_PATH})
8894
# Add target to generate docstrings
8995
if (DEPTHAI_PYTHON_BUILD_DOCSTRINGS)
9096
include(pybind11-mkdoc)
97+
9198
# Check if pybind11_mkdoc available and create target
92-
target_pybind11_mkdoc_setup(${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT} depthai-core ${DEPTHAI_PYTHON_FORCE_DOCSTRINGS})
99+
target_pybind11_mkdoc_setup(${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT} depthai::core ${DEPTHAI_PYTHON_FORCE_DOCSTRINGS})
100+
93101
if(NOT TARGET pybind11_mkdoc)
94102
# Generate default docstrings to OUTPUT path
95103
configure_file(cmake/default_docstring.hpp.in ${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT} COPYONLY)
@@ -111,24 +119,24 @@ target_link_libraries(${TARGET_NAME}
111119
hedley
112120
)
113121

114-
# Version consists of: (depthai-core).(bindings revision)[+bindings hash]
115-
set(DEPTHAI_PYTHON_VERSION "${DEPTHAI_VERSION}.${PROJECT_VERSION}")
116-
117122
# Add default commit hash ('dev') if not build by CI
118123
if(NOT DEFINED ENV{CI} AND NOT DEPTHAI_PYTHON_COMMIT_HASH)
119-
set(DEPTHAI_PYTHON_COMMIT_HASH dev)
124+
set(DEPTHAI_PYTHON_COMMIT_HASH "dev")
120125
endif()
121126

122-
# Append build info to version
127+
# Get version to use
128+
set(version_command "import find_version as v; print(v.get_package_version())")
123129
if(DEPTHAI_PYTHON_COMMIT_HASH)
124-
set(DEPTHAI_PYTHON_VERSION "${DEPTHAI_PYTHON_VERSION}+${DEPTHAI_PYTHON_COMMIT_HASH}")
130+
set(version_command "import find_version as v; print(v.get_package_dev_version('${DEPTHAI_PYTHON_COMMIT_HASH}'))")
125131
endif()
132+
execute_process(COMMAND ${PYTHON_EXECUTABLE} "-c" "${version_command}"
133+
OUTPUT_VARIABLE DEPTHAI_PYTHON_VERSION
134+
OUTPUT_STRIP_TRAILING_WHITESPACE
135+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
136+
)
126137

127138
# Add version definition
128139
target_compile_definitions(${TARGET_NAME} PRIVATE DEPTHAI_PYTHON_VERSION="${DEPTHAI_PYTHON_VERSION}")
129-
target_compile_definitions(${TARGET_NAME} PRIVATE DEPTHAI_PYTHON_BINDINGS_REVISION="${PROJECT_VERSION}")
130-
target_compile_definitions(${TARGET_NAME} PRIVATE DEPTHAI_VERSION="${DEPTHAI_VERSION}")
131-
target_compile_definitions(${TARGET_NAME} PRIVATE DEPTHAI_PYTHON_COMMIT_HASH="${DEPTHAI_PYTHON_COMMIT_HASH}")
132140

133141
# Set compiler features (c++14), and disables extensions
134142
set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 14)

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ To build a wheel, execute the following
8383
python3 -m pip wheel . -w wheelhouse
8484
```
8585
86+
## Running tests
87+
88+
To run the tests build the library with the following options
89+
```
90+
mkdir build_tests && cd build_tests
91+
cmake .. -D DEPTHAI_PYTHON_ENABLE_TESTS=ON -D DEPTHAI_PYTHON_ENABLE_EXAMPLES=ON -D DEPTHAI_PYTHON_TEST_EXAMPLES=ON
92+
cmake --build . --parallel
93+
ctest
94+
```
95+
8696
8797
## Tested platforms
8898

cmake/pybind11-mkdoc.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ include(target-public-headers)
55
# target_pybind11_mkdoc_setup([path/to/output/docstring.hpp] [Library for which to generate: target-name] [Enforce pybind11_mkdoc existing ON/OFF])
66
function(target_pybind11_mkdoc_setup output_file target enforce)
77

8+
# Get unaliased target if alias target passed in
9+
get_target_property(original_target ${target} ALIASED_TARGET)
10+
if(original_target)
11+
set(target ${original_target})
12+
endif()
13+
814
# gets target public headers
915
get_target_public_headers(${target} header_files)
1016

@@ -51,9 +57,9 @@ function(pybind11_mkdoc_setup_internal target output_path mkdoc_headers enforce)
5157
-w 80
5258
-o "${output_path}"
5359
# List of include directories
54-
"-I$<JOIN:$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>,;-I>"
60+
"-I$<JOIN:$<TARGET_PROPERTY:${target},INTERFACE_INCLUDE_DIRECTORIES>,;-I>"
5561
# List of compiler definitions
56-
"-D$<JOIN:$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>,;-D>"
62+
"-D$<JOIN:$<TARGET_PROPERTY:${target},INTERFACE_COMPILE_DEFINITIONS>,;-D>"
5763
# List of headers for which to generate docstrings
5864
"${mkdoc_headers}"
5965
# Redirect stderr to not spam output

depthai-core

Submodule depthai-core updated 61 files

0 commit comments

Comments
 (0)