ENH: provide a convenience function to replace npy_load_module#20395
ENH: provide a convenience function to replace npy_load_module#20395WarrenWeckesser merged 3 commits intonumpy:mainfrom
Conversation
|
This fixes the failing conda builds |
seberg
left a comment
There was a problem hiding this comment.
Generally, looks good to me, but I don't know this well (would be nice to get rid of the CI failure though).
One reference I found: #17731 (comment) there is a comment that we have to add the new module to sys.modules? And that snippet infers the name from the filename, although I am not sure that is actually what we do here.
|
|
||
| atexit.register(clean_up_temporary_directory) | ||
|
|
||
| from numpy.compat import npy_load_module |
There was a problem hiding this comment.
Should we leave the import here since this is probably somewhat public?
There was a problem hiding this comment.
It is a compatibility shim. I think not.
There was a problem hiding this comment.
From perusing the first couple of pages at searchcode, it seems users are properly importing it from numpy.compat and not numpy.distutils.misc_utils.
|
I added a comment about sys.modules to the function docstring. I prefer to minimally modify global state in the function itself. The function is for once-off loading, and if desired the caller can add the module to sys.modules. |
|
Maybe we can put this in as-is and iterate on it as needed. The CI failures are annoying. |
WarrenWeckesser
left a comment
There was a problem hiding this comment.
Looks good. I'll fix one small flake8 issue and merge.
…#20395) `load_module` is deprecated since python 3.4 and will be removed in python 3.12. Use `exec_module` instead. Provide a convenience function in `distutils.misc_utils` instead of `npy_load_module` from `compat.py3k`.
ENH: provide a convenience function to replace npy_load_module (#20395)
…#20395) `load_module` is deprecated since python 3.4 and will be removed in python 3.12. Use `exec_module` instead. Provide a convenience function in `distutils.misc_utils` instead of `npy_load_module` from `compat.py3k`.
…#20395) `load_module` is deprecated since python 3.4 and will be removed in python 3.12. Use `exec_module` instead. Provide a convenience function in `distutils.misc_utils` instead of `npy_load_module` from `compat.py3k`.
load_moduleis deprecated since python 3.4 and will be removed in python 3.12. Useexec_moduleinstead. Provide a convenience function indistutils.misc_utilsinstead ofnpy_load_modulefromcompat.py3k.This PR was triggered by deprecation warnings in python 3.10.