Skip to content

Commit 63090d0

Browse files
committed
Simplify ISA-L static build
1 parent 4d3116a commit 63090d0

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

setup.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,17 @@ def build_extension(self, ext):
7171
raise NotImplementedError(
7272
f"Unsupported platform: {sys.platform}")
7373
else:
74-
isa_l_prefix_dir = build_isa_l()
74+
isa_l_build_dir = build_isa_l()
7575
if SYSTEM_IS_UNIX:
7676
ext.extra_objects = [
77-
os.path.join(isa_l_prefix_dir, "lib", "libisal.a")]
77+
os.path.join(isa_l_build_dir, ".libs", "libisal.a")]
7878
elif SYSTEM_IS_WINDOWS:
7979
ext.extra_objects = [
80-
os.path.join(isa_l_prefix_dir, "isa-l_static.lib")]
80+
os.path.join(isa_l_build_dir, "isa-l_static.lib")]
8181
else:
8282
raise NotImplementedError(
8383
f"Unsupported platform: {sys.platform}")
84-
ext.include_dirs = [os.path.join(isa_l_prefix_dir,
85-
"include")]
86-
# -fPIC needed for proper static linking
87-
ext.extra_compile_args = ["-fPIC"]
84+
ext.include_dirs = [isa_l_build_dir]
8885
super().build_extension(ext)
8986

9087

@@ -98,12 +95,11 @@ def build_isa_l():
9895
if BUILD_CACHE:
9996
if BUILD_CACHE_FILE.exists():
10097
cache_path = Path(BUILD_CACHE_FILE.read_text())
101-
if (cache_path / "include" / "isa-l").exists():
98+
if (cache_path / "isa-l.h").exists():
10299
return str(cache_path)
103100

104101
# Creating temporary directories
105102
build_dir = tempfile.mktemp()
106-
temp_prefix = tempfile.mkdtemp()
107103
shutil.copytree(ISA_L_SOURCE, build_dir)
108104

109105
# Build environment is a copy of OS environment to allow user to influence
@@ -118,27 +114,17 @@ def build_isa_l():
118114
run_args = dict(cwd=build_dir, env=build_env)
119115
if SYSTEM_IS_UNIX:
120116
subprocess.run(os.path.join(build_dir, "autogen.sh"), **run_args)
121-
subprocess.run([os.path.join(build_dir, "configure"),
122-
"--prefix", temp_prefix], **run_args)
117+
subprocess.run([os.path.join(build_dir, "configure")], **run_args)
123118
subprocess.run(["make", "-j", str(cpu_count)], **run_args)
124-
subprocess.run(["make", "-j", str(cpu_count), "install"], **run_args)
125119
elif SYSTEM_IS_WINDOWS:
126-
print(build_env, file=sys.stderr)
127120
subprocess.run(["nmake", "/f", "Makefile.nmake"], **run_args)
128-
Path(temp_prefix, "include").mkdir()
129-
print(temp_prefix, file=sys.stderr)
130-
shutil.copytree(os.path.join(build_dir, "include"),
131-
Path(temp_prefix, "include", "isa-l"))
132-
shutil.copy(os.path.join(build_dir, "isa-l_static.lib"),
133-
os.path.join(temp_prefix, "isa-l_static.lib"))
134-
shutil.copy(os.path.join(build_dir, "isa-l.h"),
135-
os.path.join(temp_prefix, "include", "isa-l.h"))
136121
else:
137122
raise NotImplementedError(f"Unsupported platform: {sys.platform}")
138-
shutil.rmtree(build_dir)
123+
shutil.copytree(os.path.join(build_dir, "include"),
124+
os.path.join(build_dir, "isa-l"))
139125
if BUILD_CACHE:
140-
BUILD_CACHE_FILE.write_text(temp_prefix)
141-
return temp_prefix
126+
BUILD_CACHE_FILE.write_text(build_dir)
127+
return build_dir
142128

143129

144130
setup(

0 commit comments

Comments
 (0)