Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix wheel name #956

Merged
merged 13 commits into from
Oct 19, 2024
Merged
30 changes: 22 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.16)

project("Pangolin")
set(PANGOLIN_VERSION_MAJOR 0)
Expand Down
33 changes: 21 additions & 12 deletions cmake/MakePythonWheel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}")
Expand Down
9 changes: 6 additions & 3 deletions components/pango_python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/pango_python/pybind11
Submodule pybind11 updated 178 files
2 changes: 1 addition & 1 deletion scripts/install_prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading