Skip to content

Commit 06ca97e

Browse files
use different compile flags with MSVC
1 parent 842d31e commit 06ca97e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

setup.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ def _pack_std_jsonnet(self):
6060
f.write(",".join(str(x) for x in stdlib))
6161
f.write(",0\n\n")
6262

63+
def build_extension(self, ext):
64+
# At this point, the compiler has been chosen so we add compiler-specific flags.
65+
# There is unfortunately no built in support for this in setuptools.
66+
# Feature request: https://github.com/pypa/setuptools/issues/1819
67+
68+
print("Setting compile flags for compiler type " + self.compiler.compiler_type)
69+
# This is quite hacky as we're modifying the Extension object itself.
70+
if self.compiler.compiler_type == "msvc":
71+
ext.extra_compile_args.append("/std:c++17")
72+
else:
73+
ext.extra_compile_args.append("-std=c++17")
74+
75+
# Actually build.
76+
super().build_extension(ext)
77+
6378
def run(self):
6479
self._pack_std_jsonnet()
6580
super().run()
@@ -89,7 +104,6 @@ def run(self):
89104
"third_party/json",
90105
"third_party/rapidyaml",
91106
],
92-
extra_compile_args=["-std=c++17"],
93107
language="c++",
94108
)
95109
],

0 commit comments

Comments
 (0)