Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
104 changes: 94 additions & 10 deletions .github/workflows/wheel-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,20 @@ on:
description: "Build Linux ARM Wheels"
type: boolean
default: true
runner:
description: Choose MacOS Action Runner Type
type: choice
options:
- "self-hosted"
- "macos-12"
- "macos-13"
- "macos-14"
- "macos-15"
default: "self-hosted"

env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
VCPKG_FEATURE_FLAGS: "dependencygraph"
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
VCPKG_FEATURE_FLAGS: dependencygraph
VCPKG_DISABLE_METRICS: true
BUILD_PRESET: "release"

Expand Down Expand Up @@ -67,42 +77,111 @@ jobs:
build_wheels-macos:
name: MacOS Wheels Build
needs: [get_macos_matrix]
runs-on: self-hosted-${{ matrix.type }}
runs-on: ${{ inputs.runner }}-${{ matrix.type }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.get_macos_matrix.outputs.matrix) }}
env:
VCPKG_BINARY_SOURCES: "clear;files,/Users/sre/GitHub/vcpkg-cache-deepframe-${{ matrix.type }},readwrite"

steps:
- name: set platform name
id: platform-name
shell: bash
env:
TYPE: ${{ matrix.type }}
run: |
case "${TYPE}" in
xlarge)
echo "platform=macosx_11_0_arm64" >> $GITHUB_OUTPUT
echo "arch=arm64" >> $GITHUB_OUTPUT
echo "triplet=arm64-osx" >> $GITHUB_OUTPUT
;;
large)
echo "platform=macosx_10_9_x86_64" >> $GITHUB_OUTPUT
echo "arch=x86_64" >> $GITHUB_OUTPUT
echo "triplet=x64-osx" >> $GITHUB_OUTPUT
;;
esac

- name: set vcpkg cache path
id: vcpkg-cache
shell: bash
env:
ARCH: ${{ steps.platform-name.outputs.arch }}
run: |
echo "cache_path=/Users/sre/GitHub/vcpkg-cache-deepframe-${{ steps.platform-name.outputs.triplet }}" >> $GITHUB_OUTPUT

- name: clone repository
uses: actions/checkout@v4.2.2

- name: setup python ${{ matrix.python }}
uses: actions/setup-python@v5.3.0
if: inputs.runner != 'self-hosted'
with:
python-version: ${{ matrix.python }}

- name: setup python ${{ matrix.python }} environment
id: setup
shell: bash
run: |-
python${{ matrix.python }} -m venv "venv_${{ matrix.venv }}"
source "venv_${{ matrix.venv }}/bin/activate"
python"${{ matrix.python }}" -m pip install -qqq -U pip setuptools build; deactivate
python"${{ matrix.python }}" -m pip install -qqq -U pip setuptools build cmake==3.29.2
deactivate
echo -e "\n[bdist_wheel]\nplat-name = ${{ steps.platform-name.outputs.platform }}" >> setup.cfg

- name: install vcpkg
shell: bash
run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 1de2026f28ead93ff1773e6e680387643e914ea1 && ./bootstrap-vcpkg.sh
run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 6f29f12e82a8293156836ad81cc9bf5af41fe836 && ./bootstrap-vcpkg.sh

- name: install vcpkg dependencies
shell: bash
env:
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
VCPKG_TARGET_TRIPLET: ${{ steps.platform-name.outputs.triplet }}
VCPKG_HOST_TRIPLET: ${{ steps.platform-name.outputs.triplet }}
run: |
cd vcpkg
./vcpkg install --triplet=${{ steps.platform-name.outputs.triplet }} openssl liblzma libiconv zlib
cd ..

- name: clean build artifacts
shell: bash
run: |
# Clean build directory to ensure fresh build
rm -rf build
# Clean architecture-specific FFmpeg installations
rm -rf .ext-*
Comment thread
khustup2 marked this conversation as resolved.



- name: build py${{ matrix.python }}
env:
CMAKE_OSX_ARCHITECTURES: ${{ steps.platform-name.outputs.arch }}
VCPKG_TARGET_TRIPLET: ${{ steps.platform-name.outputs.triplet }}
VCPKG_HOST_TRIPLET: ${{ steps.platform-name.outputs.triplet }}
VCPKG_BINARY_SOURCES: "clear"
VCPKG_DISABLE_METRICS: true
VCPKG_OVERLAY_TRIPLETS: ""
VCPKG_OVERLAY_PORTS: ""
shell: bash
run: |-
CMAKE_PATH=$(whereis cmake | awk '{print $2}')
Copy link

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using whereis and awk to find cmake path is fragile and may fail if cmake is not found or if whereis returns a different format. Consider using which cmake or command -v cmake which are more reliable for finding executable paths.

Suggested change
CMAKE_PATH=$(whereis cmake | awk '{print $2}')
CMAKE_PATH=$(command -v cmake)

Copilot uses AI. Check for mistakes.
Comment thread
khustup2 marked this conversation as resolved.
CMAKE_DIR=$(dirname "$CMAKE_PATH")
echo "$CMAKE_DIR" >> $GITHUB_PATH

source "venv_${{ matrix.venv }}/bin/activate"
python"${{ matrix.python }}" -m pip install -r requirements-dev.txt &&
python"${{ matrix.python }}" scripts/build.py "${{ env.BUILD_PRESET }}"
python"${{ matrix.python }}" -m build; deactivate
python"${{ matrix.python }}" -m build
deactivate

- name: run tests
shell: bash
run: |-
source "venv_${{ matrix.venv }}/bin/activate"
timeout -k 10s 30m python"${{ matrix.python }}" -m pytest; deactivate
timeout -k 10s 30m python"${{ matrix.python }}" -m pytest
deactivate

- uses: actions/upload-artifact@v4.6.1
if: ${{ always() }}
Expand Down Expand Up @@ -159,13 +238,18 @@ jobs:
shell: bash
run: git clone -b "${{ github.ref_name }}" "https://activeloop-bot:${{ secrets.ORG_GH_BOT_PAT }}@github.com/${{ github.repository }}" .

- name: setup environment
shell: bash
run: |
echo -e "\n[bdist_wheel]\nplat-name = manylinux2014_${{ matrix.type }}" >> setup.cfg

- name: download vcpkg cache
shell: bash
run: source scripts/build_scripts/get_creds.sh && python3.11 scripts/build_scripts/manage_cache.py download deepframe

- name: install vcpkg
shell: bash
run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 1de2026f28ead93ff1773e6e680387643e914ea1 && ./bootstrap-vcpkg.sh
run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 6f29f12e82a8293156836ad81cc9bf5af41fe836 && ./bootstrap-vcpkg.sh

- name: build py${{ matrix.python }}
shell: bash
Expand Down
64 changes: 52 additions & 12 deletions cmake/modules/findFFmpeg.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
include(ExternalProject)

set(DEFAULT_PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../)
set(ffmpeg_BUILD_INSTALL_PREFIX ${DEFAULT_PARENT_DIR}/.ext)

# Make installation directory architecture-specific
# Use target architecture from CMAKE_OSX_ARCHITECTURES for cross-compilation
if(APPLE)
if (CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
set(ffmpeg_INSTALL_DIR "${DEFAULT_PARENT_DIR}/.ext-arm64")
set(ffmpeg_BUILD_INSTALL_PREFIX ${DEFAULT_PARENT_DIR}/.ext-arm64)
set(ffmpeg_SOURCE_DIR ${DEFAULT_PARENT_DIR}/.ext-arm64/ffmpeg)
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
set(ffmpeg_INSTALL_DIR "${DEFAULT_PARENT_DIR}/.ext-x86_64")
set(ffmpeg_BUILD_INSTALL_PREFIX ${DEFAULT_PARENT_DIR}/.ext-x86_64)
set(ffmpeg_SOURCE_DIR ${DEFAULT_PARENT_DIR}/.ext-x86_64/ffmpeg)
endif()
elseif(UNIX)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL aarch64)
set(ffmpeg_INSTALL_DIR "${DEFAULT_PARENT_DIR}/.ext-aarch64")
set(ffmpeg_BUILD_INSTALL_PREFIX ${DEFAULT_PARENT_DIR}/.ext-aarch64)
set(ffmpeg_SOURCE_DIR ${DEFAULT_PARENT_DIR}/.ext-aarch64/ffmpeg)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
set(ffmpeg_INSTALL_DIR "${DEFAULT_PARENT_DIR}/.ext-x86_64")
set(ffmpeg_BUILD_INSTALL_PREFIX ${DEFAULT_PARENT_DIR}/.ext-x86_64)
set(ffmpeg_SOURCE_DIR ${DEFAULT_PARENT_DIR}/.ext-x86_64/ffmpeg)
endif()
endif()

set(ffmpeg_URL "https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n7.1.tar.gz")
set(ffmpeg_SOURCE_DIR ${DEFAULT_PARENT_DIR}/.ext/ffmpeg)
set(ffmpeg_SHA256_HASH 7ddad2d992bd250a6c56053c26029f7e728bebf0f37f80cf3f8a0e6ec706431a)
set(ffmpeg_INSTALL_DIR "${DEFAULT_PARENT_DIR}/.ext")

set(ffmpeg_PKG_CONFIG_PATH "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/pkgconfig:${DEFAULT_PARENT_DIR}/.ext/lib/pkgconfig")
set(ffmpeg_PKG_CONFIG_PATH "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/pkgconfig:${ffmpeg_INSTALL_DIR}/lib/pkgconfig")

macro(check_lib_existence LIB_NAME)
find_path(${LIB_NAME}_EXISTS
Expand Down Expand Up @@ -37,30 +59,38 @@ macro(build_ffmpeg_once)
set(EXTRA_ARGUMENTS)
if(APPLE)
list(APPEND EXTRA_ARGUMENTS "--target-os=darwin")
if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm64)
if (CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
list(APPEND EXTRA_ARGUMENTS "--arch=arm64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64)
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
list(APPEND EXTRA_ARGUMENTS "--arch=x86_64")
endif()
elseif(UNIX)
list(APPEND EXTRA_ARGUMENTS "--target-os=linux")
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL aarch64)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL aarch64)
list(APPEND EXTRA_ARGUMENTS "--arch=arm64")
elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL x86_64)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
list(APPEND EXTRA_ARGUMENTS "--arch=x86_64")
endif()
endif()

set(FFMPEG_EP_DEPENDS)

message(STATUS "Building FFmpeg with extra arguments: ${EXTRA_ARGUMENTS}")
message(STATUS "FFmpeg target architecture: ${CMAKE_OSX_ARCHITECTURES}")
message(STATUS "VCPKG_TARGET_TRIPLET: ${VCPKG_TARGET_TRIPLET}")
message(STATUS "FFmpeg install directory: ${ffmpeg_INSTALL_DIR}")

ExternalProject_Add(ffmpeg_ep
SOURCE_DIR ${ffmpeg_SOURCE_DIR}
URL ${ffmpeg_URL}
URL_HASH SHA256=${ffmpeg_SHA256_HASH}
CONFIGURE_COMMAND
${CMAKE_COMMAND} -E env PKG_CONFIG_PATH=${ffmpeg_PKG_CONFIG_PATH} ${ffmpeg_SOURCE_DIR}/configure
${CMAKE_COMMAND} -E env
PKG_CONFIG_PATH=${ffmpeg_PKG_CONFIG_PATH}
VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}
VCPKG_HOST_TRIPLET=${VCPKG_HOST_TRIPLET}
CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
${ffmpeg_SOURCE_DIR}/configure
--quiet
--prefix=${ffmpeg_INSTALL_DIR}
--disable-programs
Expand Down Expand Up @@ -90,8 +120,18 @@ macro(build_ffmpeg_once)
BUILD_IN_SOURCE TRUE
PATCH_COMMAND
patch -p1 < ${DEFAULT_PARENT_DIR}/cmake/modules/url_max_length_fix.patch
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND $(MAKE) install
BUILD_COMMAND
${CMAKE_COMMAND} -E env
VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}
VCPKG_HOST_TRIPLET=${VCPKG_HOST_TRIPLET}
CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
$(MAKE)
INSTALL_COMMAND
${CMAKE_COMMAND} -E env
VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}
VCPKG_HOST_TRIPLET=${VCPKG_HOST_TRIPLET}
CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
$(MAKE) install
DEPENDS ${FFMPEG_EP_DEPENDS}
${EP_LOG_OPTIONS}
)
Expand Down Expand Up @@ -136,4 +176,4 @@ macro(ensure_ffmpeg)
PROPERTIES INTERFACE_LINK_LIBRARIES
"-framework VideoToolbox -framework CoreFoundation -framework CoreMedia -framework CoreVideo -framework CoreServices")
endif()
endmacro()
endmacro()
19 changes: 19 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@ if (NOT DEFINED ENV{VCPKG_ROOT})
message(FATAL_ERROR "You must set VCPKG_ROOT environment variable to point to your vcpkg installation")
endif ()

# Set vcpkg triplet before including the toolchain
if (DEFINED ENV{VCPKG_TARGET_TRIPLET})
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_TARGET_TRIPLET}" CACHE STRING "Vcpkg target triplet")
message(STATUS "Setting VCPKG_TARGET_TRIPLET: ${VCPKG_TARGET_TRIPLET}")
endif()

if (DEFINED ENV{VCPKG_HOST_TRIPLET})
set(VCPKG_HOST_TRIPLET "$ENV{VCPKG_HOST_TRIPLET}" CACHE STRING "Vcpkg host triplet")
message(STATUS "Setting VCPKG_HOST_TRIPLET: ${VCPKG_HOST_TRIPLET}")
endif()

set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")

project(deepframe_project LANGUAGES CXX)

# Verify cross-compilation setup
if (APPLE AND DEFINED CMAKE_OSX_ARCHITECTURES)
message(STATUS "Target architecture: ${CMAKE_OSX_ARCHITECTURES}")
if (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
message(STATUS "Cross-compiling x86_64 on ARM64 host")
endif()
endif()

# Set C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
Loading