pyd
pyd copied to clipboard
ldc can't link embedded python properly on ubuntu
and probably anywhere Py_ENABLE_SHARED is false. symptom: ImportError: /usr/lib/python3/dist-packages/numpy/core/multiarray.cpython-32mu.so: undefined symbol: PyExc_SystemError
ramification: can't use numpy and other extensions
solution: insert -rdynamic early in the link flags. unfortunately, ldc rearranges flag order, and exposes no way to override.
other solution: go back to gcc for link command. please no.
Is -rdynamic the only possible workaround? Quick googling shows that many solve this problem just by adding dlopen("libpython<PYTHON_VERSION>.so.1", RTLD_LAZY | RTLD_GLOBAL); before Py_Initialize()
LDC has recently changed the linker flag order behavior. Please try again, and otherwise open an issue with LDC, thanks!
I assume this would be in 1.6?
Yes indeed, 1.6.0 has what I meant. I may be remembering things wrong. But we had a discussion and some changes related to linking flags and their order (but perhaps only related to the flags in ldc.conf)
Ok. will check it out when I get some time.
there wouldn't happen to be a quicker way to install than build from source, would there? on 16.04, apt-get serves 0.17.1
curl -fsS https://dlang.org/install.sh | bash -s install ldc
https://dlang.org/download.html
@JohanEngelen
FYI: We can do it even a bit shorter: curl i.dlang.io | bash -s ldc
Since yesterday we also have a documentation page for the installer: https://dlang.org/install.html
Looks like ubuntu stopped building python with Py_ENABLE_SHARED=false, so this might not be much of an issue anymore.
@wilzbach
FYI: We can do it even a bit shorter: curl i.dlang.io | bash -s ldc
Brevity here is useless, and harms intelligibility. The original one at least makes it clear that you are downloading a shell script, and that you are installing ldc.
The installer page is very nice. (link needs to be added to the top menu!)
ubuntu 12.04 has an appropriate python build. With pyd from master and ldc 1.6.0, the following code is sufficient to trigger the aforementioned symptom:
auto context = new InterpContext();
context.py_stmts("import numpy");
This issue has been collecting dust long enough that I do not remember how to get link to work with -rdynamic. Will need to play with it.