Skip to content

Commit b25e943

Browse files
author
Chris Barker
committed
ugly kludge no longer needed for windows library finding -- at least with conda-forge
1 parent cd557b2 commit b25e943

1 file changed

Lines changed: 4 additions & 38 deletions

File tree

py_gd/__init__.py

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,13 @@
1515

1616
__version__ = "2.3.3"
1717

18-
if sys.platform.startswith('win'):
19-
# This only works for Anaconda / miniconda
20-
# On other systems, logic needs to be added here.
21-
libpath = os.path.join(os.path.split(sys.executable)[0], "Library", "bin")
22-
23-
# UGLY kludge for Windows: load the libgd dll with ctypes so it can be used by the extension
24-
# import ctypes
25-
# # note: need to load up the dependencies, too
26-
# # this is a serious kludge!
27-
# try:
28-
# libpng = ctypes.cdll.LoadLibrary(os.path.join(libpath,'libpng16.dll'))
29-
# zlib = ctypes.cdll.LoadLibrary(os.path.join(libpath,'zlib.dll'))
30-
# libgd = ctypes.cdll.LoadLibrary(os.path.join(libpath,'libgd.dll'))
31-
# except WindowsError as err:
32-
# raise WindowsError("Can't find dlls for libgd, libpng, and libz.\n"
33-
# "This kludge is only written to support Anaconda installs")
34-
35-
# alternative ugly kludge: add lib dir to PATH:
36-
if (os.path.isfile(os.path.join(libpath, 'libpng16.dll')) and
37-
os.path.isfile(os.path.join(libpath, 'zlib.dll')) and
38-
os.path.isfile(os.path.join(libpath, 'libgd.dll'))):
39-
os.environ['PATH'] = libpath + os.pathsep + os.environ['PATH']
40-
41-
# raise RuntimeError("Can't find dlls for libgd, libpng, and libz.\n"
42-
# "This kludge is only written to support Anaconda installs\n",
43-
# "you may need to add some logic for other library locations",
44-
# )
4518
try:
4619
from .py_gd import * # noqa: F401
47-
4820
except ImportError as err:
4921
if str(err).startswith("DLL load failed:"):
50-
if not (os.path.isfile(os.path.join(libpath, 'libpng16.dll')) and
51-
os.path.isfile(os.path.join(libpath, 'zlib.dll')) and
52-
os.path.isfile(os.path.join(libpath, 'libgd.dll'))):
53-
raise RuntimeError("Can't find dlls for libgd, libpng, and libz.\n"
54-
"This kludge is only written to support Anaconda installs\n",
55-
"you may need to add some logic for other library locations",
56-
)
57-
else:
58-
raise
22+
raise RuntimeError("Can't find dlls for libgd, libpng, and/or libz.\n"
23+
"This kludge is only written to support Anaconda installs\n",
24+
"you may need to add some logic for other library locations",
25+
) from err
5926
else:
6027
raise
61-
print(err.args)

0 commit comments

Comments
 (0)