From 710ff781c7856988e1070329d5b8faa3ae4450c8 Mon Sep 17 00:00:00 2001 From: Arnaud TANGUY Date: Mon, 17 Feb 2025 11:33:44 +0000 Subject: [PATCH 1/5] [macos] Handle M1 arch arm64 --- setup.in.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/setup.in.py b/setup.in.py index 33abc7f..21301a7 100644 --- a/setup.in.py +++ b/setup.in.py @@ -28,6 +28,7 @@ win32_build = os.name == 'nt' + from utils import generate_eigen_pyx this_path = os.path.dirname(os.path.realpath(__file__)) @@ -46,6 +47,13 @@ def GenExtension(name): compile_args = ['-std=c++11'] if win32_build: compile_args = ['-DWIN32'] + elif sys.platform == 'darwin': + from platform import machine + osx_arch = machine() + print(f"OSX framework used, force to {osx_arch} only") + os.environ["ARCHFLAGS"] = os.environ.get("ARCHFLAGS", f"-arch {osx_arch}") + compile_args = ['-arch', osx_arch] + return Extension(name, [ext_src], extra_compile_args = compile_args, include_dirs = include_dirs) extensions = [ From 76a2651a0d02dbbf5425a028a5b63c6f0f548681 Mon Sep 17 00:00:00 2001 From: Arnaud TANGUY Date: Mon, 17 Feb 2025 12:03:47 +0000 Subject: [PATCH 2/5] [setup] Handle deprecation of pkg_resources --- setup.in.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.in.py b/setup.in.py index 21301a7..419f31f 100644 --- a/setup.in.py +++ b/setup.in.py @@ -4,12 +4,16 @@ 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) + try: + import importlib + importlib.import_module(pkg) + except: + import pkg_resources + pkg_resources.require(pkg) try: from setuptools import setup From 176dd9737dfc406d0a7a6e8b0272d8efa74cfc49 Mon Sep 17 00:00:00 2001 From: Arnaud TANGUY Date: Mon, 17 Feb 2025 12:55:08 +0000 Subject: [PATCH 3/5] [setup] Handle dependencies with setuptools --- setup.in.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/setup.in.py b/setup.in.py index 419f31f..1754fed 100644 --- a/setup.in.py +++ b/setup.in.py @@ -4,20 +4,14 @@ from __future__ import print_function +links = [] +requires = [] requirements_file = "@CMAKE_CURRENT_SOURCE_DIR@/requirements.txt" -with open(requirements_file) as fd: - for pkg in fd: - pkg = pkg.strip() - try: - import importlib - importlib.import_module(pkg) - except: - import pkg_resources - pkg_resources.require(pkg) try: from setuptools import setup from setuptools import Extension + from setuptools import find_packages except ImportError: from distutils.core import setup from distutils.extension import Extension @@ -76,10 +70,17 @@ def GenExtension(name): extensions = cythonize(extensions, cache = True) +dependencies = [ + "Cython>=0.2", + "coverage", + "numpy>=1.8.2", + "pytest" +] + setup( name = 'eigen', version='@PROJECT_VERSION@', ext_modules = extensions, - packages = packages, - package_data = { 'eigen': data } + package_data = { 'eigen': data }, + install_requires=dependencies ) From 527286e29f7d13c6b05b19d3de5f29265da81820 Mon Sep 17 00:00:00 2001 From: Arnaud TANGUY Date: Mon, 17 Feb 2025 12:59:35 +0000 Subject: [PATCH 4/5] [macos] Use arm64 architecture on macos --- .github/workflows/build.yml | 2 ++ setup.in.py | 11 +++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1fb2762..3dda3b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,6 +49,8 @@ jobs: uses: jrl-umi3218/github-actions/build-cmake-project@master with: build-type: ${{ matrix.build-type }} + env: + ARCHFLAGS: "-arch arm64" - name: Slack Notification if: failure() uses: archive/github-actions-slack@master diff --git a/setup.in.py b/setup.in.py index 1754fed..1e76b1b 100644 --- a/setup.in.py +++ b/setup.in.py @@ -4,14 +4,9 @@ from __future__ import print_function -links = [] -requires = [] -requirements_file = "@CMAKE_CURRENT_SOURCE_DIR@/requirements.txt" - try: from setuptools import setup from setuptools import Extension - from setuptools import find_packages except ImportError: from distutils.core import setup from distutils.extension import Extension @@ -43,14 +38,14 @@ def GenExtension(name): ext_src = pyx_src include_dirs = [os.path.join(os.getcwd(), "include"), "@EIGEN3_INCLUDE_DIR@", numpy.get_include()] compile_args = ['-std=c++11'] + print(sys.platform) if win32_build: compile_args = ['-DWIN32'] elif sys.platform == 'darwin': from platform import machine osx_arch = machine() - print(f"OSX framework used, force to {osx_arch} only") - os.environ["ARCHFLAGS"] = os.environ.get("ARCHFLAGS", f"-arch {osx_arch}") - compile_args = ['-arch', osx_arch] + 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) From 50a836071df1c3a01e8d881c8a8c764278ac77d2 Mon Sep 17 00:00:00 2001 From: Arnaud TANGUY Date: Mon, 17 Feb 2025 15:54:51 +0000 Subject: [PATCH 5/5] [cleanup] --- setup.in.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup.in.py b/setup.in.py index 1e76b1b..141a6a7 100644 --- a/setup.in.py +++ b/setup.in.py @@ -21,7 +21,6 @@ win32_build = os.name == 'nt' - from utils import generate_eigen_pyx this_path = os.path.dirname(os.path.realpath(__file__)) @@ -38,7 +37,6 @@ def GenExtension(name): ext_src = pyx_src include_dirs = [os.path.join(os.getcwd(), "include"), "@EIGEN3_INCLUDE_DIR@", numpy.get_include()] compile_args = ['-std=c++11'] - print(sys.platform) if win32_build: compile_args = ['-DWIN32'] elif sys.platform == 'darwin':