-
Notifications
You must be signed in to change notification settings - Fork 748
Work around a broken shared detection on some platforms #300
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
Conversation
This seems like an issue with xamarin mono project, not .NET Seems like a shame to have it always turned off, for a small percentage of PythonNET users Why not do some sort of check for Linux or darwin, then disable, but if win32 use flag? |
@mikofski can you please explain how Mono is to blame in more details, especially if you can point to specific code? |
@tonyroberts @filmor @vmuriart please review. Note that I marked this pull request as release-blocking. |
This change may fix a problem for some cases, but it will break it for others. If that flag isn't reliable because of a bug in some distributions, why not check another way instead of ignoring it? Checking the output of ldd on the Python executable would tell you if it's been linked dynamically or not. |
@tonyroberts @filmor this was a bit of learning for me. See analysis below. On Linux Mint it shows that python 2/3 are dynamically linked:
here is the output of ldd on Linux Mint with python 2/3:
According to this wiki this most likely means that python2/python3 were build dynamically: https://wiki.python.org/moin/BuildStatically I tried ldd with statically build python from source and indeed it shows the correct message:
with output:
The problem is that even when python is dynamically linked, @tonyroberts so can you give examples on which Linux systems and how this would still fail? |
@denfromufa Some versions of the Python executable are built with the python runtime embedded in them, and others are built with it as an external shared object (.so) file. For the ones that use a separate .so file, extensions like clr must also be built to use the same shared object. Ones that embed that code into the python executable must have extension modules built slightly differently (hence the Py_ENABLED_SHARED option, which should be set if a shared object is used). ldd shows you the shared libraries an executable depends on. If Python has been built to use a shared object version of the python runtime will see libpythonXX.so in the list of shared object dependencies. To build a version of Python that uses this shared object you should use the "--enable-shared" option when configuring. If successful, when you do ldd on python you will see libpythonXX.so in the output, and if you try the tests with clr built with PYTHON_WITHOUT_ENABLE_SHARED defined it will fail. Building Python for static linking is something different. This is only useful for embedding Python into another executable without having dynamic link dependencies. |
@tonyroberts great explanation, I will try to build with "--enable-shared" and do some testing. |
no more python 2.6 - missing subprocess.check_output()
# enable_shared = get_config_var("Py_ENABLE_SHARED") | ||
# if enable_shared == 0: | ||
defines.append("PYTHON_WITHOUT_ENABLE_SHARED") | ||
enable_shared = get_config_var("Py_ENABLE_SHARED") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capital "y" as in PY_ENABLE_SHARED
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tonyroberts @filmor please review |
@@ -10,7 +10,7 @@ | |||
from distutils.spawn import find_executable | |||
from distutils import log | |||
from platform import architecture | |||
from subprocess import Popen, CalledProcessError, PIPE, check_call | |||
from subprocess import Popen, CalledProcessError, PIPE, check_call, check_output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@denfromufa Did you try using _check_output
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but what is the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the exact same thing 😄. Atleast it sounds like _check_output
was copied from py27 so that earlier version (py26) could use it. I'm reviewing the changes we can make after dropping old python versions and noticed your code.
#119