Skip to content

Commit 5e6cff0

Browse files
committed
setup.py: cosmetic clean-up
1 parent 9dbe572 commit 5e6cff0

2 files changed

Lines changed: 21 additions & 22 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dist/
1717
.pytest_cache
1818
blis.egg-info/
1919
tmp/
20+
z/
2021

2122
# Blis stuff
2223
blis/include

setup.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,38 +61,34 @@ def find_in_path(name, path):
6161
return None
6262

6363

64-
# By subclassing build_extensions we have the actual compiler that will be used
65-
# which is really known only after finalize_options
66-
# http://stackoverflow.com/questions/724664/python-distutils-how-to-get-a-compiler-that-is-going-to-be-used
67-
class build_ext_options:
68-
def build_options(self):
64+
class ExtensionBuilder(build_ext):
65+
# By overriding build_extensions we have the actual compiler that will be used
66+
# which is really known only after finalize_options
67+
# http://stackoverflow.com/questions/724664/python-distutils-how-to-get-a-compiler-that-is-going-to-be-used
68+
def build_extensions(self):
6969
if hasattr(self.compiler, "initialize"):
7070
self.compiler.initialize()
7171
self.compiler.platform = sys.platform[:6]
72-
print("Build options", self.compiler.platform, self.compiler.compiler_type)
73-
74-
self.compiler.include_dirs = [numpy.get_include()] + self.compiler.include_dirs
72+
self.compiler.include_dirs.append(numpy.get_include())
7573

7674
if self.compiler.compiler_type == "msvc":
77-
include_dirs = list(self.compiler.include_dirs)
78-
library_dirs = list(self.compiler.library_dirs)
75+
# Replace msvc compiler with unix compiler
76+
include_dirs = self.compiler.include_dirs[:]
77+
library_dirs = self.compiler.library_dirs[:]
78+
llvm_path = locate_windows_llvm()
79+
7980
self.compiler = new_compiler(plat="nt", compiler="unix")
8081
self.compiler.platform = "nt"
8182
self.compiler.compiler_type = "msvc"
82-
self.compiler.compiler = [locate_windows_llvm()]
83-
self.compiler.compiler_so = list(self.compiler.compiler)
84-
self.compiler.preprocessor = list(self.compiler.compiler)
85-
self.compiler.linker = list(self.compiler.compiler) + ["-shared"]
86-
self.compiler.linker_so = list(self.compiler.linker)
87-
self.compiler.linker_exe = list(self.compiler.linker)
83+
self.compiler.compiler = [llvm_path]
84+
self.compiler.compiler_so = [llvm_path]
85+
self.compiler.preprocessor = [llvm_path]
86+
self.compiler.linker_so = [llvm_path, "-shared"]
87+
self.compiler.linker_exe = [llvm_path, "-shared"]
8888
self.compiler.archiver = ["llvm-ar"]
89-
self.compiler.library_dirs.extend(library_dirs)
89+
self.compiler.library_dirs = library_dirs
9090
self.compiler.include_dirs = include_dirs
9191

92-
93-
class ExtensionBuilder(build_ext, build_ext_options):
94-
def build_extensions(self):
95-
build_ext_options.build_options(self)
9692
if sys.platform in ("msvc", "win32"):
9793
platform_name = "windows"
9894
elif sys.platform == "darwin":
@@ -122,7 +118,8 @@ def build_extensions(self):
122118
os.path.join(INCLUDE, "%s-%s" % (platform_name, arch))
123119
)
124120
e.extra_objects = list(short_paths)
125-
build_ext.build_extensions(self)
121+
122+
super().build_extensions()
126123
shutil.rmtree(short_dir)
127124

128125
def get_arch_name(self, platform_name):
@@ -326,6 +323,7 @@ def chdir(new_dir):
326323
"License :: OSI Approved :: BSD License",
327324
"Operating System :: POSIX :: Linux",
328325
"Operating System :: MacOS :: MacOS X",
326+
"Operating System :: Microsoft :: Windows",
329327
"Programming Language :: Python :: 3.10",
330328
"Programming Language :: Python :: 3.11",
331329
"Programming Language :: Python :: 3.12",

0 commit comments

Comments
 (0)