-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from laggykiller/main
Auto build binary wheels with CMake
- Loading branch information
Showing
349 changed files
with
592 additions
and
66,535 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
name: Build and upload to PyPI | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
# push: | ||
|
||
jobs: | ||
build_sdist: | ||
name: Build source distribution | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Build sdist | ||
run: pipx run build --sdist | ||
|
||
- name: Test sdist | ||
run: | | ||
python -m pip install dist/pyrlottie-*.tar.gz | ||
pip install pytest imgcompare | ||
pytest | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-sdist | ||
path: dist/*.tar.gz | ||
|
||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} ${{ matrix.arch }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: windows-2019 | ||
arch: x64 | ||
cibw_archs_windows: AMD64 | ||
cibw_build: "cp38* pp*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=x86_64 | ||
- os: windows-2019 | ||
arch: x86 | ||
cibw_archs_windows: x86 | ||
cibw_build: "cp38*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=x86 | ||
- os: windows-2019 | ||
arch: arm64 | ||
cibw_archs_windows: ARM64 | ||
cibw_build: "cp39*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=armv8 | ||
- os: macos-12 | ||
arch: x64 | ||
cibw_archs_macos: x86_64 | ||
cibw_build: "cp38* pp*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=x86_64 | ||
- os: macos-14 | ||
arch: arm64 | ||
cibw_archs_macos: arm64 | ||
cibw_build: "cp38* pp*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=armv8 | ||
- os: ubuntu-20.04 | ||
arch: x64 | ||
cibw_archs_linux: x86_64 | ||
cibw_build: "cp38* pp*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=x86_64 | ||
- os: ubuntu-20.04 | ||
arch: x86 | ||
cibw_archs_linux: i686 | ||
cibw_build: "cp38* pp*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=x86 | ||
- os: ubuntu-20.04 | ||
arch: arm64 | ||
cibw_archs_linux: aarch64 | ||
cibw_build: "cp38* pp*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=armv8 | ||
- os: ubuntu-20.04 | ||
arch: ppc64le | ||
cibw_archs_linux: ppc64le | ||
cibw_build: "cp38*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=ppc64le | ||
- os: ubuntu-20.04 | ||
arch: s390x | ||
cibw_archs_linux: s390x | ||
cibw_build: "cp38*" | ||
cibw_environment: PYRLOTTIE_COMPILE_TARGET=s390x | ||
|
||
steps: | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Install python packages | ||
run: pip install abi3audit patch | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Set up QEMU | ||
if: runner.os == 'Linux' | ||
uses: docker/setup-qemu-action@v2 | ||
with: | ||
platforms: all | ||
|
||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_BUILD_FRONTEND: build | ||
CIBW_ARCHS_WINDOWS: ${{ matrix.cibw_archs_windows }} | ||
CIBW_ARCHS_MACOS: ${{ matrix.cibw_archs_macos }} | ||
CIBW_ARCHS_LINUX: ${{ matrix.cibw_archs_linux }} | ||
CIBW_ENVIRONMENT: ${{ matrix.cibw_environment }} | ||
CIBW_BUILD: ${{ matrix.cibw_build }} | ||
CIBW_TEST_REQUIRES: pytest imgcompare | ||
CIBW_BEFORE_TEST: pip install --only-binary ":all:" Pillow numpy; true | ||
CIBW_BEFORE_TEST_WINDOWS: pip install --only-binary ":all:" Pillow numpy || VER>NUL | ||
CIBW_TEST_COMMAND: pytest {package}/tests | ||
CIBW_TEST_SKIP: "pp* *-*linux_{ppc64le,s390x} *-musllinux_i686" | ||
|
||
- name: abi3audit | ||
run: abi3audit $(ls ./wheelhouse/*.whl) --debug --verbose | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-${{ matrix.os }}-${{ matrix.arch }} | ||
path: ./wheelhouse/*.whl | ||
|
||
upload_pypi: | ||
needs: [build_wheels, build_sdist] | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'release' && github.event.action == 'published' | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
# unpacks default artifact into dist/ | ||
# if `name: artifact` is omitted, the action will create extra parent dir | ||
pattern: artifact-* | ||
path: dist | ||
|
||
- uses: pypa/[email protected] | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,3 +163,9 @@ dmypy.json | |
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# CMake | ||
CMakeUserPresets.json | ||
|
||
# Conan | ||
conan_output/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "libwebp"] | ||
path = libwebp | ||
url = https://github.com/webmproject/libwebp.git | ||
[submodule "rlottie"] | ||
path = rlottie | ||
url = https://github.com/Samsung/rlottie.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
cmake_minimum_required(VERSION 3.17) | ||
cmake_policy(SET CMP0074 NEW) | ||
|
||
find_package(PythonInterp 3 REQUIRED) | ||
|
||
set(GET_ARCH_CMD ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/scripts/get_arch.py") | ||
set(GET_DEPS_CMD ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/scripts/get_deps.py") | ||
set(APPLY_PATCHES_CMD ${PYTHON_EXECUTABLE} "-m" "patch") | ||
|
||
message(STATUS "Executing get_arch.py") | ||
execute_process( | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
COMMAND ${GET_ARCH_CMD} | ||
OUTPUT_VARIABLE PYRLOTTIE_COMPILE_TARGET | ||
) | ||
message(STATUS "Finished get_arch.py") | ||
message(STATUS "PYRLOTTIE_COMPILE_TARGET is ${PYRLOTTIE_COMPILE_TARGET}") | ||
|
||
message(STATUS "Executing get_deps.py") | ||
execute_process( | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
COMMAND ${GET_DEPS_CMD} | ||
) | ||
message(STATUS "Finished get_deps.py") | ||
|
||
file(GLOB PATCH_FILES "${CMAKE_SOURCE_DIR}/patches/*.patch") | ||
foreach(PATCH_FILE ${PATCH_FILES}) | ||
message(STATUS "Applying patch ${PATCH_FILE}") | ||
execute_process( | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
COMMAND ${APPLY_PATCHES_CMD} ${PATCH_FILE} | ||
COMMAND_ERROR_IS_FATAL ANY | ||
) | ||
message(STATUS "Finished applying patch ${PATCH_FILE}") | ||
endforeach() | ||
|
||
if (MSVC) | ||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Zi /Ob0 /Od /RTC1") | ||
elseif (LINUX) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") | ||
elseif (APPLE) | ||
if("${PYRLOTTIE_COMPILE_TARGET}" STREQUAL "armv8") | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0") | ||
else() | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -stdlib=libc++") | ||
endif() | ||
endif() | ||
|
||
set(BUILD_SHARED_LIBS OFF) | ||
set(ZLIB_USE_STATIC_LIBS ON) | ||
set(PNG_USE_STATIC_LIBS ON) | ||
|
||
# Add conan packages | ||
set(CONAN_ROOT ${CMAKE_SOURCE_DIR}/conan_output/${PYRLOTTIE_COMPILE_TARGET}) | ||
set(CONAN_TOOLCHAIN "${CONAN_ROOT}/conan_toolchain.cmake") | ||
|
||
if (EXISTS ${CONAN_TOOLCHAIN}) | ||
include(${CONAN_TOOLCHAIN}) | ||
else() | ||
message(FATAL_ERROR "The conan_toolchain file could not be found: ${CONAN_TOOLCHAIN}") | ||
endif() | ||
|
||
project(pyrlottie) | ||
|
||
add_subdirectory(libwebp) | ||
add_subdirectory(rlottie) | ||
|
||
# Install the module | ||
install(TARGETS lottie2gif gif2webp | ||
EXCLUDE_FROM_ALL | ||
RUNTIME DESTINATION ${PY_BUILD_CMAKE_MODULE_NAME} | ||
COMPONENT python_module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
# type: ignore | ||
import shutil | ||
|
||
from conan import ConanFile | ||
from conan.tools.cmake import CMakeDeps, CMakeToolchain | ||
|
||
|
||
class PyrlottieRecipe(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
|
||
def requirements(self): | ||
self.requires("giflib/5.2.1") | ||
self.requires("libpng/1.6.43") | ||
self.requires("zlib/1.3.1") | ||
self.requires("libjpeg/9e") | ||
|
||
def build_requirements(self): | ||
if not shutil.which("cmake"): | ||
self.tool_requires("cmake/[>=3.27]") | ||
|
||
def build(self): | ||
build_type = "Release" # noqa: F841 | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
cmake = CMakeDeps(self) | ||
tc.generate() | ||
cmake.generate() |
Oops, something went wrong.