From 07fa8f1f81364a5e69ec21cf6b0edcc8f8b5d8b3 Mon Sep 17 00:00:00 2001 From: laggykiller Date: Sat, 9 Sep 2023 20:14:29 +0800 Subject: [PATCH] Use conan2 --- .github/workflows/build.yaml | 30 ++++------ .gitignore | 3 +- CMakeLists.txt | 106 ++++------------------------------- CMakeUserPresets.json | 9 +++ apngasm | 2 +- conanfile.py | 19 +++++++ get-deps.py | 104 ++++++++++++++++++++++++++++++++++ get-target-linux.sh | 20 ------- get-target-mac.sh | 20 ------- get-target-win.bat | 17 ------ prepare-linux.sh | 55 ------------------ prepare-mac.sh | 85 ---------------------------- prepare-win.bat | 60 -------------------- pyproject.toml | 23 ++++++-- 14 files changed, 175 insertions(+), 378 deletions(-) create mode 100644 CMakeUserPresets.json create mode 100644 conanfile.py create mode 100644 get-deps.py delete mode 100755 get-target-linux.sh delete mode 100755 get-target-mac.sh delete mode 100644 get-target-win.bat delete mode 100755 prepare-linux.sh delete mode 100755 prepare-mac.sh delete mode 100755 prepare-win.bat diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b519538..3f86c30 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,25 +17,21 @@ jobs: matrix: include: - os: windows-2019 - arch: x64 submodules_mode: true cibw_archs_windows: AMD64 - cibw_environment: APNGASM_COMPILE_TARGET=x64 + cibw_environment: APNGASM_COMPILE_TARGET=x86_64 cibw_before_all: prepare-win.bat - os: windows-2019 - arch: x86 submodules_mode: true cibw_archs_windows: x86 cibw_environment: APNGASM_COMPILE_TARGET=x86 cibw_before_all: prepare-win.bat - os: windows-2019 - arch: arm64 submodules_mode: true cibw_archs_windows: ARM64 - cibw_environment: APNGASM_COMPILE_TARGET=ARM64 + cibw_environment: APNGASM_COMPILE_TARGET=armv8 cibw_before_all: prepare-win.bat - os: macos-11 - arch: x64 submodules_mode: true cibw_archs_macos: x86_64 cibw_environment: > @@ -48,11 +44,10 @@ jobs: VCPKG_CXX_FLAGS="-mmacosx-version-min=10.15" cibw_before_all: ./prepare-mac.sh - os: macos-11 - arch: arm64 submodules_mode: true cibw_archs_macos: arm64 cibw_environment: > - APNGASM_COMPILE_TARGET=arm64 + APNGASM_COMPILE_TARGET=armv8 _PYTHON_HOST_PLATFORM=macosx-11.0-arm64 VCPKG_OSX_DEPLOYMENT_TARGET=11.0 MACOSX_DEPLOYMENT_TARGET=11.0 @@ -61,7 +56,6 @@ jobs: VCPKG_CXX_FLAGS="-mmacosx-version-min=11.0" cibw_before_all: ./prepare-mac.sh - os: macos-11 - arch: universal2 submodules_mode: true cibw_archs_macos: universal2 cibw_environment: > @@ -73,57 +67,57 @@ jobs: VCPKG_C_FLAGS="-mmacosx-version-min=11.0" VCPKG_CXX_FLAGS="-mmacosx-version-min=11.0" - os: ubuntu-20.04 - arch: x64 submodules_mode: true cibw_archs_linux: x86_64 cibw_before_all: ./prepare-linux.sh + cibw_environment: APNGASM_COMPILE_TARGET=x86_64 - os: ubuntu-20.04 - arch: x86 submodules_mode: true cibw_archs_linux: i686 cibw_before_all: ./prepare-linux.sh + cibw_environment: APNGASM_COMPILE_TARGET=x86 - os: ubuntu-20.04 - arch: arm64 submodules_mode: true cibw_archs_linux: aarch64 cibw_skip: "*-muslinux_* pp*" cibw_before_all: ./prepare-linux.sh + cibw_environment: APNGASM_COMPILE_TARGET=armv8 - os: ubuntu-20.04 - arch: arm64 submodules_mode: true cibw_archs_linux: aarch64 cibw_skip: "*-multilinux_* pp*" cibw_before_all: ./prepare-linux.sh + cibw_environment: APNGASM_COMPILE_TARGET=armv8 - os: ubuntu-20.04 - arch: arm64 submodules_mode: true cibw_archs_linux: aarch64 cibw_skip: "*-muslinux_* *-multilinux_*" cibw_before_all: ./prepare-linux.sh + cibw_environment: APNGASM_COMPILE_TARGET=armv8 - os: ubuntu-20.04 - arch: ppc64le submodules_mode: true cibw_archs_linux: ppc64le cibw_skip: "*-muslinux_*" cibw_before_all: ./prepare-linux.sh + cibw_environment: APNGASM_COMPILE_TARGET=ppc64le - os: ubuntu-20.04 - arch: ppc64le submodules_mode: true cibw_archs_linux: ppc64le cibw_skip: "*-multilinux_*" cibw_before_all: ./prepare-linux.sh + cibw_environment: APNGASM_COMPILE_TARGET=ppc64le - os: ubuntu-20.04 - arch: s390x submodules_mode: true cibw_archs_linux: s390x cibw_skip: "*-muslinux_*" cibw_before_all: ./prepare-linux.sh + cibw_environment: APNGASM_COMPILE_TARGET=s390x - os: ubuntu-20.04 - arch: s390x submodules_mode: true cibw_archs_linux: s390x cibw_skip: "*-multilinux_*" cibw_before_all: ./prepare-linux.sh + cibw_environment: APNGASM_COMPILE_TARGET=s390x steps: - uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index b23bd1d..b6cc75b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ dist/ .py-build-cmake_cache/ fakeroot/ -.vscode/ \ No newline at end of file +.vscode/ +conan_output/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index e9d6ea5..bff910f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,104 +11,28 @@ elseif (APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") endif() -if (WIN32) - set(GET_TARGET_CMD "cmd" "/c" "${CMAKE_SOURCE_DIR}/get-target-win.bat") - set(PREPARE_CMD "cmd" "/c" "${CMAKE_SOURCE_DIR}/prepare-win.bat") -elseif (APPLE) - set(GET_TARGET_CMD "${CMAKE_SOURCE_DIR}/get-target-mac.sh") - set(PREPARE_CMD "${CMAKE_SOURCE_DIR}/prepare-mac.sh") -else() - set(GET_TARGET_CMD "${CMAKE_SOURCE_DIR}/get-target-linux.sh") - set(PREPARE_CMD "${CMAKE_SOURCE_DIR}/prepare-linux.sh") -endif() +find_package(PythonInterp 3 REQUIRED) +set(PREPARE_CMD ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/get-deps.py") + +message(STATUS "Executing get-deps.py") execute_process( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${PREPARE_CMD} + OUTPUT_VARIABLE APNGASM_COMPILE_TARGET ) +message(STATUS "Finished get-deps.py") +message(STATUS "APNGASM_COMPILE_TARGET is ${APNGASM_COMPILE_TARGET}") +set(ZLIB_USE_STATIC_LIBS ON) +set(PNG_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_LIBS ON) if (WIN32) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME ON) - set(STATIC_LIBRARY_SUFFIX ".lib") -else() - set(STATIC_LIBRARY_SUFFIX ".a") -endif() - -if (DEFINED ENV{VCPKG_INSTALLATION_ROOT}) - set(VCPKG_INSTALLATION_ROOT $ENV{VCPKG_INSTALLATION_ROOT}) endif() -if (DEFINED VCPKG_INSTALLATION_ROOT) - if (DEFINED ENV{APNGASM_COMPILE_TARGET}) - set(APNGASM_COMPILE_TARGET $ENV{APNGASM_COMPILE_TARGET}) - elseif (NOT DEFINED APNGASM_COMPILE_TARGET) - execute_process( - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${GET_TARGET_CMD} - OUTPUT_VARIABLE APNGASM_COMPILE_TARGET - ) - if (DEFINED ENV{APNGASM_COMPILE_TARGET}) - set(APNGASM_COMPILE_TARGET $ENV{APNGASM_COMPILE_TARGET}) - endif() - endif() - - if (DEFINED ENV{PLATFORM}) - set(PLATFORM $ENV{PLATFORM}) - elseif (NOT DEFINED PLATFORM) - if (WIN32) - set(PLATFORM windows-static) - elseif (APPLE) - set(PLATFORM osx) - else() - set(PLATFORM linux) - endif() - endif() - - if (WIN32) - set(LIBZ_NAME zlib) - set(LIBPNG_NAME libpng16) - else() - set(LIBZ_NAME libz) - set(LIBPNG_NAME libpng16) - endif() - - set(ZLIB_ROOT ${VCPKG_INSTALLATION_ROOT}/installed) - set(PNG_ROOT ${VCPKG_INSTALLATION_ROOT}/installed) - set(Boost_ROOT ${VCPKG_INSTALLATION_ROOT}/installed) - - set(VCPKG_TARGET_TRIPLET ${APNGASM_COMPILE_TARGET}-${PLATFORM}) - - include_directories(${VCPKG_INSTALLATION_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/include) - set(LIBZ_PATH ${VCPKG_INSTALLATION_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/lib/${LIBZ_NAME}${STATIC_LIBRARY_SUFFIX}) - set(LIBPNG_PATH ${VCPKG_INSTALLATION_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/lib/${LIBPNG_NAME}${STATIC_LIBRARY_SUFFIX}) - - set(CMAKE_TOOLCHAIN_FILE "${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" - CACHE STRING "Vcpkg toolchain file") -else() - if (WIN32) - set(LIBZ_NAME zlibstatic) - set(LIBPNG_NAME libpng16_static) - else() - set(LIBZ_NAME libz) - set(LIBPNG_NAME libpng16) - endif() - - set(ZLIB_ROOT ${CMAKE_SOURCE_DIR}/fakeroot) - set(PNG_ROOT ${CMAKE_SOURCE_DIR}/fakeroot) - set(Boost_ROOT ${CMAKE_SOURCE_DIR}/fakeroot) - - set(LIBZ_PATH ${CMAKE_SOURCE_DIR}/fakeroot/lib/${LIBZ_NAME}${STATIC_LIBRARY_SUFFIX}) - if(NOT EXISTS ${LIBZ_PATH}) - set(LIBZ_PATH ${CMAKE_SOURCE_DIR}/fakeroot/lib64/${LIBZ_NAME}${STATIC_LIBRARY_SUFFIX}) - endif() - - set(LIBPNG_PATH ${CMAKE_SOURCE_DIR}/fakeroot/lib/${LIBPNG_NAME}${STATIC_LIBRARY_SUFFIX}) - if(NOT EXISTS ${LIBPNG_PATH}) - set(LIBPNG_PATH ${CMAKE_SOURCE_DIR}/fakeroot/lib64/${LIBPNG_NAME}${STATIC_LIBRARY_SUFFIX}) - endif() -endif() +include(${CMAKE_SOURCE_DIR}/conan_output/${APNGASM_COMPILE_TARGET}/conan_toolchain.cmake) project(apngasm-python VERSION 1.0.6) set(PY_VERSION_SUFFIX "") @@ -135,22 +59,14 @@ target_compile_definitions(_apngasm_python PRIVATE _apngasm_python_EXPORTS) target_compile_definitions(_apngasm_python PRIVATE apngasm_EXPORTS) # Static linking -add_library(zlibstatic STATIC IMPORTED) -add_library(png_static STATIC IMPORTED) - add_subdirectory(apngasm) set_target_properties(apngasm-static PROPERTIES BUILD_SHARED_LIBS OFF) -include_directories(${CMAKE_SOURCE_DIR}/fakeroot/include) include_directories(${CMAKE_BINARY_DIR}/apngasm/lib/src) include_directories(${CMAKE_SOURCE_DIR}/apngasm/lib/src) include_directories(${CMAKE_SOURCE_DIR}/apngasm/lib/src/listener) -set_target_properties(zlibstatic PROPERTIES IMPORTED_LOCATION ${LIBZ_PATH}) -set_target_properties(png_static PROPERTIES IMPORTED_LOCATION ${LIBPNG_PATH}) - -target_link_libraries(_apngasm_python PRIVATE apngasm-static png_static zlibstatic) - +target_link_libraries(_apngasm_python PRIVATE apngasm-static) target_compile_definitions(_apngasm_python PRIVATE MODULE_NAME=$ VERSION_INFO="${PY_FULL_VERSION}" diff --git a/CMakeUserPresets.json b/CMakeUserPresets.json new file mode 100644 index 0000000..c490aef --- /dev/null +++ b/CMakeUserPresets.json @@ -0,0 +1,9 @@ +{ + "version": 4, + "vendor": { + "conan": {} + }, + "include": [ + "/mnt/Library-SSD/Codes/apngasm-python/conan_output/x86_64/CMakePresets.json" + ] +} \ No newline at end of file diff --git a/apngasm b/apngasm index bd6879d..3f1c587 160000 --- a/apngasm +++ b/apngasm @@ -1 +1 @@ -Subproject commit bd6879d06addc8b8bdabe30a343f5ab022dcbd1a +Subproject commit 3f1c587649a5e02536b520afbf3817ae1c1c766c diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..bb8a05c --- /dev/null +++ b/conanfile.py @@ -0,0 +1,19 @@ +from conan import ConanFile +import shutil +import platform + +class ApngasmRecipe(ConanFile): + settings = 'os', 'compiler', 'build_type', 'arch' + + def requirements(self): + self.requires("zlib/1.2.13") + self.requires("libpng/1.6.40") + self.requires("boost/1.83.0") + self.generators = ['CMakeToolchain', 'CMakeDeps'] + + def build_requirements(self): + if not shutil.which('cmake'): + self.tool_requires("cmake/[>=3.5]") + + def build(self): + build_type = 'Release' \ No newline at end of file diff --git a/get-deps.py b/get-deps.py new file mode 100644 index 0000000..5103b80 --- /dev/null +++ b/get-deps.py @@ -0,0 +1,104 @@ +import platform +import os +import sys +import subprocess +import platform + +conan_archs = { + 'x86_64': ['amd64', 'x86_64', 'x64'], + 'x86': ['i386', 'i686', 'x86'], + 'armv8': ['arm64', 'aarch64', 'aarch64_be', 'armv8b', 'armv8l'], + 'ppc64le': ['ppc64le', 'powerpc'], + 's390x': ['s390', 's390x'] +} + +def install_deps(arch=None): + # Use Conan to install dependencies + + settings = [] + + if platform.system() == 'Windows': + settings.append('os=Windows') + elif platform.system() == 'Darwin': + settings.append('os=Macos') + settings.append('compiler=apple-clang') + settings.append('compiler.version=11.0') + settings.append('compiler.libcxx=libc++') + elif platform.system() == 'Linux': + settings.append('os=Linux') + + if arch: + settings.append(f'arch={arch}') + + build = [] + if os.path.isdir('/lib') and len([i for i in os.listdir('/lib') if i.startswith('libc.musl')]) != 0: + # Need to compile dependencies if musllinux + build.append('zlib*') + build.append('libpng*') + build.append('boost*') + if not platform.machine().lower() in conan_archs['armv8'] + conan_archs['x86_64']: + build.append('cmake*') + if build == []: + build.append('missing') + + subprocess.run(['conan', 'profile', 'detect'], + stdout = subprocess.DEVNULL, + stderr = subprocess.DEVNULL) + + conan_output = os.path.join('conan_output', arch) + + subprocess.run([ + 'conan', 'install', + *[x for s in settings for x in ('-s', s)], + *[x for b in build for x in ('-b', b)], + '-of', conan_output, '--deployer=full_deploy', '.' + ], + stdout = subprocess.DEVNULL, + stderr = subprocess.DEVNULL) + + return conan_output + +arch = None +if os.getenv('APNGASM_COMPILE_TARGET') == 'universal2': + arch = 'armv8' +elif os.getenv('APNGASM_COMPILE_TARGET'): + arch = os.getenv('APNGASM_COMPILE_TARGET') +else: + for k, v in conan_archs.items(): + if platform.machine().lower() in v: + arch = k + break + +if arch == None: + arch = platform.machine().lower() + +conan_output = install_deps(arch) +if os.getenv('APNGASM_COMPILE_TARGET') == 'universal2': + # Repeat to install the other architecture version of libwebp + conan_output_x64 = install_deps('x86_64') + conan_output_universal2 = 'conan_output/universal2' + os.makedirs(conan_output_universal2, exist_ok=True) + subprocess.run([ + 'python3', 'lipo-dir-merge/lipo-dir-merge.py', + conan_output, conan_output_x64, conan_output_universal2 + ], + stdout = subprocess.DEVNULL, + stderr = subprocess.DEVNULL) + + with open(os.path.join(conan_output_universal2, 'CMakePresets.json')) as f: + cmake_presets = f.read() + cmake_presets = cmake_presets.replace('armv8', 'universal2') + with open(os.path.join(conan_output_universal2, 'CMakePresets.json'), 'w+') as f: + f.write(cmake_presets) + + with open(os.path.join(conan_output_universal2, 'conan_toolchain.cmake')) as f: + conan_toolchain = f.read() + conan_toolchain = conan_toolchain.replace('armv8', 'universal2') + with open(os.path.join(conan_output_universal2, 'conan_toolchain.cmake'), 'w+') as f: + f.write(conan_toolchain) + + +if os.getenv('APNGASM_COMPILE_TARGET'): + sys.stdout.write(os.getenv('APNGASM_COMPILE_TARGET')) +else: + sys.stdout.write(arch) \ No newline at end of file diff --git a/get-target-linux.sh b/get-target-linux.sh deleted file mode 100755 index db80051..0000000 --- a/get-target-linux.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -if [[ -z $APNGASM_COMPILE_TARGET ]]; then - arch=$(uname --machine) - if [[ $arch == x86_64* ]]; then - APNGASM_COMPILE_TARGET=x64 - elif [[ $arch == i*86 ]]; then - APNGASM_COMPILE_TARGET=x86 - elif [[ $arch == aarch64 ]]; then - APNGASM_COMPILE_TARGET=arm64 - elif [[ $arch == '' ]]; then - APNGASM_COMPILE_TARGET=x64 - else - APNGASM_COMPILE_TARGET=$arch - fi -fi - -export APNGASM_COMPILE_TARGET=$APNGASM_COMPILE_TARGET - -printf '%s' $APNGASM_COMPILE_TARGET \ No newline at end of file diff --git a/get-target-mac.sh b/get-target-mac.sh deleted file mode 100755 index 4748b85..0000000 --- a/get-target-mac.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -if [[ -z $APNGASM_COMPILE_TARGET ]]; then - arch=$(uname -m) - if [[ $arch == x86_64* ]]; then - APNGASM_COMPILE_TARGET=x64 - elif [[ $arch == i*86 ]]; then - APNGASM_COMPILE_TARGET=x86 - elif [[ $arch == arm64 ]]; then - APNGASM_COMPILE_TARGET=arm64 - elif [[ $arch == '' ]]; then - APNGASM_COMPILE_TARGET=x64 - else - APNGASM_COMPILE_TARGET=$arch - fi -fi - -export APNGASM_COMPILE_TARGET=$APNGASM_COMPILE_TARGET - -printf '%s' $APNGASM_COMPILE_TARGET \ No newline at end of file diff --git a/get-target-win.bat b/get-target-win.bat deleted file mode 100644 index 142e4eb..0000000 --- a/get-target-win.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off - -if not defined APNGASM_COMPILE_TARGET ( - if %PROCESSOR_ARCHITECTURE%=="AMD64" ( - set APNGASM_COMPILE_TARGET=x64 - ) else if %PROCESSOR_ARCHITECTURE%=="X86" ( - set APNGASM_COMPILE_TARGET=x86 - ) else if %PROCESSOR_ARCHITECTURE%=="ARM64" ( - set APNGASM_COMPILE_TARGET=arm64 - ) else if %PROCESSOR_ARCHITECTURE%=="ARM" ( - set APNGASM_COMPILE_TARGET=arm - ) else if %PROCESSOR_ARCHITECTURE%=="" ( - set APNGASM_COMPILE_TARGET=x64 - ) else ( - set APNGASM_COMPILE_TARGET=%PROCESSOR_ARCHITECTURE% - ) -) \ No newline at end of file diff --git a/prepare-linux.sh b/prepare-linux.sh deleted file mode 100755 index bc1696b..0000000 --- a/prepare-linux.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -SOURCE_PATH=$PWD -FAKEROOT=${SOURCE_PATH}/fakeroot -mkdir ${FAKEROOT} - -CORES=$(nproc --all) -if [[ $? -ne 0 ]]; then - CORES=2 -fi - -# Cross compiling supported only through vcpkg -if [[ ! -z $VCPKG_INSTALLATION_ROOT ]]; then - export APNGASM_COMPILE_TARGET=$(./get-target-linux.sh) - - ${VCPKG_INSTALLATION_ROOT}/vcpkg install zlib:${APNGASM_COMPILE_TARGET}-linux - ${VCPKG_INSTALLATION_ROOT}/vcpkg install libpng:${APNGASM_COMPILE_TARGET}-linux - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-program-options:${APNGASM_COMPILE_TARGET}-linux - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-regex:${APNGASM_COMPILE_TARGET}-linux - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-system:${APNGASM_COMPILE_TARGET}-linux - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-algorithm:${APNGASM_COMPILE_TARGET}-linux - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-property-tree:${APNGASM_COMPILE_TARGET}-linux - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-foreach:${APNGASM_COMPILE_TARGET}-linux -else - if [ ! -f ${FAKEROOT}/include/zlib.h ]; then - cd ${SOURCE_PATH} - git clone https://github.com/madler/zlib.git - cd ${SOURCE_PATH}/zlib - git checkout v1.2.13 - mkdir build - cd ./build - cmake -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -O3 -fPIC" -DCMAKE_INSTALL_PREFIX:PATH=${FAKEROOT} .. - make install -j - fi - - if [ ! -f ${FAKEROOT}/include/png.h ]; then - cd ${SOURCE_PATH} - git clone https://github.com/glennrp/libpng.git - cd ${SOURCE_PATH}/libpng - git checkout v1.6.40 - mkdir build - cd ./build - cmake -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -O3 -fPIC" -DCMAKE_POLICY_DEFAULT_CMP0074=NEW -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=${FAKEROOT} -DPNG_SHARED=OFF -DZLIB_ROOT=${FAKEROOT} -DZLIB_USE_STATIC_LIBS=ON .. - make install -j - fi - - if [ ! -d ${FAKEROOT}/include/boost ]; then - cd ${SOURCE_PATH} - git clone --recursive https://github.com/boostorg/boost.git - cd ${SOURCE_PATH}/boost - git checkout boost-1.83.0 - ./bootstrap.sh - ./b2 install link=static --cxxflags="-fPIC" --cflags="-fPIC" --build-dir=tmp --prefix=${FAKEROOT} --with-program_options --with-regex --with-system -j${CORES} --layout=tagged - fi -fi \ No newline at end of file diff --git a/prepare-mac.sh b/prepare-mac.sh deleted file mode 100755 index 07d74ba..0000000 --- a/prepare-mac.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh - -SOURCE_PATH=$PWD -FAKEROOT=${SOURCE_PATH}/fakeroot -mkdir ${FAKEROOT} - -CORES=$(sysctl -n hw.logicalcpu) -if [[ $? -ne 0 ]]; then - CORES=2 -fi - -function vcpkg_install() { - ${VCPKG_INSTALLATION_ROOT}/vcpkg install zlib:$1-osx - ${VCPKG_INSTALLATION_ROOT}/vcpkg install libpng:$1-osx - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-program-options:$1-osx - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-regex:$1-osx - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-system:$1-osx - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-algorithm:$1-osx - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-property-tree:$1-osx - ${VCPKG_INSTALLATION_ROOT}/vcpkg install boost-foreach:$1-osx -} - -# Cross compiling supported only through vcpkg -if [[ ! -z $VCPKG_INSTALLATION_ROOT ]]; then - export VCPKG_OSX_DEPLOYMENT_TARGET=10.15 - export VCPKG_C_FLAGS="-mmacosx-version-min=10.15" - export VCPKG_CXX_FLAGS="-mmacosx-version-min=10.15" - export APNGASM_COMPILE_TARGET=$(./get-target-mac.sh) - - if [[ $APNGASM_COMPILE_TARGET != 'universal2' ]]; then - vcpkg_install ${APNGASM_COMPILE_TARGET} - else - vcpkg_install x64 - vcpkg_install arm64 - python3 ./lipo-dir-merge/lipo-dir-merge.py \ - ${VCPKG_INSTALLATION_ROOT}/installed/arm64-osx \ - ${VCPKG_INSTALLATION_ROOT}/installed/x64-osx \ - ${VCPKG_INSTALLATION_ROOT}/installed/universal2-osx - fi -else - which -s brew - if [[ $? != 0 ]] ; then - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - fi - - which -s cmake - if [[ $? != 0 ]] ; then - brew install cmake - fi - - if [ ! -d /usr/local/opt/icu4c/include ]; then - brew install icu4c - fi - - if [ ! -f ${FAKEROOT}/include/zlib.h ]; then - cd ${SOURCE_PATH} - git clone https://github.com/madler/zlib.git - cd ${SOURCE_PATH}/zlib - git checkout v1.2.13 - mkdir build - cd ./build - cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_INSTALL_PREFIX:PATH=${FAKEROOT} .. - make install -j - fi - - if [ ! -f ${FAKEROOT}/include/png.h ]; then - cd ${SOURCE_PATH} - git clone https://github.com/glennrp/libpng.git - cd ${SOURCE_PATH}/libpng - git checkout v1.6.40 - mkdir build - cd ./build - cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_POLICY_DEFAULT_CMP0074=NEW -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=${FAKEROOT} -DPNG_SHARED=OFF -DZLIB_ROOT=${FAKEROOT} -DZLIB_USE_STATIC_LIBS=ON .. - make install -j - fi - - if [ ! -d ${FAKEROOT}/include/boost ]; then - cd ${SOURCE_PATH} - git clone --recursive https://github.com/boostorg/boost.git - cd ${SOURCE_PATH}/boost - git checkout boost-1.83.0 - ./bootstrap.sh --prefix=. - ./b2 install link=static macosx-version-min=10.15 --build-dir=tmp --prefix=${FAKEROOT} --with-program_options --with-regex --with-system -j${CORES} --layout=tagged - fi -fi \ No newline at end of file diff --git a/prepare-win.bat b/prepare-win.bat deleted file mode 100755 index ea2d592..0000000 --- a/prepare-win.bat +++ /dev/null @@ -1,60 +0,0 @@ -@echo off - -set SOURCE_PATH=%cd% -set FAKEROOT=%SOURCE_PATH%\fakeroot -mkdir %FAKEROOT% - -if defined NUMBER_OF_PROCESSORS ( - set CORES=%NUMBER_OF_PROCESSORS% -) else ( - set CORES=4 -) - -:: Cross compiling supported only through vcpkg -if defined VCPKG_INSTALLATION_ROOT ( - call get-target-win.bat - - %VCPKG_INSTALLATION_ROOT%\vcpkg.exe install zlib:%APNGASM_COMPILE_TARGET%-windows-static - %VCPKG_INSTALLATION_ROOT%\vcpkg.exe install libpng:%APNGASM_COMPILE_TARGET%-windows-static - %VCPKG_INSTALLATION_ROOT%\vcpkg.exe install boost-program-options:%APNGASM_COMPILE_TARGET%-windows-static - %VCPKG_INSTALLATION_ROOT%\vcpkg.exe install boost-regex:%APNGASM_COMPILE_TARGET%-windows-static - %VCPKG_INSTALLATION_ROOT%\vcpkg.exe install boost-system:%APNGASM_COMPILE_TARGET%-windows-static - %VCPKG_INSTALLATION_ROOT%\vcpkg.exe install boost-algorithm:%APNGASM_COMPILE_TARGET%-windows-static - %VCPKG_INSTALLATION_ROOT%\vcpkg.exe install boost-property-tree:%APNGASM_COMPILE_TARGET%-windows-static - %VCPKG_INSTALLATION_ROOT%\vcpkg.exe install boost-foreach:%APNGASM_COMPILE_TARGET%-windows-static - -) else ( - if not exist %FAKEROOT%\include\zlib.h ( - cd %SOURCE_PATH% - git clone https://github.com/madler/zlib.git - cd %SOURCE_PATH%/zlib - git checkout v1.2.13 - mkdir build - cd build - cmake -DCMAKE_C_FLAGS_RELEASE="/MT /MP" -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=%FAKEROOT% .. - cmake --build . --target INSTALL --config Release - ) - - if not exist %FAKEROOT%\include\png.h ( - cd %SOURCE_PATH% - git clone https://github.com/glennrp/libpng.git - cd %SOURCE_PATH%/libpng - git checkout v1.6.40 - mkdir build - cd build - cmake -DCMAKE_C_FLAGS_RELEASE="/MT /MP" -DBUILD_SHARED_LIBS=OFF -DCMAKE_POLICY_DEFAULT_CMP0074=NEW -DCMAKE_INSTALL_PREFIX:PATH=%FAKEROOT% -DZLIB_ROOT=%FAKEROOT% -DZLIB_USE_STATIC_LIBS=ON -DPNG_SHARED=OFF .. - cmake --build . --target INSTALL --config Release - ) - - if not exist %FAKEROOT%\include\boost ( - cd %SOURCE_PATH% - git clone --recursive https://github.com/boostorg/boost.git - cd %SOURCE_PATH%/boost - git checkout boost-1.83.0 - call bootstrap.bat - b2.exe install link=static runtime-link=static threading=multi --prefix=%FAKEROOT% --build-dir=tmp --with-program_options --with-regex --with-system -j%CORES% msvc stage - robocopy %FAKEROOT%\include\boost-1_82\boost %FAKEROOT%\include\boost /E - ) -) - -exit 0 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 26446e7..2b9eaf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,13 @@ Documentation = "https://apngasm-python.readthedocs.io/en/latest/" Tracker = "https://github.com/laggykiller/apngasm-python/issues" [build-system] # How pip and other frontends should build this project -requires = ["py-build-cmake==0.2.0a7", "nanobind>=1.5.2", "nanobind-stubgen"] +requires = [ + "py-build-cmake==0.2.0a7", + "nanobind>=1.5.2", + "nanobind-stubgen", + "conan>=2.0", + "wheel" +] build-backend = "py_build_cmake.build" [tool.py-build-cmake.module] # Where to find the Python module to package @@ -24,7 +30,15 @@ name = "apngasm_python" directory = "src-python" [tool.py-build-cmake.sdist] # What to include in source distributions -include = ["CMakeLists.txt", "cmake/*.cmake", "src/*", "src-python/*", "*.bat", "*.sh", "apngasm/*"] +include = [ + "CMakeLists.txt", + "cmake/*.cmake", + "src/*", + "src-python/*", + "get-deps.py", + "conanfile.py", + "apngasm/*" +] [tool.py-build-cmake.cmake] # How to build the CMake project build_type = "Release" @@ -37,7 +51,4 @@ install_components = ["python_module"] [tool.cibuildwheel] build-verbosity = 1 -environment = { PY_BUILD_CMAKE_VERBOSE="1" } - -[tool.py-build-cmake.mac.cmake] # macOS-specific options -env = { "LDFLAGS" = "-L/usr/local/opt/icu4c/lib", "CPPFLAGS" = "-I/usr/local/opt/icu4c/include" } # Required for brew installed icu4c \ No newline at end of file +environment = { PY_BUILD_CMAKE_VERBOSE="1" } \ No newline at end of file