Open nrnhines opened 1 day ago
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
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.
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)
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
It then becomes possible to build with:
and one can successfully
nrngui -python
and press NEURONMainMenu/File/Quit