diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index dee049e..4af13c8 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -8,3 +8,6 @@ # Move to clang-format-22 6056b26ff82dfd156708fd7d3680470d9ba3c9ce + +# Clean up in setup.py +5045ed9c6b39fa1747cdae2719477e5a596f0d3b diff --git a/CHANGELOG.md b/CHANGELOG.md index b7994fc..8e8f882 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Dropped support for Python 3.9 [gh-118](https://github.com/IntelPython/mkl-service/pull/118) * Dropped support for `"ssse3"`, `"sse4_1"`, `"avx"`, `"avx512_mic"`, `"avx512_mic,strict"`, and `"avx512_mic_e1"` cbwr branches [gh-173](https://github.com/IntelPython/mkl-service/pull/173) +### Fixed +* Removed use of star import in `mkl-service` initialization, which removes imported module pollution from the namespace [gh-178](https://github.com/IntelPython/mkl-service/pull/178) + ## [2.6.1] (11/25/2025) ### Fixed diff --git a/mkl/__init__.py b/mkl/__init__.py index 635b707..c0eb2ae 100644 --- a/mkl/__init__.py +++ b/mkl/__init__.py @@ -23,8 +23,6 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import sys - from . import _init_helper @@ -34,6 +32,7 @@ def __init__(self): def __enter__(self): import ctypes + import sys try: self.saved_rtld = sys.getdlopenflags() @@ -46,6 +45,8 @@ def __enter__(self): del ctypes def __exit__(self, *args): + import sys + if self.saved_rtld: sys.setdlopenflags(self.saved_rtld) self.saved_rtld = None @@ -55,9 +56,84 @@ def __exit__(self, *args): from . import _mklinit del RTLD_for_MKL -del sys -from ._py_mkl_service import * +from ._py_mkl_service import ( + cbwr_get, + cbwr_get_auto_branch, + cbwr_set, + disable_fast_mm, + domain_get_max_threads, + domain_set_num_threads, + dsecnd, + enable_instructions, + free_buffers, + get_clocks_frequency, + get_cpu_clocks, + get_cpu_frequency, + get_dynamic, + get_env_mode, + get_max_cpu_frequency, + get_max_threads, + get_num_stripes, + get_version, + get_version_string, + mem_stat, + peak_mem_usage, + second, + set_dynamic, + set_env_mode, + set_memory_limit, + set_mpi, + set_num_stripes, + set_num_threads, + set_num_threads_local, + thread_free_buffers, + verbose, + vml_clear_err_status, + vml_get_err_status, + vml_get_mode, + vml_set_err_status, + vml_set_mode, +) from ._version import __version__ +__all__ = [ + "get_version", + "get_version_string", + "set_num_threads", + "domain_set_num_threads", + "set_num_threads_local", + "set_dynamic", + "get_max_threads", + "domain_get_max_threads", + "get_dynamic", + "set_num_stripes", + "get_num_stripes", + "second", + "dsecnd", + "get_cpu_clocks", + "get_cpu_frequency", + "get_max_cpu_frequency", + "get_clocks_frequency", + "free_buffers", + "thread_free_buffers", + "disable_fast_mm", + "mem_stat", + "peak_mem_usage", + "set_memory_limit", + "cbwr_set", + "cbwr_get", + "cbwr_get_auto_branch", + "enable_instructions", + "set_env_mode", + "get_env_mode", + "verbose", + "set_mpi", + "vml_set_mode", + "vml_get_mode", + "vml_set_err_status", + "vml_get_err_status", + "vml_clear_err_status", +] + del _init_helper diff --git a/pyproject.toml b/pyproject.toml index cb8a5f2..f14b964 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,6 +72,17 @@ test = ["pytest"] Download = "http://github.com/IntelPython/mkl-service" Homepage = "http://github.com/IntelPython/mkl-service" +[tool.black] +line-length = 80 + +[tool.isort] +ensure_newline_before_comments = true +force_grid_wrap = 0 +include_trailing_comma = true +line_length = 80 +multi_line_output = 3 +use_parentheses = true + [tool.setuptools] include-package-data = true packages = ["mkl"] diff --git a/setup.py b/setup.py index 23bac56..0362197 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,10 @@ def extensions(): if mkl_root: mkl_info = { "include_dirs": [join(mkl_root, "include")], - "library_dirs": [join(mkl_root, "lib"), join(mkl_root, "lib", "intel64")], + "library_dirs": [ + join(mkl_root, "lib"), + join(mkl_root, "lib", "intel64"), + ], "libraries": ["mkl_rt"], } else: @@ -62,7 +65,8 @@ def extensions(): "mkl._mklinit", sources=[join("mkl", "_mklinitmodule.c")], include_dirs=mkl_include_dirs, - libraries=mkl_libraries + (["pthread"] if os.name == "posix" else []), + libraries=mkl_libraries + + (["pthread"] if os.name == "posix" else []), library_dirs=mkl_library_dirs, runtime_library_dirs=mkl_rpaths, extra_compile_args=[