-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Open
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-ctypes
Description
Bug report
Bug description:
I have a Python project like this:
Project
|---libs
|------dylib.dll
main.py
then, I try to use ctypes to load that:
from ctypes import *
lib = CDLL("libs/dylib.dll")
CRASHED!
Traceback (most recent call last):
File "...", line 4, in <module>
spdlog_api = ctypes.CDLL("libs/dylib.dll")
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\ctypes\__init__.py", line 379, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'lib/dylib.dll' (or one of its dependencies). Try using the full path with constructor syntax.
all right, lets use os to generate the full path.
os.path.dirname(os.path.abspath(__file__))+"/libs/spdlog-build.dll")
this works on my PC but CRASHED AGAIN ON ANOTHER COMPUTER!
It shows that ctypes can not load full path as well!
right , lets fix it!
then, I found that
NO! Ctypes is written in C so that I can only find the definition in ctypes.pyi
CPython versions tested on:
3.12
Operating systems tested on:
No response
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-ctypes