Skip to content

Commit eb8784d

Browse files
authored
Merge pull request #178 from IntelPython/remove-star-import
Remove star import from `_mkl_service`
2 parents 6b4f252 + 14f5427 commit eb8784d

6 files changed

Lines changed: 97 additions & 8 deletions

File tree

.flake8

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ extend-ignore =
44
E203,
55
# line too long (in docstrings):
66
E501,
7-
# ‘from module import *’ used; unable to detect undefined names:
8-
F403,
97
# doc line too long (105 > 80 characters):
108
W505,
119
# missing docstring in public module:

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88

99
# Move to clang-format-22
1010
6056b26ff82dfd156708fd7d3680470d9ba3c9ce
11+
12+
# Clean up in setup.py
13+
5045ed9c6b39fa1747cdae2719477e5a596f0d3b

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
### Fixed
2020
* Fixed Cython warnings when building `mkl-service` [gh-183](https://github.com/IntelPython/mkl-service/pull/183)
21+
* 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)
2122

2223
## [2.6.1] (11/25/2025)
2324

mkl/__init__.py

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2424
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525

26-
import sys
27-
2826
from . import _init_helper
2927

3028

@@ -34,6 +32,7 @@ def __init__(self):
3432

3533
def __enter__(self):
3634
import ctypes
35+
import sys
3736

3837
try:
3938
self.saved_rtld = sys.getdlopenflags()
@@ -46,6 +45,8 @@ def __enter__(self):
4645
del ctypes
4746

4847
def __exit__(self, *args):
48+
import sys
49+
4950
if self.saved_rtld:
5051
sys.setdlopenflags(self.saved_rtld)
5152
self.saved_rtld = None
@@ -55,9 +56,84 @@ def __exit__(self, *args):
5556
from . import _mklinit
5657

5758
del RTLD_for_MKL
58-
del sys
5959

60-
from ._py_mkl_service import *
60+
from ._py_mkl_service import (
61+
cbwr_get,
62+
cbwr_get_auto_branch,
63+
cbwr_set,
64+
disable_fast_mm,
65+
domain_get_max_threads,
66+
domain_set_num_threads,
67+
dsecnd,
68+
enable_instructions,
69+
free_buffers,
70+
get_clocks_frequency,
71+
get_cpu_clocks,
72+
get_cpu_frequency,
73+
get_dynamic,
74+
get_env_mode,
75+
get_max_cpu_frequency,
76+
get_max_threads,
77+
get_num_stripes,
78+
get_version,
79+
get_version_string,
80+
mem_stat,
81+
peak_mem_usage,
82+
second,
83+
set_dynamic,
84+
set_env_mode,
85+
set_memory_limit,
86+
set_mpi,
87+
set_num_stripes,
88+
set_num_threads,
89+
set_num_threads_local,
90+
thread_free_buffers,
91+
verbose,
92+
vml_clear_err_status,
93+
vml_get_err_status,
94+
vml_get_mode,
95+
vml_set_err_status,
96+
vml_set_mode,
97+
)
6198
from ._version import __version__
6299

100+
__all__ = [
101+
"get_version",
102+
"get_version_string",
103+
"set_num_threads",
104+
"domain_set_num_threads",
105+
"set_num_threads_local",
106+
"set_dynamic",
107+
"get_max_threads",
108+
"domain_get_max_threads",
109+
"get_dynamic",
110+
"set_num_stripes",
111+
"get_num_stripes",
112+
"second",
113+
"dsecnd",
114+
"get_cpu_clocks",
115+
"get_cpu_frequency",
116+
"get_max_cpu_frequency",
117+
"get_clocks_frequency",
118+
"free_buffers",
119+
"thread_free_buffers",
120+
"disable_fast_mm",
121+
"mem_stat",
122+
"peak_mem_usage",
123+
"set_memory_limit",
124+
"cbwr_set",
125+
"cbwr_get",
126+
"cbwr_get_auto_branch",
127+
"enable_instructions",
128+
"set_env_mode",
129+
"get_env_mode",
130+
"verbose",
131+
"set_mpi",
132+
"vml_set_mode",
133+
"vml_get_mode",
134+
"vml_set_err_status",
135+
"vml_get_err_status",
136+
"vml_clear_err_status",
137+
]
138+
63139
del _init_helper

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ test = ["pytest"]
7272
Download = "http://github.com/IntelPython/mkl-service"
7373
Homepage = "http://github.com/IntelPython/mkl-service"
7474

75+
[tool.black]
76+
line-length = 80
77+
78+
[tool.isort]
79+
line_length = 80
80+
profile = "black"
81+
7582
[tool.setuptools]
7683
include-package-data = true
7784
packages = ["mkl"]

setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def extensions():
3737
if mkl_root:
3838
mkl_info = {
3939
"include_dirs": [join(mkl_root, "include")],
40-
"library_dirs": [join(mkl_root, "lib"), join(mkl_root, "lib", "intel64")],
40+
"library_dirs": [
41+
join(mkl_root, "lib"),
42+
join(mkl_root, "lib", "intel64"),
43+
],
4144
"libraries": ["mkl_rt"],
4245
}
4346
else:
@@ -62,7 +65,8 @@ def extensions():
6265
"mkl._mklinit",
6366
sources=[join("mkl", "_mklinitmodule.c")],
6467
include_dirs=mkl_include_dirs,
65-
libraries=mkl_libraries + (["pthread"] if os.name == "posix" else []),
68+
libraries=mkl_libraries
69+
+ (["pthread"] if os.name == "posix" else []),
6670
library_dirs=mkl_library_dirs,
6771
runtime_library_dirs=mkl_rpaths,
6872
extra_compile_args=[

0 commit comments

Comments
 (0)