From 3e39b38836470d0d4846cb5f949eeb3e73255c81 Mon Sep 17 00:00:00 2001 From: Mario Juric Date: Tue, 3 Oct 2023 15:18:30 -0700 Subject: [PATCH 1/2] conda-forge cross-compile build support Conda-forge builds Apple Silicon (arm64) binaries by cross-compiling, not by building on native platforms. This is all rather hacky and poorly documented, with the best documentation at: https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/ It's really really hacky for Python extension module builds, as distutils doesn't support cross-compilation. The way it works is by running a (hacked, monkeypatched) build-platform Python+distutils to drive the build, which then invokes the cross-platform compiler. This causes all sorts of issues with paths, where the cross-compiler will find the build- rather than host-platform libraries using the default logic from setup.py here. We avoid this by explicitly detecting conda-forge cross-platform builds by looking for the CONDA_BUILD_CROSS_COMPILATION environment variable. If this variable is set, we set up the library paths by looking at the PREFIX variable (which conda sets to the destination where the package will be installed). This makes the cross-compilation work. It doesn't make it any less ugly, but that's the world we live in... --- setup.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 7f55a7f..0fdf2aa 100644 --- a/setup.py +++ b/setup.py @@ -44,13 +44,25 @@ def finalize_options(self): rebdirsp = get_python_lib()+'/'#[p for p in sys.path if p.endswith('site-packages')][0]+'/' self.include_dirs.append(rebdir) sources = [ 'src/assist.c', 'src/spk.c', 'src/planets.c', 'src/forces.c'], - self.library_dirs.append(rebdir+'/../') - self.library_dirs.append(rebdirsp) - for ext in self.extensions: - ext.runtime_library_dirs.append(rebdir+'/../') - ext.extra_link_args.append('-Wl,-rpath,'+rebdir+'/../') - ext.runtime_library_dirs.append(rebdirsp) - ext.extra_link_args.append('-Wl,-rpath,'+rebdirsp) + + if not "CONDA_BUILD_CROSS_COMPILATION" in os.environ: + self.library_dirs.append(rebdir+'/../') + self.library_dirs.append(rebdirsp) + for ext in self.extensions: + ext.runtime_library_dirs.append(rebdir+'/../') + ext.extra_link_args.append('-Wl,-rpath,'+rebdir+'/../') + ext.runtime_library_dirs.append(rebdirsp) + ext.extra_link_args.append('-Wl,-rpath,'+rebdirsp) + print(extra_link_args) + print(rebdir+'/../') + print(rebdirsp) + else: + # For conda-forge cross-compile builds + rebdir=get_python_lib(prefix=os.environ["PREFIX"]) + self.library_dirs.append(rebdir) + for ext in self.extensions: + ext.extra_link_args.append('-Wl,-rpath,'+rebdir) + print(ext.extra_link_args) from distutils.version import LooseVersion @@ -77,7 +89,7 @@ def finalize_options(self): long_description = f.read() setup(name='assist', - version='1.1.3', + version='1.1.5', description='A library high accuracy ephemeris in REBOUND', long_description=long_description, long_description_content_type="text/markdown", From da1e0aee629b5550e99d17eccec496523390fb78 Mon Sep 17 00:00:00 2001 From: Mario Juric Date: Tue, 3 Oct 2023 17:48:53 -0700 Subject: [PATCH 2/2] Bump version to 1.1.6 using update_version.py --- README.md | 2 +- setup.py | 4 ++-- src/assist.c | 2 +- version.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 34a70dd..465e797 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Version](https://img.shields.io/badge/assist-v1.1.3-green.svg?style=flat)](https://assist.readthedocs.org) +[![Version](https://img.shields.io/badge/assist-v1.1.6-green.svg?style=flat)](https://assist.readthedocs.org) [![GPL](https://img.shields.io/badge/license-GPL-green.svg?style=flat)](https://github.com/matthewholman/blob/main/LICENSE) [![Python unit tests)](https://github.com/matthewholman/assist/actions/workflows/python.yml/badge.svg)](https://github.com/matthewholman/assist/actions/workflows/python.yml) [![C unit tests](https://github.com/matthewholman/assist/actions/workflows/c.yml/badge.svg)](https://github.com/matthewholman/assist/actions/workflows/c.yml) diff --git a/setup.py b/setup.py index 0fdf2aa..e4991ff 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ ghash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii") ghash_arg = "-DASSISTGITHASH="+ghash except: - ghash_arg = "-DASSISTGITHASH=52acc4b057a6c26f4a8f324651c3d9b19cbaf6b5" #GITHASHAUTOUPDATE + ghash_arg = "-DASSISTGITHASH=3e39b38836470d0d4846cb5f949eeb3e73255c81" #GITHASHAUTOUPDATE class build_ext(_build_ext): def finalize_options(self): @@ -89,7 +89,7 @@ def finalize_options(self): long_description = f.read() setup(name='assist', - version='1.1.5', + version='1.1.6', description='A library high accuracy ephemeris in REBOUND', long_description=long_description, long_description_content_type="text/markdown", diff --git a/src/assist.c b/src/assist.c index 55aafb5..5932b5b 100644 --- a/src/assist.c +++ b/src/assist.c @@ -44,7 +44,7 @@ const int reb_max_messages_N = 10; #define str(s) #s const char* assist_build_str = __DATE__ " " __TIME__; // Date and time build string. -const char* assist_version_str = "1.1.3"; // **VERSIONLINE** This line gets updated automatically. Do not edit manually. +const char* assist_version_str = "1.1.6"; // **VERSIONLINE** This line gets updated automatically. Do not edit manually. const char* assist_githash_str = STRINGIFY(ASSISTGITHASH);// This line gets updated automatically. Do not edit manually. diff --git a/version.txt b/version.txt index 2e1e6a9..bc72b61 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ -1.1.3 +1.1.6