iiasa / ixmp

The ix modeling platform for integrated and cross-cutting scenario analysis
https://docs.messageix.org/ixmp
Apache License 2.0
36 stars 110 forks source link

Work around libgmdjni64.dylib not compatible with arm64 architecture on macOS #531

Open ravitby opened 1 month ago

ravitby commented 1 month ago

Installing Gams on the arm64 version reproducing the following error. The issue is related to the closed issue #473

java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: 
/Users/ravitb/Workspace/TAU/ilTransport/ixmp/ixmp/backend/jdbc/libgmdjni64.dylib: 
dlopen(/Users/ravitb/Workspace/TAU/ilTransport/ixmp/ixmp/backend/jdbc/libgmdjni64.dylib, 0x0001): tried: 
'/Users/ravitb/Workspace/TAU/ilTransport/ixmp/ixmp/backend/jdbc/libgmdjni64.dylib' (mach-o file, but is an incompatible 
architecture (have 'x86_64', need 'arm64')), 
'/System/Volumes/Preboot/Cryptexes/OS/Users/ravitb/Workspace/TAU/ilTransport/ixmp/ixmp/backend/jdbc/libgmdjni64.dylib' (no
such file), '/Users/ravitb/Workspace/TAU/ilTransport/ixmp/ixmp/backend/jdbc/libgmdjni64.dylib' (mach-o file, but is an 
incompatible architecture (have 'x86_64', need 'arm64'))

I wrote to Gams support and they suggested to replace the libgmdjni64.dylib dll file from the installation Gams path:

 /Library/Frameworks/GAMS.framework/Versions/Current/Resources/apifiles/Java/api/libgmdjni64.dylib

to the ixmp path as follows:

Path to ixmp/ixmp/backend/jdbc/libgmdjni64.dylib
khaeru commented 1 month ago

Thanks! This is indeed a simpler work-around than previously devised.

It may be possible to automatically achieve this for users, but I am not sure how. Some ideas include:

  1. Build and publish different 'wheels' for the different macOS architectures: for x86_64, including the current file, and for arm64 including instead the other file.
  2. Package two files with names like:

    • libgmdjni64-x86_64.dylib
    • libgmdjni64-amd64.dylib

    …and depend on Java picking up the correct one. I am not sure if this would work.

  3. Put files with the correct names in separate directories, and selectively add one or the other to the Java CLASSPATH when starting the JVM: https://github.com/iiasa/ixmp/blob/f08447f658780c38a3238944e9b0cf5e1161f476/ixmp/backend/jdbc.py#L1244-L1252
khaeru commented 1 month ago

@ravitby could you please give the result of the following on your system?

import platform
print(platform.processor(), platform.uname()

This could help develop a solution per (3) above.

ravitby commented 1 month ago

This is the results of the print:

print(platform.processor(), platform.uname())
arm uname_result(system='Darwin', node='Ravits-MacBook-Pro.local', release='23.2.0', version='Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000', machine='arm64')