This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author indygreg
Recipients indygreg
Date 2019-05-27.00:02:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558915361.55.0.999227161151.issue37060@roundup.psfhosted.org>
In-reply-to
Content
ctypes/__init__.py calls _ctypes.dlopen(None) on Linux as part of code execution during module import. Unfortunately, dlopen() doesn't work if the current executable isn't a dynamic executable.

Using a fully statically linked Python executable:

$ ldd python3.7
        not a dynamic executable

$ python3.7
>>> import _ctypes

>>> _ctypes.dlopen(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: Dynamic loading not supported

>>> import ctypes
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gps/src/python-build-standalone.git/build/python/install/lib/python3.7/ctypes/__init__.py", line 444, in <module>
    pythonapi = PyDLL(None)
  File "/home/gps/src/python-build-standalone.git/build/python/install/lib/python3.7/ctypes/__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: Dynamic loading not supported


I think it is a bug that `import ctypes` raises OSError at import time in this environment. I can make a compelling argument that this error should either be suppressed or converted to an ImportError.

Producing a fully statically linked Python executable is a bit of work and isn't easily accomplished with the existing build system. My "python-build-standalone" project automates the process. A fully statically linked Python executable is available in the zstd compressed archive at https://github.com/indygreg/python-build-standalone/releases/download/20190505/cpython-3.7.3-linux64-musl-20190526T0219.tar.zst under the python/install/bin/python3.7 path. Simply extract that archive and run that binary to reproduce.
History
Date User Action Args
2019-05-27 00:02:41indygregsetrecipients: + indygreg
2019-05-27 00:02:41indygregsetmessageid: <1558915361.55.0.999227161151.issue37060@roundup.psfhosted.org>
2019-05-27 00:02:41indygreglinkissue37060 messages
2019-05-27 00:02:41indygregcreate