Skip to content

Commit

Permalink
cuda+py: swap out imp for importlib
Browse files Browse the repository at this point in the history
  • Loading branch information
janden committed Dec 18, 2023
1 parent a0fca04 commit fa15e74
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions python/cufinufft/cufinufft/_cufinufft.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
import ctypes
import os
import warnings

# While imp is deprecated, it is currently the inspection solution
# that works for all versions of Python 2 and 3.
# One day if that changes, can be replaced
# with importlib.find_spec.
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
import imp
import importlib.util

from ctypes import c_double
from ctypes import c_int
Expand All @@ -42,10 +35,9 @@
try:
if lib is None:
# Find the library.
fh = imp.find_module('cufinufftc')[0]
lib_path = importlib.util.find_spec('cufinufftc').origin
# Get the full path for the ctypes loader.
full_lib_path = os.path.realpath(fh.name)
fh.close() # Be nice and close the open file handle.
full_lib_path = os.path.realpath(lib_path)

# Load the library,
# which rpaths the libraries we care about.
Expand Down

0 comments on commit fa15e74

Please sign in to comment.