Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python bindings for jsartoolkitNFT #431

Open
wants to merge 28 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d0089df
Add Python bindings for jsartoolkitNFT and update .gitignore
kalwalt Feb 20, 2025
fcab895
improved test and solve issue with ARLog's
kalwalt Feb 21, 2025
a0d4d8d
fix for last missed escape characters
kalwalt Feb 21, 2025
85acf85
Update .gitignore and enhance setup.py to download and include libjpeg
kalwalt Feb 21, 2025
c040dc3
Add nftMarker class to Python bindings and enhance test script for NF…
kalwalt Feb 21, 2025
a208c46
Add GitHub Actions workflow for building and testing Python bindings
kalwalt Feb 21, 2025
9bf7d5f
Enhance GitHub Actions workflow by adding submodule update step for b…
kalwalt Feb 21, 2025
2deb11f
Add config.h generation to setup.py for AR video input configuration
kalwalt Feb 21, 2025
74eca3b
Update GitHub Actions workflow to install system dependencies for lib…
kalwalt Feb 21, 2025
0e7e63e
Refactor build process for libjpeg in setup.py and update workflow to…
kalwalt Feb 21, 2025
5e1dd79
Use absolute path for build directory in setup.py
kalwalt Feb 21, 2025
4dd58f3
Add installation of libjpeg9 in GitHub Actions workflow
kalwalt Feb 22, 2025
09b8ab2
Update Python dependencies in GitHub Actions workflow to include numpy
kalwalt Feb 22, 2025
e24726a
Add separate build jobs for Linux and Windows in GitHub Actions workflow
kalwalt Feb 22, 2025
67d1306
Update GitHub Actions workflow to install libjpeg-turbo instead of li…
kalwalt Feb 22, 2025
9b8fff2
Update GitHub Actions workflow to use bash for adding vcpkg to path
kalwalt Feb 22, 2025
0197900
Refactor setup.py to conditionally handle libjpeg build for Windows u…
kalwalt Feb 22, 2025
dfc40bf
Add zlib, libjpeg, and pthread libraries for Windows support; update …
kalwalt Feb 24, 2025
70deb15
Refactor setup.py to use conditional extra_compile_args for Windows b…
kalwalt Feb 24, 2025
7f157c7
Refactor setup.py to conditionally build libjpeg for Linux platforms
kalwalt Feb 24, 2025
efde8d7
Add jconfig.h and jversion.h for libjpeg-turbo support; update extra_…
kalwalt Feb 24, 2025
1f3d30f
Add caching for pip packages and vcpkg in GitHub Actions; update setu…
kalwalt Feb 24, 2025
0d4bdeb
Add pthreads installation to GitHub Actions and update setup.py for l…
kalwalt Feb 24, 2025
15e44b7
Add unit tests for jsartoolkitNFT and update GitHub Actions workflow
kalwalt Feb 24, 2025
36e44d3
Update expected values in unit tests for cameraId and id
kalwalt Feb 25, 2025
96b993e
Update GitHub Actions to use Windows 2022 and enhance unit tests for …
kalwalt Feb 25, 2025
d067b37
Upgrade GitHub Actions to Ubuntu 24.04, update Node.js setup, and mod…
kalwalt Feb 25, 2025
4b31bdd
Add installation of ChromiumHeadless in GitHub Actions workflow
kalwalt Feb 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@ on:
jobs:

tests:
strategy:
matrix:
node:
- 20.x

# Packages 'firefox' and 'chromium' are pre-installed.
#
# https://github.com/actions/virtual-environments/blob/ubuntu20/20210302.0/images/linux/Ubuntu2004-README.md
runs-on: ubuntu-20.04
name: Node.js ${{ matrix.node }}
runs-on: ubuntu-24.04 # Upgrade to Ubuntu 24.04
name: Node.js CI
steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node }}
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version-file: ".nvmrc"

- name: Install ChromiumHeadless
run: |
sudo apt-get update
sudo apt-get install -y chromium-browser

- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}

- uses: actions/cache@v4
id: npm-cache
with:
path: ~/.npm
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
Expand Down
120 changes: 120 additions & 0 deletions .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Build and Test Python Bindings

on:
push:
pull_request:

jobs:
build-linux:
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libjpeg9

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install numpy setuptools wheel pybind11

- name: Update submodules
run: git submodule update --init

- name: Build the Python bindings
run: |
cd python-bindings
python setup.py build_ext --inplace

- name: Test the build
run: |
cd python-bindings
python test.py

- name: Run unit tests
run: |
cd python-bindings
python -m unittest discover -s . -p 'unittests.py'

build-windows:
runs-on: windows-2022

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Cache vcpkg
uses: actions/cache@v4
with:
path: |
vcpkg
!vcpkg/.git
key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }}

- name: Install vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat

- name: Install libjpeg-turbo
run: .\vcpkg\vcpkg install libjpeg-turbo

- name: Install pthreads
run: .\vcpkg\vcpkg install pthreads

- name: Add vcpkg to path
shell: bash
run: echo "vcpkg/installed/x64-windows/bin" >> $GITHUB_PATH

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install numpy setuptools wheel pybind11

- name: Update submodules
run: git submodule update --init

- name: Build the Python bindings
run: |
cd python-bindings
python setup.py build_ext --inplace

- name: Test the build
run: |
cd python-bindings
python test.py

- name: Run unit tests
run: |
cd python-bindings
python -m unittest discover -s . -p 'unittests.py'
22 changes: 16 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,34 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-24.04 # Upgrade to Ubuntu 24.04

strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}

- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version-file: ".nvmrc"

- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Set output
id: vars
run: echo name=tag::${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT

- name: Check output
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: |
echo $RELEASE_VERSION
echo ${{ steps.vars.outputs.tag }}

- uses: actions/upload-artifact@v4
with:
name: build
Expand All @@ -42,22 +44,30 @@ jobs:
!build/libar.o
!build/libar_td.o
!build/libar_simd.o

- run: git submodule update --init

- run: npm install

- run: docker run -dit --name emscripten -v $(pwd):/src emscripten/emsdk:3.1.69 bash

- run: docker exec emscripten npm run build

- uses: actions/upload-artifact@v4
with:
name: dist
path: dist

- run: npm run build-ts

- name: Commit changes
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: new build files from action
add: '["build", "dist"]'

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ build/*.a
node_modules
docs/*
emscripten/build
python-bindings/build
python-bindings/*.so
python-bindings/deps/libjpeg/*
python-bindings/__pycache__
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"build-docker": "docker exec emscripten-jsartoolkitnft npm run build",
"build-docker-no-libar": "docker exec emscripten-jsartoolkitnft npm run build-no-libar",
"test-browser": "karma start --browsers Chrome,Firefox,ChromeHeadless,FirefoxHeadless",
"build-python-bindings": "cd python-bindings && python setup.py build_ext --inplace",
"test": "karma start",
"watch": "./node_modules/.bin/watch 'npm run build' ./js/",
"format-check": "prettier --check .",
Expand Down
Loading