From f3572035428c2e5f023db82b08e98fa15cb8319c Mon Sep 17 00:00:00 2001 From: Arnaud TANGUY Date: Wed, 12 Nov 2025 20:29:14 +0100 Subject: [PATCH 1/2] build(noble): Upgrade to pyproject.toml to replace deprecated use of pkg_resources --- CMakeLists.txt | 2 +- pyproject.toml | 23 +++++++++++++ setup.in.py | 88 ++++++++++++++++++++++++++------------------------ 3 files changed, 69 insertions(+), 44 deletions(-) create mode 100644 pyproject.toml diff --git a/CMakeLists.txt b/CMakeLists.txt index d6f711b..80cd02c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,7 @@ macro(ADD_BINDINGS PYTHON PYTHON_EXECUTABLE SOURCES) endif() endif() add_custom_target(install-${TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON_EXECUTABLE} -m pip install . ${PIP_EXTRA_OPTIONS} --upgrade + COMMAND ${CMAKE_COMMAND} -E chdir "${SETUP_LOCATION}" ${PYTHON_EXECUTABLE} -m pip install . --upgrade ${PIP_EXTRA_OPTIONS} COMMENT "Install Eigen ${PYTHON} bindings" ) endif() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e9f5147 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ +[build-system] +requires = ["setuptools>=61,<=68.1.2", "wheel", "Cython"] +build-backend = "setuptools.build_meta" + +[project] +name = "eigen" +version = "1.0.0" +description = "Eigen3 Python bindings" +authors = [ + { name = "CNRS-UM LIRMM, CNRS-AIST JRL" } +] +dependencies = [ + "Cython>=0.2", + "coverage", + "numpy>=1.8.2", + "pytest" +] + +[tool.setuptools] +packages = ["eigen"] + +[tool.setuptools.package-data] +eigen = ["__init__.py", "c_eigen.pxd", "eigen.pxd"] diff --git a/setup.in.py b/setup.in.py index 52a1384..6107d46 100644 --- a/setup.in.py +++ b/setup.in.py @@ -4,77 +4,79 @@ from __future__ import print_function - -import pkg_resources -requirements_file = "@CMAKE_CURRENT_SOURCE_DIR@/requirements.txt" -with open(requirements_file) as fd: - for pkg in fd: - pkg = pkg.strip() - pkg_resources.require(pkg) +# Project metadata and dependencies are managed in pyproject.toml try: - from setuptools import setup - from setuptools import Extension + from setuptools import setup + from setuptools import Extension except ImportError: - from distutils.core import setup - from distutils.extension import Extension + from distutils.core import setup + from distutils.extension import Extension import sysconfig from Cython.Build import cythonize import numpy import os -import subprocess import sys win32_build = os.name == 'nt' from utils import generate_eigen_pyx -this_path = os.path.dirname(os.path.realpath(__file__)) -src_files = ['eigen/c_eigen.pxd', 'eigen/c_eigen_private.pxd', 'include/eigen_wrapper.hpp'] -src_files.extend(['utils/angleaxis.in.pyx', 'utils/generate_eigen_pyx.py', 'utils/quaternion.in.pyx']) -src_files = [ '{}/{}'.format(this_path, f) for f in src_files ] +this_path = os.path.dirname(os.path.realpath(__file__)) +src_files = [ + 'eigen/c_eigen.pxd', + 'eigen/c_eigen_private.pxd', + 'include/eigen_wrapper.hpp', + 'utils/angleaxis.in.pyx', + 'utils/generate_eigen_pyx.py', + 'utils/quaternion.in.pyx' +] +src_files = [f"{this_path}/{f}" for f in src_files] -generate_eigen_pyx(this_path + "/eigen", this_path + "/utils") +generate_eigen_pyx(f"{this_path}/eigen", f"{this_path}/utils") def GenExtension(name): - pyx_src = name.replace('.', '/') - cpp_src = pyx_src + '.cpp' - pyx_src = pyx_src + '.pyx' - ext_src = pyx_src - include_dirs = [os.path.join(os.getcwd(), "include"), "@EIGEN3_INCLUDE_DIR@", numpy.get_include()] - compile_args = ['-std=c++11'] - if win32_build: - compile_args = ['-DWIN32'] - elif sys.platform == 'darwin': - from platform import machine - osx_arch = machine() - os.environ["ARCHFLAGS"] = "-arch " + osx_arch - compile_args += ["-arch", osx_arch] - - return Extension(name, [ext_src], extra_compile_args = compile_args, include_dirs = include_dirs) + pyx_src = name.replace('.', '/') + '.pyx' + include_dirs = [os.path.join(os.getcwd(), "include"), "@EIGEN3_INCLUDE_DIR@", numpy.get_include()] + compile_args = ['-std=c++11'] + if win32_build: + compile_args = ['-DWIN32'] + elif sys.platform == 'darwin': + from platform import machine + osx_arch = machine() + os.environ["ARCHFLAGS"] = "-arch " + osx_arch + compile_args += ["-arch", osx_arch] + + return Extension(name, [pyx_src], extra_compile_args=compile_args, include_dirs=include_dirs) extensions = [ - GenExtension('eigen.eigen') + GenExtension('eigen.eigen') ] packages = ['eigen'] data = ['__init__.py', 'c_eigen.pxd', 'eigen.pxd'] -cython_c_compiler_launcher="@CYTHON_C_COMPILER_LAUNCHER@" +cython_c_compiler_launcher = "@CYTHON_C_COMPILER_LAUNCHER@" if cython_c_compiler_launcher: - sysconfig.get_config_vars()["CC"] = cython_c_compiler_launcher + " " + sysconfig.get_config_vars()["BINDIR"] + "/" + sysconfig.get_config_vars()["CC"] -cython_cxx_compiler_launcher="@CYTHON_CXX_COMPILER_LAUNCHER@" + sysconfig.get_config_vars()["CC"] = ( + cython_c_compiler_launcher + " " + + sysconfig.get_config_vars()["BINDIR"] + "/" + + sysconfig.get_config_vars()["CC"] + ) +cython_cxx_compiler_launcher = "@CYTHON_CXX_COMPILER_LAUNCHER@" if cython_cxx_compiler_launcher: - sysconfig.get_config_vars()["CXX"] = cython_cxx_compiler_launcher + " " + sysconfig.get_config_vars()["BINDIR"] + "/" + sysconfig.get_config_vars()["CXX"] + sysconfig.get_config_vars()["CXX"] = ( + cython_cxx_compiler_launcher + " " + + sysconfig.get_config_vars()["BINDIR"] + "/" + + sysconfig.get_config_vars()["CXX"] + ) -extensions = cythonize(extensions, cache = True) +extensions = cythonize(extensions, cache=True) setup( - name = 'eigen', - version='@PROJECT_VERSION@', - ext_modules = extensions, - package_data = { 'eigen': data }, - packages = packages + ext_modules=extensions, + package_data={'eigen': data}, + packages=packages ) From 181d3cfe298a7ef1a20b1436da7281e22dd3a8c0 Mon Sep 17 00:00:00 2001 From: Arnaud TANGUY Date: Wed, 12 Nov 2025 20:42:04 +0100 Subject: [PATCH 2/2] ci: drop support for ubuntu 20.04, macos-latest --- .github/workflows/build.yml | 8 +------- .github/workflows/package.yml | 8 ++------ .gitignore | 1 + 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed11ec7..3c9733e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-latest] + os: [ubuntu-22.04, ubuntu-24.04] build-type: [Debug, RelWithDebInfo] exclude: # No Debug build in Windows @@ -25,12 +25,6 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - name: Install pip for Python 2 (Ubuntu 20.04) - run: | - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py - sudo python2 get-pip.py - rm -f get-pip.py - if: matrix.os == 'ubuntu-20.04' - name: Install dependencies uses: jrl-umi3218/github-actions/install-dependencies@master with: diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 9d466fd..3949a5d 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -23,12 +23,8 @@ jobs: deps: '["jrl-umi3218/SpaceVecAlg"]' matrix: | { - "dist": ["bionic", "focal", "jammy", "noble"], - "arch": ["amd64"], - "include": - [ - {"dist": "bionic", "arch": "i386" } - ] + "dist": ["jammy", "noble"], + "arch": ["amd64"] } secrets: CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} diff --git a/.gitignore b/.gitignore index 55b8131..23d06c2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ eigen/eigen.pxd *.pyc *.cpp setup.py +build