Merge pull request #138133 from PhilTaken/fix/pysdl2
This commit is contained in:
commit
610ceb54e3
1 changed files with 127 additions and 100 deletions
|
@ -1,100 +1,127 @@
|
||||||
diff -ru PySDL2-0.9.7-old/sdl2/dll.py PySDL2-0.9.7/sdl2/dll.py
|
diff --git a/sdl2/dll.py b/sdl2/dll.py
|
||||||
--- PySDL2-0.9.7-old/sdl2/dll.py 2020-02-15 09:36:29.000000000 +0100
|
index 6e30259..12e1f7d 100644
|
||||||
+++ PySDL2-0.9.7/sdl2/dll.py 2020-09-23 20:24:09.365497270 +0200
|
--- a/sdl2/dll.py
|
||||||
@@ -94,15 +94,16 @@
|
+++ b/sdl2/dll.py
|
||||||
"""Function wrapper around the different DLL functions. Do not use or
|
@@ -145,7 +145,7 @@ class DLL(object):
|
||||||
instantiate this one directly from your user code.
|
"""Function wrapper around the different DLL functions. Do not use or
|
||||||
"""
|
instantiate this one directly from your user code.
|
||||||
- def __init__(self, libinfo, libnames, path=None):
|
"""
|
||||||
+ def __init__(self, libinfo, libfile):
|
- def __init__(self, libinfo, libnames, path=None):
|
||||||
self._dll = None
|
+ def __init__(self, libinfo, libfile):
|
||||||
self._libname = libinfo
|
self._dll = None
|
||||||
self._version = None
|
self._deps = None
|
||||||
- foundlibs = _findlib(libnames, path)
|
self._libname = libinfo
|
||||||
- dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
|
@@ -157,11 +157,12 @@ class DLL(object):
|
||||||
- if len(foundlibs) == 0:
|
"SDL2_image": 2001,
|
||||||
- raise RuntimeError("could not find any library for %s (%s)" %
|
"SDL2_gfx": 1003
|
||||||
- (libinfo, dllmsg))
|
}
|
||||||
+ #foundlibs = _findlib(libnames, path)
|
- foundlibs = _findlib(libnames, path)
|
||||||
+ #dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
|
- dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
|
||||||
+ #if len(foundlibs) == 0:
|
- if len(foundlibs) == 0:
|
||||||
+ # raise RuntimeError("could not find any library for %s (%s)" %
|
- raise RuntimeError("could not find any library for %s (%s)" %
|
||||||
+ # (libinfo, dllmsg))
|
- (libinfo, dllmsg))
|
||||||
+ foundlibs = [ libfile ]
|
+ #foundlibs = _findlib(libnames, path)
|
||||||
for libfile in foundlibs:
|
+ #dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
|
||||||
try:
|
+ #if len(foundlibs) == 0:
|
||||||
self._dll = CDLL(libfile)
|
+ # raise RuntimeError("could not find any library for %s (%s)" %
|
||||||
@@ -117,9 +118,9 @@
|
+ # (libinfo, dllmsg))
|
||||||
if self._dll is None:
|
+ foundlibs = [ libfile ]
|
||||||
raise RuntimeError("found %s, but it's not usable for the library %s" %
|
for libfile in foundlibs:
|
||||||
(foundlibs, libinfo))
|
try:
|
||||||
- if path is not None and sys.platform in ("win32",) and \
|
self._dll = CDLL(libfile)
|
||||||
- path in self._libfile:
|
@@ -185,19 +186,19 @@ class DLL(object):
|
||||||
- os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
|
(foundlibs, libinfo))
|
||||||
+ #if path is not None and sys.platform in ("win32",) and \
|
if _using_ms_store_python():
|
||||||
+ # path in self._libfile:
|
self._deps = _preload_deps(libinfo, self._libfile)
|
||||||
+ # os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
|
- if path is not None and sys.platform in ("win32",) and \
|
||||||
|
- path in self._libfile:
|
||||||
def bind_function(self, funcname, args=None, returns=None, added=None):
|
- os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
|
||||||
"""Binds the passed argument and return value types to the specified
|
+ #if path is not None and sys.platform in ("win32",) and \
|
||||||
@@ -220,7 +221,7 @@
|
+ # path in self._libfile:
|
||||||
return
|
+ # os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
|
||||||
|
|
||||||
try:
|
def bind_function(self, funcname, args=None, returns=None, added=None):
|
||||||
- dll = DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
|
"""Binds the passed argument and return value types to the specified
|
||||||
+ dll = DLL("SDL2", "@sdl2@")
|
function. If the version of the loaded library is older than the
|
||||||
except RuntimeError as exc:
|
version where the function was added, an informative exception will
|
||||||
raise ImportError(exc)
|
be raised if the bound function is called.
|
||||||
|
|
||||||
diff -ru PySDL2-0.9.7-old/sdl2/sdlgfx.py PySDL2-0.9.7/sdl2/sdlgfx.py
|
Args:
|
||||||
--- PySDL2-0.9.7-old/sdl2/sdlgfx.py 2020-02-02 11:07:00.000000000 +0100
|
funcname (str): The name of the function to bind.
|
||||||
+++ PySDL2-0.9.7/sdl2/sdlgfx.py 2020-09-23 20:23:56.997419129 +0200
|
args (List or None, optional): The data types of the C function's
|
||||||
@@ -39,8 +39,7 @@
|
arguments. Should be 'None' if function takes no arguments.
|
||||||
]
|
returns (optional): The return type of the bound C function. Should
|
||||||
|
be 'None' if function returns 'void'.
|
||||||
try:
|
@@ -288,7 +289,7 @@ def nullfunc(*args):
|
||||||
- dll = DLL("SDL2_gfx", ["SDL2_gfx", "SDL2_gfx-1.0"],
|
return
|
||||||
- os.getenv("PYSDL2_DLL_PATH"))
|
|
||||||
+ dll = DLL("SDL2_gfx", "@sdl2_gfx@")
|
try:
|
||||||
except RuntimeError as exc:
|
- dll = DLL("SDL2", ["SDL2", "SDL2-2.0", "SDL2-2.0.0"], os.getenv("PYSDL2_DLL_PATH"))
|
||||||
raise ImportError(exc)
|
+ dll = DLL("SDL2", "@sdl2@")
|
||||||
|
except RuntimeError as exc:
|
||||||
diff -ru PySDL2-0.9.7-old/sdl2/sdlimage.py PySDL2-0.9.7/sdl2/sdlimage.py
|
raise ImportError(exc)
|
||||||
--- PySDL2-0.9.7-old/sdl2/sdlimage.py 2020-02-02 11:07:00.000000000 +0100
|
|
||||||
+++ PySDL2-0.9.7/sdl2/sdlimage.py 2020-09-23 20:23:50.085375658 +0200
|
diff --git a/sdl2/sdlgfx.py b/sdl2/sdlgfx.py
|
||||||
@@ -27,8 +27,7 @@
|
index 090752e..a8a7488 100644
|
||||||
]
|
--- a/sdl2/sdlgfx.py
|
||||||
|
+++ b/sdl2/sdlgfx.py
|
||||||
try:
|
@@ -50,8 +50,7 @@ __all__ = [
|
||||||
- dll = DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"],
|
|
||||||
- os.getenv("PYSDL2_DLL_PATH"))
|
|
||||||
+ dll = DLL("SDL2_image", "@sdl2_image@")
|
try:
|
||||||
except RuntimeError as exc:
|
- dll = DLL("SDL2_gfx", ["SDL2_gfx", "SDL2_gfx-1.0"],
|
||||||
raise ImportError(exc)
|
- os.getenv("PYSDL2_DLL_PATH"))
|
||||||
|
+ dll = DLL("SDL2_gfx", "@sdl2_gfx@")
|
||||||
diff -ru PySDL2-0.9.7-old/sdl2/sdlmixer.py PySDL2-0.9.7/sdl2/sdlmixer.py
|
except RuntimeError as exc:
|
||||||
--- PySDL2-0.9.7-old/sdl2/sdlmixer.py 2020-02-02 11:07:00.000000000 +0100
|
raise ImportError(exc)
|
||||||
+++ PySDL2-0.9.7/sdl2/sdlmixer.py 2020-09-23 20:23:46.117350771 +0200
|
|
||||||
@@ -53,8 +53,7 @@
|
diff --git a/sdl2/sdlimage.py b/sdl2/sdlimage.py
|
||||||
]
|
index a6884e8..95d96df 100644
|
||||||
|
--- a/sdl2/sdlimage.py
|
||||||
try:
|
+++ b/sdl2/sdlimage.py
|
||||||
- dll = DLL("SDL2_mixer", ["SDL2_mixer", "SDL2_mixer-2.0"],
|
@@ -32,15 +32,14 @@ __all__ = [
|
||||||
- os.getenv("PYSDL2_DLL_PATH"))
|
"IMG_LoadXCF_RW", "IMG_LoadWEBP_RW", "IMG_LoadXPM_RW",
|
||||||
+ dll = DLL("SDL2_mixer", "@sdl2_mixer@")
|
"IMG_LoadXV_RW", "IMG_ReadXPMFromArray",
|
||||||
except RuntimeError as exc:
|
"IMG_GetError", "IMG_SetError", "IMG_SaveJPG", "IMG_SaveJPG_RW",
|
||||||
raise ImportError(exc)
|
-
|
||||||
|
+
|
||||||
diff -ru PySDL2-0.9.7-old/sdl2/sdlttf.py PySDL2-0.9.7/sdl2/sdlttf.py
|
# Python Functions
|
||||||
--- PySDL2-0.9.7-old/sdl2/sdlttf.py 2020-02-02 11:07:00.000000000 +0100
|
"get_dll_file"
|
||||||
+++ PySDL2-0.9.7/sdl2/sdlttf.py 2020-09-23 20:23:40.069312931 +0200
|
]
|
||||||
@@ -39,8 +39,7 @@
|
|
||||||
]
|
|
||||||
|
try:
|
||||||
try:
|
- dll = DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"],
|
||||||
- dll = DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"],
|
- os.getenv("PYSDL2_DLL_PATH"))
|
||||||
- os.getenv("PYSDL2_DLL_PATH"))
|
+ dll = DLL("SDL2_image", "@sdl2_image@")
|
||||||
+ dll = DLL("SDL2_ttf", "@sdl2_ttf@")
|
except RuntimeError as exc:
|
||||||
except RuntimeError as exc:
|
raise ImportError(exc)
|
||||||
raise ImportError(exc)
|
|
||||||
|
diff --git a/sdl2/sdlmixer.py b/sdl2/sdlmixer.py
|
||||||
|
index 9ad9b85..1c36289 100644
|
||||||
|
--- a/sdl2/sdlmixer.py
|
||||||
|
+++ b/sdl2/sdlmixer.py
|
||||||
|
@@ -76,8 +76,7 @@ __all__ = [
|
||||||
|
]
|
||||||
|
|
||||||
|
try:
|
||||||
|
- dll = DLL("SDL2_mixer", ["SDL2_mixer", "SDL2_mixer-2.0"],
|
||||||
|
- os.getenv("PYSDL2_DLL_PATH"))
|
||||||
|
+ dll = DLL("SDL2_mixer", "@sdl2_mixer@")
|
||||||
|
except RuntimeError as exc:
|
||||||
|
raise ImportError(exc)
|
||||||
|
|
||||||
|
diff --git a/sdl2/sdlttf.py b/sdl2/sdlttf.py
|
||||||
|
index 9c2d951..bd5a16a 100644
|
||||||
|
--- a/sdl2/sdlttf.py
|
||||||
|
+++ b/sdl2/sdlttf.py
|
||||||
|
@@ -54,8 +54,7 @@ __all__ = [
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
- dll = DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"],
|
||||||
|
- os.getenv("PYSDL2_DLL_PATH"))
|
||||||
|
+ dll = DLL("SDL2_ttf", "@sdl2_ttf@")
|
||||||
|
except RuntimeError as exc:
|
||||||
|
raise ImportError(exc)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue