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 8
8
import os
9
9
import subprocess
10
10
import sys
11
- from distutils .command .build_ext import build_ext
12
- from distutils .core import Extension , setup
11
+ from distutils import ccompiler , sysconfig
13
12
from typing import Any
14
13
14
+ from setuptools import Extension , setup
15
+ from setuptools .command .build_ext import build_ext
16
+
15
17
C_APIS_TO_TEST = [
16
18
"init.c" ,
17
19
"int_ops.c" ,
@@ -72,6 +74,14 @@ def run(self) -> None:
72
74
else :
73
75
# TODO: we need a way to share our preferred C flags and get_extension() logic with
74
76
# 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
+
75
85
setup (
76
86
ext_modules = [
77
87
Extension (
@@ -85,6 +95,7 @@ def run(self) -> None:
85
95
"getargsfast.c" ,
86
96
],
87
97
include_dirs = ["." ],
98
+ extra_compile_args = cflags ,
88
99
)
89
100
]
90
101
)
You can’t perform that action at this time.
0 commit comments