Use find_msvcrt() to load the CRT instead of globbing

This commit is contained in:
Kovid Goyal 2016-06-16 19:29:40 +05:30
parent 96e743c5b1
commit 0ba86c31f4
2 changed files with 10 additions and 3 deletions

View File

@ -274,6 +274,12 @@ def test_openssl():
raise ValueError('Mozilla CA certs not loaded')
fprint('SSL OK!')
def test_crt():
from ctypes.util import find_msvcrt
if not find_msvcrt():
raise SystemExit('find_msvcrt() failed')
fprint('CRT OK!')
def test():
if iswindows:
test_dlls()
@ -305,6 +311,7 @@ def test():
test_wpd()
test_winutil()
test_file_dialog_helper()
test_crt()
else:
test_terminal()
if isosx:

View File

@ -158,9 +158,9 @@ def crt():
# We use the C runtime bundled with the calibre windows build
global _crt
if _crt is None:
import glob, ctypes
d = os.path.join(os.path.dirname(sys.executable), '*.CRT', 'msvcr*.dll')
_crt = ctypes.CDLL(glob.glob(d)[0])
import ctypes
from ctypes.util import find_msvcrt
_crt = ctypes.CDLL(find_msvcrt())
return _crt
class ColoredStream(Detect):