You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it's surprisingly hard to find libpython in a robust way; this does the trick but relies on an external python package find_libpython:
# ubuntu:
$ pip3 install find_libpython
$ python3 -c 'import find_libpython; print(find_libpython.find_libpython())'
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
# osx:
$ python3 -c 'import find_libpython; print(find_libpython.find_libpython())'
/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/Python
# this also works on osx directly via shell, but somehow not on ubuntu (probably because I installed it inside a miniconda environment):
find_libpython
/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/Python
$ file /usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/Python
/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/Python: Mach-O 64-bit dynamically linked shared library x86_64
before finding find_libpython I had also tried parsing otool -L (ldd on linux) directly on OSX but this doesn't seem robust, but at least avoids calling an external python program:
import std/[osproc,strformat,os,strutils]
procgetPythonDll*(path: string): string=whendefined(osx):
letresult=execCmdEx(fmt"otool -L {path.quoteShell}")
ifresult.exitCode !=0: return""let s =result.output.splitLines
# dbg sif s.len <2: return""let s2 = s[1].split(maxsplit=2)
if s2.len <2: return""return s2[1]
whenisMainModule:
let exe ="python3".findExe
let s =getPythonDll(exe)
echo (exe, s)
proposal
step 1: link to find_libpython in the README
step 2: port find_libpython to nim; likely based on std/dyncalls etc
The text was updated successfully, but these errors were encountered:
Ran into this recently, is there any update on this? Manually specifying the python did fix it, but is rather uggly to include in scripts. This happened under MacOS with one of my students.
it's surprisingly hard to find libpython in a robust way; this does the trick but relies on an external python package
find_libpython
:links
findPythonDLL
+ friends in nimpy could be updated based on find_libpythonother
find_library
is described here: https://docs.python.org/2.5/lib/ctypes-finding-shared-libraries.html (https://github.com/python/cpython/blob/master/Lib/ctypes/util.py#L72) and would be useful to port/wrap to nim (more generally)find_libpython
I had also tried parsingotool -L
(ldd on linux) directly on OSX but this doesn't seem robust, but at least avoids calling an external python program:proposal
find_libpython
to nim; likely based on std/dyncalls etcThe text was updated successfully, but these errors were encountered: