Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT Clean dead code in build helpers #25661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def build_extensions(self):
print(f"Using old NumPy C API (version 1.7) for extension {ext.name}")

if sklearn._OPENMP_SUPPORTED:
openmp_flag = get_openmp_flag(self.compiler)
openmp_flag = get_openmp_flag()

for e in self.extensions:
e.extra_compile_args += openmp_flag
Expand Down
9 changes: 2 additions & 7 deletions sklearn/_build_utils/openmp_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
from .pre_build_helpers import compile_test_program


def get_openmp_flag(compiler):
if hasattr(compiler, "compiler"):
compiler = compiler.compiler[0]
else:
compiler = compiler.__class__.__name__

def get_openmp_flag():
if sys.platform == "win32":
return ["/openmp"]
elif sys.platform == "darwin" and "openmp" in os.getenv("CPPFLAGS", ""):
Expand Down Expand Up @@ -66,7 +61,7 @@ def check_openmp_support():
if flag.startswith(("-L", "-Wl,-rpath", "-l", "-Wl,--sysroot=/"))
]

extra_postargs = get_openmp_flag
extra_postargs = get_openmp_flag()

openmp_exception = None
try:
Expand Down
9 changes: 1 addition & 8 deletions sklearn/_build_utils/pre_build_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,11 @@
from setuptools.command.build_ext import customize_compiler, new_compiler


def compile_test_program(code, extra_preargs=[], extra_postargs=[]):
def compile_test_program(code, extra_preargs=None, extra_postargs=None):
"""Check that some C code can be compiled and run"""
ccompiler = new_compiler()
customize_compiler(ccompiler)

# extra_(pre/post)args can be a callable to make it possible to get its
# value from the compiler
if callable(extra_preargs):
extra_preargs = extra_preargs(ccompiler)
if callable(extra_postargs):
extra_postargs = extra_postargs(ccompiler)

start_dir = os.path.abspath(".")

with tempfile.TemporaryDirectory() as tmp_dir:
Expand Down