Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions mypyc/lib-rt/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import os
import subprocess
import sys
from distutils.command.build_ext import build_ext
from distutils.core import Extension, setup
from distutils import ccompiler, sysconfig
from typing import Any

from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext

C_APIS_TO_TEST = [
"init.c",
"int_ops.c",
Expand Down Expand Up @@ -72,6 +74,14 @@ def run(self) -> None:
else:
# TODO: we need a way to share our preferred C flags and get_extension() logic with
# mypyc/build.py without code duplication.
compiler = ccompiler.new_compiler()
sysconfig.customize_compiler(compiler)
cflags: list[str] = []
if compiler.compiler_type == "unix":
cflags += ["-O3"]
elif compiler.compiler_type == "msvc":
cflags += ["/O2"]

setup(
ext_modules=[
Extension(
Expand All @@ -85,6 +95,7 @@ def run(self) -> None:
"getargsfast.c",
],
include_dirs=["."],
extra_compile_args=cflags,
)
]
)