diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f62dc1607..eb050caab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,19 +21,15 @@ jobs: include: - os: ubuntu-22.04 package_manager: "apt" - test: "ON" - os: ubuntu-24.04 package_manager: "apt" - test: "ON" - os: macos-14 package_manager: "brew" - test: "OFF" - os: windows-2022 package_manager: "vcpkg" - test: "OFF" steps: - name: Checkout Pangolin @@ -80,13 +76,28 @@ jobs: echo "CMake toolchain file: $TOOLCHAIN_FILE" $GITHUB_WORKSPACE/scripts/install_prerequisites.sh -v -u -m ${{matrix.package_manager}} all + - name: "(vcpkg only) remove python" + if: ${{ matrix.package_manager == 'vcpkg' }} + run: | + vcpkg remove python3 + + - uses: actions/setup-python@v5 + if: ${{ matrix.package_manager == 'vcpkg' }} + with: + python-version: '3.12' + + - name: "(vcpkg only) install setuptools" + if: ${{ matrix.package_manager == 'vcpkg' }} + run: | + pip install setuptools + - name: Configure CMake run: > cmake -G Ninja -B build -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D CMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" -D BUILD_SHARED_LIBS=${{ matrix.shared_libs }} - -D BUILD_TESTS=${{ matrix.test }} + -D BUILD_TESTS=ON - name: Build run: cmake --build build --config $BUILD_TYPE @@ -95,16 +106,19 @@ jobs: run: cmake --build build -t pypangolin_wheel - name: Install Python wheel - if: ${{ matrix.package_manager == 'apt' }} env: PIP_BREAK_SYSTEM_PACKAGES: 1 run: | + python -m zipfile --list build/pypangolin-*.whl pip install build/pypangolin-*.whl pip show pypangolin + + - name: Test Python wheel + if: ${{ !(matrix.package_manager == 'vcpkg' && matrix.shared_libs == 'ON') }} + run: | python -c "import pypangolin" - name: Run all tests - if: ${{ matrix.test == 'ON' }} run: | cmake --build build --target test @@ -121,7 +135,7 @@ jobs: sudo apt install -y emscripten ninja-build libeigen3-dev catch2 - name: Configure Pangolin - run: emcmake cmake -G Ninja -B pangolin-build -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D Eigen3_DIR=/usr/share/eigen3/cmake/ + run: emcmake cmake -G Ninja -B pangolin-build -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D BUILD_PANGOLIN_PYTHON=OFF -D Eigen3_DIR=/usr/share/eigen3/cmake/ - name: Build Pangolin run: cmake --build pangolin-build diff --git a/CMakeLists.txt b/CMakeLists.txt index 9dadf93e1..c91d2fa74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project("Pangolin") set(PANGOLIN_VERSION_MAJOR 0) diff --git a/cmake/MakePythonWheel.cmake b/cmake/MakePythonWheel.cmake index 8f6bcfdf0..200ba1e15 100644 --- a/cmake/MakePythonWheel.cmake +++ b/cmake/MakePythonWheel.cmake @@ -10,7 +10,24 @@ function( MakeWheel python_module) set(version ${MAKEWHEEL_VERSION}) execute_process( - COMMAND ${Python_EXECUTABLE} -c " + COMMAND ${Python3_EXECUTABLE} -c " +import sys +try: + import setuptools + sys.exit(0) +except ImportError as e: + print(f'{e}. Search paths:', file=sys.stderr) + for p in sys.path: print(f' {p}', file=sys.stderr) + sys.exit(1) +" + RESULT_VARIABLE has_setuptools) + + if(has_setuptools EQUAL "1") + message(FATAL_ERROR "Python module `setuptools` required for correct wheel filename generation.") + endif() + + execute_process( + COMMAND ${Python3_EXECUTABLE} -c " from setuptools.dist import Distribution from setuptools import Extension @@ -23,24 +40,16 @@ def wheel_name(**kwargs): # assemble wheel file name distname = bdist_wheel_cmd.wheel_dist_name tag = '-'.join(bdist_wheel_cmd.get_tag()) - return f'{distname};{tag}' + return f'{distname}-{tag}' -print(wheel_name(name='${python_module}', version='${version}', ext_modules=[Extension('dummy', ['summy.c'])])) +print(wheel_name(name='${python_module}', version='${version}', ext_modules=[Extension('dummy', ['dummy.c'])])) " OUTPUT_VARIABLE wheel_filename OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) - if(NOT wheel_filename) - message(STATUS "Python module `setuptools` required for correct wheel filename generation. Please install if needed.") - set(wheel_filename "unknown;unknown") - endif() - - list(GET wheel_filename 0 distname) - list(GET wheel_filename 1 platformtag) - set(complete_tag "${distname}-${platformtag}") - set(wheel_filename "${CMAKE_BINARY_DIR}/${complete_tag}.whl") + set(wheel_filename "${CMAKE_BINARY_DIR}/${wheel_filename}.whl") set(wheel_distinfo "${CMAKE_BINARY_DIR}/${python_module}-${version}.dist-info") set(wheel_data "${CMAKE_BINARY_DIR}/${python_module}-${version}.data") set(wheel_generator_string "pango_wheelgen_${version}") diff --git a/components/pango_python/CMakeLists.txt b/components/pango_python/CMakeLists.txt index 945ae3c86..0eb6bc419 100644 --- a/components/pango_python/CMakeLists.txt +++ b/components/pango_python/CMakeLists.txt @@ -3,10 +3,13 @@ get_filename_component(COMPONENT ${CMAKE_CURRENT_LIST_DIR} NAME) option(BUILD_PANGOLIN_PYTHON "Build support for Pangolin Interactive Console" ON) if(BUILD_PANGOLIN_PYTHON) - find_package(Python COMPONENTS Interpreter Development QUIET) + if(POLICY CMP0148) + cmake_policy(SET CMP0148 NEW) + endif() + find_package(Python3 COMPONENTS Interpreter Development REQUIRED) endif() -if(BUILD_PANGOLIN_PYTHON AND Python_FOUND) +if(BUILD_PANGOLIN_PYTHON AND Python3_FOUND) # If we've inited the submodule, use that if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/pybind11/CMakeLists.txt") add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/pybind11) @@ -15,7 +18,7 @@ if(BUILD_PANGOLIN_PYTHON AND Python_FOUND) endif() endif() -if(BUILD_PANGOLIN_PYTHON AND Python_FOUND AND pybind11_FOUND) +if(BUILD_PANGOLIN_PYTHON AND Python3_FOUND AND pybind11_FOUND) set(SRC_BINDINGS ${CMAKE_CURRENT_LIST_DIR}/src/pypangolin/attach.cpp ${CMAKE_CURRENT_LIST_DIR}/src/pypangolin/colour.cpp diff --git a/components/pango_python/pybind11 b/components/pango_python/pybind11 index 3e9dfa286..a2e59f0e7 160000 --- a/components/pango_python/pybind11 +++ b/components/pango_python/pybind11 @@ -1 +1 @@ -Subproject commit 3e9dfa2866941655c56877882565e7577de6fc7b +Subproject commit a2e59f0e7065404b44dfe92a28aca47ba1378dc4 diff --git a/scripts/install_prerequisites.sh b/scripts/install_prerequisites.sh index 07c336c73..a0547afb1 100755 --- a/scripts/install_prerequisites.sh +++ b/scripts/install_prerequisites.sh @@ -159,7 +159,7 @@ elif [[ "$MANAGER" == "brew" ]]; then PKGS_OPTIONS+=(install) if ((VERBOSE > 0)); then PKGS_OPTIONS+=(--verbose); fi PKGS_REQUIRED+=(glew eigen cmake ninja) - PKGS_RECOMMENDED+=(libjpeg-turbo libpng openexr libtiff ffmpeg lz4 zstd catch2) + PKGS_RECOMMENDED+=(libjpeg-turbo libpng openexr libtiff ffmpeg lz4 zstd catch2 python-setuptools) # Brew doesn't have a dryrun option if ((DRYRUN > 0)); then MANAGER="echo $MANAGER"