-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Are you switching to dynamic linking? #222
Comments
I am getting a similar issue on linux where some versions are dynamically linked, e.g., |
libpython.so should be shipped and I think this is what we intend. If it is not present in a package, this is a mistake. A PR fixing the issue would be very helpful! Thanks! |
Hi, thanks for the reply. But actually that was not my question. I've never seen libpython missing from the conda package so that's not my complain. My interest is that if the python executable is dynamically linked to libpython or not. In Linux, you can check it by passing the python executable installed by conda to |
The python executable is statically linked to libpython in the packages in the |
I see. That makes sense. Thanks for the explanation! |
It should be possible to get all symbols you need from the executable, but you will need to be sure not to use the shared library (which is making me wonder if that shouldn't be dropped). |
The shared libpython library is useful when embedding Python in another application. Additional, compiled Python extensions which were built with a pre-static interpreter often link against libpython so the library is needed for compatibility with these extensions. Debian ships a statically linked python interpreter but libpython can be in installed using There was a nice discussion of this topic on the distutils mailing list during the planning for manylinux1 standard. |
@jakirkham Yes, we have the code that gets symbols from executable statically linked to libpython. But there is a bit of peculiarity in our setting that prevents us from using it at the moment: https://github.com/JuliaPy/pyjulia/tree/master/julia/fake-julia @jjhelmus Thanks for the link! It looks like a useful discussion to follow. |
@tkf, here's an idea for your use-case. You can dlopen the executable as they are position independent executables. (conda-forge's python is not, but it soon will be. python in conda-forge/label/gcc7 and anaconda already are position independent executables). I had to create a symlink
PyCall.jl could load symbols from the python exectuable without launching julia through python. Therefore libpython is not used at all. |
@isuruf Awesome! Thanks a lot for looking into this. I didn't know you can do that. It looks like the best solution. Is there a nice way to detect if a python executable is a position independent executable? Quick googling finds https://unix.stackexchange.com/questions/89211/how-to-test-whether-a-linux-binary-was-compiled-as-position-independent-code but I'm wondering if there is a Python-specific cross-platform way of checking it, like some variable in cc: @stevengj |
I guess just trying to dlopen (and catch the error) would be the simplest? |
Yes. Btw, python2 on Ubuntu 18.04 is a PIE, but python3 is not. (https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1452115/comments/5) |
Thanks! |
I just ran into this because dolfin's JIT had
if libpython is statically linked. Adding the error message here, so folks can find this more easily than I did: libs to be loaded by Python must not link libpython, and instead must rely on When building with Python, it would appear that you can check if it is dynamically linked via sysconfig: from distutils import sysconfig
sysconfig.get_config_var('Py_ENABLE_SHARED') |
Is there any way I can still use |
For any Python interpreter you should be able to use:
.. to get the link line for an extension module (it will include the prefixed compiler filename iff you are using our compilers, otherwise it will not). If you are using C++, then replace |
What would be the simplest way to get a python executable with enable-shared ? Tried briefly to compile the feedstock locally, but couldn't make it work and was not sure I would get the right output. I am doing |
Issue:
Hi, I'm maintaining a library which requires a Python executable dynamically linked to libpython. It meant that I couldn't support Python installed via conda as it's used to be statically linked. But I just noticed that the latest Python 3.6.6 from conda-forge is dynamically linked. However, 3.7.0 is still statically linked (but it's built before 3.6.6). It would be nice for us if conda-forge distributes dynamically linked Python executables. Could you share your plan? Are you going to switch to dynamic linking? Would it be the case for all platforms?
Just for the record, here is what I get from conda-forge at the moment:
ref: JuliaPy/pyjulia#185 (comment)
Environment (
conda list
):Details about
conda
and system (conda info
):The text was updated successfully, but these errors were encountered: