mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-29 03:00:14 -04:00
fix: find_library can be None (#7145)
This commit is contained in:
@@ -211,7 +211,7 @@ generate_libc() {
|
|||||||
|
|
||||||
sed -i "s\import ctypes\import ctypes, ctypes.util, os\g" $BASE/libc.py
|
sed -i "s\import ctypes\import ctypes, ctypes.util, os\g" $BASE/libc.py
|
||||||
sed -i "s\FIXME_STUB\libc\g" $BASE/libc.py
|
sed -i "s\FIXME_STUB\libc\g" $BASE/libc.py
|
||||||
sed -i "s\FunctionFactoryStub()\ctypes.CDLL(ctypes.util.find_library('c'))\g" $BASE/libc.py
|
sed -i "s\FunctionFactoryStub()\None if (libc_path := ctypes.util.find_library('c')) is None else ctypes.CDLL(libc_path)\g" $BASE/libc.py
|
||||||
|
|
||||||
fixup $BASE/libc.py
|
fixup $BASE/libc.py
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class FunctionFactoryStub:
|
|||||||
# You can either re-run clan2py with -l /path/to/library.so
|
# You can either re-run clan2py with -l /path/to/library.so
|
||||||
# Or manually fix this by comment the ctypes.CDLL loading
|
# Or manually fix this by comment the ctypes.CDLL loading
|
||||||
_libraries = {}
|
_libraries = {}
|
||||||
_libraries['libc'] = ctypes.CDLL(ctypes.util.find_library('c')) # ctypes.CDLL('libc')
|
_libraries['libc'] = None if (libc_path := ctypes.util.find_library('c')) is None else ctypes.CDLL(libc_path) # ctypes.CDLL('libc')
|
||||||
def string_cast(char_pointer, encoding='utf-8', errors='strict'):
|
def string_cast(char_pointer, encoding='utf-8', errors='strict'):
|
||||||
value = ctypes.cast(char_pointer, ctypes.c_char_p).value
|
value = ctypes.cast(char_pointer, ctypes.c_char_p).value
|
||||||
if value is not None and encoding is not None:
|
if value is not None and encoding is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user