File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 88import os
99import subprocess
1010import sys
11- from distutils .command .build_ext import build_ext
12- from distutils .core import Extension , setup
11+ from distutils import ccompiler , sysconfig
1312from typing import Any
1413
14+ from setuptools import Extension , setup
15+ from setuptools .command .build_ext import build_ext
16+
1517C_APIS_TO_TEST = [
1618 "init.c" ,
1719 "int_ops.c" ,
@@ -72,6 +74,14 @@ def run(self) -> None:
7274else :
7375 # TODO: we need a way to share our preferred C flags and get_extension() logic with
7476 # mypyc/build.py without code duplication.
77+ compiler = ccompiler .new_compiler ()
78+ sysconfig .customize_compiler (compiler )
79+ cflags : list [str ] = []
80+ if compiler .compiler_type == "unix" :
81+ cflags += ["-O3" ]
82+ elif compiler .compiler_type == "msvc" :
83+ cflags += ["/O2" ]
84+
7585 setup (
7686 ext_modules = [
7787 Extension (
@@ -85,6 +95,7 @@ def run(self) -> None:
8595 "getargsfast.c" ,
8696 ],
8797 include_dirs = ["." ],
98+ extra_compile_args = cflags ,
8899 )
89100 ]
90101 )
You can’t perform that action at this time.
0 commit comments