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

MACOSX nrniv -python does not allow use with gui. #3248

Open
nrnhines opened this issue Nov 25, 2024 · 3 comments
Open

MACOSX nrniv -python does not allow use with gui. #3248

nrnhines opened this issue Nov 25, 2024 · 3 comments

Comments

@nrnhines
Copy link
Member

Since #3239 the gui does not work on MACOSX arm64 for nrngui -python (either for python 3.12 or 3.13).

This may not be a problem for mac wheels as the issue appears to be related to building the software such that by default libedit replaces libreadline.

Solution:

All issues for nrniv -python are resolved when using the latest master merged into hines/universal2-wheel and using the wheels. Both python-3.12 and python-3.13 work. Basically the fix is to link a static build of libreadline.a from readline-7.0 and ncurses-6.4. A default build on the mac, I believe, uses libedit instead of libreadline. I don't know why the problems are experienced with libedit.

Also note that, after building universal2 wheels on maxosx, readline and ncurses libraries are "installed" at

% ls /opt/nrnwheel/arm64         
ncurses		readline

It then becomes possible to build with:

% cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Debug -DNRN_WHEEL_STATIC_READLINE=ON -DReadline_ROOT_DIR=/opt/nrnwheel/arm64/readline
% ninja install

and one can successfully nrngui -python and press NEURONMainMenu/File/Quit

@nrnhines
Copy link
Member Author

Ironically, readline was already brew install readline on my machine. It suffices for a local install from sources, to build with

% cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Debug -DReadline_ROOT_DIR=/opt/homebrew/opt/readline

But in creating a pkg file for another machine, static linking is needed, -DNRN_WHEEL_STATIC_READLINE=ON as the target machine may not have a real readline library. Also, pkg files are typically created as universal2, but the brew readline is unfortunately only for arm64. I.e.

% lipo -archs /opt/homebrew/opt/readline/lib/libreadline.dylib
arm64

@JCGoran
Copy link
Collaborator

JCGoran commented Nov 26, 2024

As a side note, I think any libraries from homebrew should not be used to make redistributable wheels, since the "bottles" are usually very machine-specific (should be fine for local installs though). I recall working on a project that needed some external libraries, and the homebrew versions were completely incompatible for portable wheels, so I ended up having to build them from source.

@nrnhines
Copy link
Member Author

I think we can let this ferment for a few days. At least macosx wheels should not have the problem as readline is statically linked in their creation. For pkg installers, the developer just needs to first prepare universal libreadline.a and dependent libraries to allow static linking (in bldnrnmacpkgcmake.sh (that needs a new name!) perhaps we can leverage packaging/python/build_static_readline_osx.bash to do that for us). For a normal user build from sources, there is a need to modify our cmake support to make sure we don't inadvertently get libedit.3.so (or else figure out how to make that work for nrniv -python with from neuron import gui)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants