The common idiom I've seen in various Python code bases for dynamically creating / loading a C function at runtime is:
import tempfile import shutil from ctypes import CDLL workdir = tempfile.mkdtemp() try:
While this seems to work very well on * nix systems, I'm not sure how well it will work on Win32. This is due to the fact that, in my experience, when a .dll inside a temporary directory is mapped to a process, it cannot be undone. Consequently, rmtree fails.
What options are available for me to make sure that ASAP is deleted on Win32.dll (and the directory in which it is located) since only the base lib was specified or when the application terminated so as not to leave a temporary jerk about).
source share