Skip to content

Commit

Permalink
Try loading CDLL on Windows / Python 3.8 by using os.add_dll_directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jobovy committed Mar 17, 2020
1 parent c97a40e commit 2c0e676
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
7 changes: 6 additions & 1 deletion galpy/actionAngle/actionAngleAdiabatic_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
else: #pragma: no cover
_ext_suffix= '.so'
for path in sys.path:
if not os.path.isdir(path): continue
try:
_lib = ctypes.CDLL(os.path.join(path,'galpy_actionAngle_c%s' % _ext_suffix))
if sys.platform == 'win32' and sys.version_info >= (3,8):
with os.add_dll_directory(path):
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
else:
_lib = ctypes.CDLL(os.path.join(path,'galpy_actionAngle_c%s' % _ext_suffix))
except OSError as e:
if os.path.exists(os.path.join(path,'galpy_actionAngle_c%s' % _ext_suffix)): #pragma: no cover
outerr= e
Expand Down
7 changes: 6 additions & 1 deletion galpy/actionAngle/actionAngleStaeckel_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
else: #pragma: no cover
_ext_suffix= '.so'
for path in sys.path:
if not os.path.isdir(path): continue
try:
_lib = ctypes.CDLL(os.path.join(path,'galpy_actionAngle_c%s' % _ext_suffix))
if sys.platform == 'win32' and sys.version_info >= (3,8):
with os.add_dll_directory(path):
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
else:
_lib = ctypes.CDLL(os.path.join(path,'galpy_actionAngle_c%s' % _ext_suffix))
except OSError as e:
if os.path.exists(os.path.join(path,'galpy_actionAngle_c%s' % _ext_suffix)): #pragma: no cover
outerr= e
Expand Down
7 changes: 6 additions & 1 deletion galpy/actionAngle/actionAngleTorus_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
else: #pragma: no cover
_ext_suffix= '.so'
for path in sys.path:
if not os.path.isdir(path): continue
try:
_lib = ctypes.CDLL(os.path.join(path,'galpy_actionAngleTorus_c%s' % _ext_suffix))
if sys.platform == 'win32' and sys.version_info >= (3,8):
with os.add_dll_directory(path):
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
else:
_lib = ctypes.CDLL(os.path.join(path,'galpy_actionAngleTorus_c%s' % _ext_suffix))
except OSError as e:
if os.path.exists(os.path.join(path,'galpy_actionAngleTorus_c%s' % _ext_suffix)): #pragma: no cover
outerr= e
Expand Down
7 changes: 6 additions & 1 deletion galpy/orbit/integrateFullOrbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@
else: #pragma: no cover
_ext_suffix= '.so'
for path in sys.path:
if not os.path.isdir(path): continue
try:
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
if sys.platform == 'win32' and sys.version_info >= (3,8):
with os.add_dll_directory(path):
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
else:
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
except OSError as e:
if os.path.exists(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix)): #pragma: no cover
outerr= e
Expand Down
7 changes: 6 additions & 1 deletion galpy/orbit/integratePlanarOrbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@
else: #pragma: no cover
_ext_suffix= '.so'
for path in sys.path:
if not os.path.isdir(path): continue
try:
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
if sys.platform == 'win32' and sys.version_info >= (3,8):
with os.add_dll_directory(path):
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
else:
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
except OSError as e:
if os.path.exists(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix)): #pragma: no cover
outerr= e
Expand Down
7 changes: 6 additions & 1 deletion galpy/potential/interpRZPotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
else: #pragma: no cover
_ext_suffix= '.so'
for path in sys.path:
if not os.path.isdir(path): continue
try:
_lib = ctypes.CDLL(os.path.join(path,'galpy_interppotential_c%s' % _ext_suffix))
if sys.platform == 'win32' and sys.version_info >= (3,8):
with os.add_dll_directory(path):
_lib = ctypes.CDLL(os.path.join(path,'galpy_integrate_c%s' % _ext_suffix))
else:
_lib = ctypes.CDLL(os.path.join(path,'galpy_interppotential_c%s' % _ext_suffix))
except OSError as e:
if os.path.exists(os.path.join(path,'galpy_interppotential_c%s' % _ext_suffix)): #pragma: no cover
outerr= e
Expand Down

0 comments on commit 2c0e676

Please sign in to comment.