This document outlines the strategy to integrate Python packages from user-init-examples/requirements.txt into the BrightSign SDK build using BitBake recipes. After analyzing existing recipes in the BrightSign OE tree, many packages are already available.
Current Status in brightsign-sdk.bb:
- ✅ Already included: opencv, python3-core, python3-modules, python3-dev, python3-numpy, python3-pillow
Package Categories (Updated):
- ✅ Already in SDK (5 packages): numpy, pillow, opencv-python, python3-core, python3-dev
- 🟢 Easy Integration (8 packages): Standard OE recipes available in source tree
⚠️ Moderate Complexity (5 packages): Custom recipes needed, manageable dependencies- 🔴 High Complexity (4 packages): Significant build challenges, may need wheel approach
- 🎯 Custom/Proprietary (2 packages): Rockchip-specific
- 🚨 HIGH PRIORITY: python3-pip and python3-setuptools (required for package management)
- Status: ✅ RECIPE EXISTS
- Recipe Source:
oe-core/meta/recipes-devtools/python/python3-pip_20.0.2.bb - Dependencies: python3-setuptools, python3-wheel
- Issues: None - standard package
- Integration: Add to SDK immediately - enables runtime package installation
- Status: ✅ RECIPE EXISTS
- Recipe Source:
oe-core/meta/recipes-devtools/python/python3-setuptools_45.2.0.bb - Dependencies: python3-core
- Issues: None - standard package
- Integration: Add to SDK (dependency of pip)
- Status: ✅ ALREADY IN SDK
- Location: brightsign-sdk.bb line 23
- Status: ✅ ALREADY IN SDK
- Location: brightsign-sdk.bb line 24
- Status: ✅ ALREADY IN SDK (as opencv)
- Location: brightsign-sdk.bb line 19
- Recipe Source: Need to search for protobuf recipe
- Dependencies: protobuf, protobuf-native
- Issues: Version pinning may require adjustment
- Integration: Check if available, may need custom recipe
- Status: ✅ RECIPE EXISTS
- Recipe Source:
oe-core/meta/recipes-devtools/python/python3-jinja2_2.11.3.bb - Dependencies: python3-markupsafe
- Issues: None
- Integration: Add to SDK
- Status: ✅ RECIPE EXISTS
- Recipe Source:
oe-core/meta/recipes-devtools/python/python3-markupsafe_1.1.1.bb - Dependencies: python3-setuptools
- Issues: None
- Integration: Add to SDK (dependency of jinja2)
- Status: ✅ RECIPE EXISTS
- Recipe Source:
meta-oe/meta-python/recipes-devtools/python/python3-psutil_5.7.0.bb - Dependencies: python3-setuptools
- Issues: None - system utilities binding
- Integration: Add meta-python layer dependency
- Status: ✅ RECIPE EXISTS
- Recipe Source:
meta-oe/meta-python/recipes-devtools/python/python3-tqdm_4.43.0.bb - Dependencies: python3-setuptools
- Issues: None - pure Python progress bars
- Integration: Add meta-python layer dependency
- Status: ✅ RECIPE EXISTS
- Recipe Source:
meta-oe/meta-python/recipes-devtools/python/python3-typing-extensions_3.7.4.2.bb - Dependencies: python3-setuptools
- Issues: None - pure Python
- Integration: Add meta-python layer dependency
- Recipe Source: Need to check if available
- Dependencies: python3-setuptools
- Issues: None - pure Python
- Integration: Add meta-python layer dependency
- Recipe Source: Need to check if available
- Dependencies: python3-setuptools
- Issues: None - filesystem interfaces
- Integration: Add meta-python layer dependency
- Status: ✅ RECIPE EXISTS
- Recipe Source:
meta-oe/meta-python/recipes-devtools/python/python3-networkx_2.4.bb - Dependencies: python3-setuptools
- Issues: None - pure Python graph library
- Integration: Add meta-python layer dependency
- Status: ✅ RECIPE EXISTS
- Recipe Source:
meta-oe/meta-python/recipes-devtools/python/python3-mpmath_1.1.0.bb - Dependencies: python3-setuptools
- Issues: None - pure Python arbitrary precision math
- Integration: Add to SDK
- Status: ✅ RECIPE EXISTS
- Recipe Source:
meta-oe/meta-python/recipes-devtools/python/python3-ruamel-yaml_0.16.5.bb - Dependencies: python3-setuptools
- Issues: Version 0.16.5 vs required >=0.17.4
- Integration: Add to SDK, may need version update
- Recipe Source:
meta-openembedded/meta-python/recipes-devtools/python/python3-scipy_*.bb - Dependencies: python3-numpy, BLAS, LAPACK, gfortran
- Issues: Fortran cross-compilation, large binary size (~50MB)
- Build Impact: Requires gfortran-cross, increases build time significantly
- Integration: Add meta-python dependency, ensure Fortran toolchain available
- Recipe Source:
meta-openembedded/meta-oe/recipes-devtools/flatbuffers/python3-flatbuffers_*.bb - Dependencies: flatbuffers, cmake, python3-setuptools
- Issues: CMake cross-compilation complexity
- Integration: Add meta-oe dependency, verify CMake cross-compilation
- Status: 🚫 CURRENTLY BROKEN - custom recipe needed
- Recipe Source: Custom recipe needed
- Dependencies: python3-numpy, Cython, python3-setuptools
- Issues: Cython compilation, cross-compilation of C extensions
- Integration: Fix existing custom recipe or create new one
- Recipe Source:
meta-pytorch/recipes-devtools/python/python3-torch_*.bb(often broken) - Alternative: Pre-built wheel approach
- Dependencies: MASSIVE - CUDA, OpenMP, BLAS, LAPACK, protobuf, 100+ libraries
- Issues:
- Extremely complex build system (1-2 hours compile time)
- Binary size: 1GB+
- Cross-compilation nearly impossible for full build
- CUDA dependencies optional but complex
- Build Impact: Dramatic increase in build time and image size
- Integration Strategy: Use pre-built ARM64 wheel, create stub recipe
- Status: 🚫 CURRENTLY BROKEN - build failures
- Recipe Source: Custom recipe exists but fails
- Dependencies: protobuf, cmake, python3-numpy, python3-setuptools
- Issues:
- CMake cross-compilation complexity
- Protobuf version conflicts
- Setup.py AttributeError with newer setuptools
- Integration Strategy: Fix CMake configuration or use wheel approach
- Status: 🚫 CURRENTLY BROKEN - build failures
- Recipe Source: Custom recipe exists but fails
- Dependencies: onnx, many native libraries, potentially CUDA
- Issues:
- Microsoft's complex build system
- Cross-compilation extremely difficult
- Large binary size
- Integration Strategy: Use pre-built ARM64 wheel
- Recipe Source:
meta-tensorflow/recipes-devtools/python/python3-tensorflow_*.bb(often broken) - Alternative: Pre-built wheel approach
- Dependencies: ENORMOUS - bazel, protobuf, grpc, 200+ libraries
- Issues:
- Bazel build system incompatible with cross-compilation
- Binary size: 500MB-1GB+
- Build time: 3-6 hours
- Memory requirements: 8GB+ RAM for compilation
- Build Impact: Makes build nearly impossible on constrained systems
- Integration Strategy: Use pre-built ARM64 wheel, create stub recipe
- Status:
⚠️ PARTIALLY IMPLEMENTED - needs wheel file - Recipe Source: Custom recipe exists but missing wheel file
- Dependencies: python3-numpy, proprietary Rockchip libraries
- Issues: Requires manual wheel file placement
- Integration: Provide wheel file, complete custom recipe
- Recipe Source: Custom recipe needed
- Dependencies: onnx (which is broken)
- Issues: Depends on onnx being functional first
- Integration Strategy: Address after onnx is resolved
oe-core- Base OpenEmbedded recipesmeta-bs- BrightSign custom layer
meta-openembedded/meta-python- Python package recipesmeta-openembedded/meta-oe- Additional tools and librariesmeta-pytorch- PyTorch recipes (if attempting source build)meta-tensorflow- TensorFlow recipes (if attempting source build)
Add to conf/bblayers.conf:
${BSPDIR}/meta-openembedded/meta-python \
${BSPDIR}/meta-openembedded/meta-oe \
Packages: python3-pip, python3-setuptools
Actions:
- Add python3-pip to brightsign-sdk.bb IMMEDIATELY
- Add python3-setuptools as dependency
- This enables runtime package installation fallback
Risk: None - standard packages, required for any Python development
Packages: protobuf, jinja2, markupsafe, psutil, tqdm, typing-extensions, networkx, mpmath, ruamel.yaml
Actions:
- These recipes already exist in the source tree
- Add to brightsign-sdk.bb TOOLCHAIN_TARGET_TASK
- No new layers needed - already in meta-python
- Verify package functionality
Risk: Low - recipes already exist, just need to include them
Packages: scipy, flatbuffers, mpmath, ruamel.yaml, fast-histogram
Actions:
- Add meta-oe layer dependency
- Investigate and fix fast-histogram recipe
- Test scipy with Fortran dependencies
- Verify all packages build and function
Risk: Medium - build complexity, dependency chain issues
Packages: torch, tensorflow, onnx, onnxruntime, onnxoptimizer
Strategy: Create wheel-based recipes that:
- Download pre-built ARM64 wheels
- Extract and install without compilation
- Handle dependency stubbing
- Skip QA checks for pre-built binaries
Actions:
- Research available ARM64 wheels on PyPI
- Create stub recipes for wheel installation
- Test import functionality
- Document limitations (may not have full functionality)
Risk: High - wheel availability, dependency satisfaction, reduced functionality
Packages: rknn-toolkit2
Actions:
- Obtain Rockchip wheel files
- Complete integration with librknnrt
- Test full RKNN functionality
- Current baseline: ~200MB Python environment
- After Phase 1: +50MB (pure Python packages)
- After Phase 2: +200MB (scipy, scientific computing)
- After Phase 3: +1.5GB (PyTorch, TensorFlow wheels)
- Total: ~2GB Python environment
- Current baseline: 30-45 minutes
- After Phase 1: +5 minutes (quick Python packages)
- After Phase 2: +15 minutes (scipy compilation)
- After Phase 3: +10 minutes (wheel downloads/extraction)
- Total: 60-75 minutes
- Phase 1-2: Current 4GB RAM sufficient
- Phase 3: If building from source would need 8GB+, but wheel approach avoids this
-
Wheel Availability: ARM64 wheels may not exist for all packages
- Mitigation: Test wheel availability first, have fallback strategies
-
Dependency Conflicts: Version mismatches between packages
- Mitigation: Careful version pinning, dependency testing
-
Storage Constraints: 2GB Python environment may be too large
- Mitigation: Modular approach, optional package groups
-
Cross-compilation Failures: Complex packages may not cross-compile
- Mitigation: Wheel approach for problematic packages
-
Build Time: Extended build times may impact development cycle
- Mitigation: Incremental builds, sstate caching
-
Maintenance Burden: Many custom recipes to maintain
- Mitigation: Prefer standard OE recipes, document customizations
- All 10 easy packages build successfully
- Package imports work in test environment
- Build time increase <10 minutes
- No conflicts with existing packages
- scipy builds with Fortran support
- fast-histogram recipe fixed
- All moderate complexity packages functional
- Storage increase <300MB total
- PyTorch wheel installs and imports successfully
- TensorFlow wheel installs and imports successfully
- ONNX packages functional via wheel approach
- Basic deep learning functionality verified
- All 23 packages pass test_cv_packages.py validation
- RKNN model zoo examples run successfully
- Total environment size <2.5GB
- Build completes in <90 minutes
Add the following to TOOLCHAIN_TARGET_TASK in brightsign-sdk.bb:
TOOLCHAIN_TARGET_TASK += "\
libstdc++ \
opencv \
python3-core \
python3-modules \
python3-dev \
python3-numpy \
python3-pillow \
python3-pip \ # CRITICAL - package management
python3-setuptools \ # CRITICAL - pip dependency
python3-protobuf \ # Protocol buffers
python3-jinja2 \ # Template engine
python3-markupsafe \ # Jinja2 dependency
python3-psutil \ # System utilities
python3-tqdm \ # Progress bars
python3-typing-extensions \ # Type hints
python3-networkx \ # Graph algorithms
python3-mpmath \ # Arbitrary precision math
python3-ruamel-yaml \ # YAML processing
"- Add python3-pip FIRST - enables runtime package installation
- Add all Phase 1 packages that have existing recipes
- Test build with these additions
- Create custom recipes for missing packages (filelock, fsspec, flatbuffers)
- Incremental integration - add packages in phases, not all at once
- Comprehensive testing - verify each package before moving to next
- Fallback strategies - have wheel approach ready for complex packages
- Documentation - document all customizations and integration choices
- Monitor upstream - track OE recipe improvements for complex packages
- Contribute back - submit working recipes to appropriate layers
- Optimize size - investigate package minimization strategies
- Modular deployment - consider optional package groups for different use cases
This build plan provides a structured approach to integrating all required Python packages while managing risk and complexity. The phased approach allows for early wins while tackling the most challenging packages with appropriate strategies.