Skip to content

Commit 5677bb1

Browse files
committed
simplify build
1 parent 76d1dca commit 5677bb1

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

setup.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,7 @@ def build_extension(self, ext):
7272
raise NotImplementedError(
7373
f"Unsupported platform: {sys.platform}")
7474
else:
75-
if self.compiler.compiler_type == "msvc":
76-
compiler = copy.deepcopy(self.compiler)
77-
if not compiler.initialized:
78-
compiler.initialize()
79-
compiler_command = f'"{compiler.cc}"'
80-
compiler_args = compiler.compile_options
81-
elif self.compiler.compiler_type == "unix":
82-
compiler_command = self.compiler.compiler[0]
83-
compiler_args = self.compiler.compiler[1:]
84-
else:
85-
raise NotImplementedError("Unknown compiler")
86-
isa_l_prefix_dir = build_isa_l(compiler_command,
87-
" ".join(compiler_args))
75+
isa_l_prefix_dir = build_isa_l()
8876
if SYSTEM_IS_UNIX:
8977
ext.extra_objects = [
9078
os.path.join(isa_l_prefix_dir, "lib", "libisal.a")]
@@ -106,7 +94,7 @@ def build_extension(self, ext):
10694
# 'cache' is only available from python 3.9 onwards.
10795
# see: https://docs.python.org/3/library/functools.html#functools.cache
10896
@functools.lru_cache(maxsize=None)
109-
def build_isa_l(compiler_command: str, compiler_options: str):
97+
def build_isa_l():
11098
# Check for cache
11199
if BUILD_CACHE:
112100
if BUILD_CACHE_FILE.exists():
@@ -122,14 +110,8 @@ def build_isa_l(compiler_command: str, compiler_options: str):
122110
# Build environment is a copy of OS environment to allow user to influence
123111
# it.
124112
build_env = os.environ.copy()
125-
# Add -fPIC flag to allow static compilation
126-
build_env["CC"] = compiler_command
127113
if SYSTEM_IS_UNIX:
128-
build_env["CFLAGS"] = compiler_options + " -fPIC"
129-
elif SYSTEM_IS_WINDOWS:
130-
# The nmake file has CLFAGS_REL for all the compiler options.
131-
# This is added to CFLAGS with all the necessary include options.
132-
build_env["CFLAGS_REL"] = compiler_options
114+
build_env["CFLAGS"] = build_env.get("CFLAGS", "") + " -O2 -fPIC"
133115
if hasattr(os, "sched_getaffinity"):
134116
cpu_count = len(os.sched_getaffinity(0))
135117
else: # sched_getaffinity not available on all platforms

0 commit comments

Comments
 (0)