Skip to content

Commit 418fd1f

Browse files
committed
More touches
1 parent 8e7cdcb commit 418fd1f

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "0.0.*"
1+
version = "0.0.*"

mypyc/lib-rt/setup.py

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,65 @@
1212
from distutils.core import Extension, setup
1313
from typing import Any
1414

15-
kwargs: dict[str, Any]
16-
if sys.platform == "darwin":
17-
kwargs = {"language": "c++"}
18-
compile_args = []
19-
else:
20-
kwargs = {}
21-
compile_args = ["--std=c++11"]
15+
C_APIS_TO_TEST = [
16+
"init.c",
17+
"int_ops.c",
18+
"float_ops.c",
19+
"list_ops.c",
20+
"exc_ops.c",
21+
"generic_ops.c",
22+
"pythonsupport.c",
23+
]
2224

2325

24-
class build_ext_custom(build_ext): # noqa: N801
25-
def get_library_names(self):
26+
class BuildExtGtest(build_ext):
27+
def get_library_names(self) -> list[str]:
2628
return ["gtest"]
2729

28-
def run(self):
30+
def run(self) -> None:
31+
# Build Google Test, the C++ framework we use for testing C code.
32+
# The source code for Google Test is copied to this repository.
2933
gtest_dir = os.path.abspath(
3034
os.path.join(os.path.dirname(__file__), "..", "external", "googletest")
3135
)
32-
3336
os.makedirs(self.build_temp, exist_ok=True)
34-
35-
# Build Google Test, the C++ framework we use for testing C code.
36-
# The source code for Google Test is copied to this repository.
3737
subprocess.check_call(
3838
["make", "-f", os.path.join(gtest_dir, "make", "Makefile"), f"GTEST_DIR={gtest_dir}"],
3939
cwd=self.build_temp,
4040
)
41-
4241
self.library_dirs = [self.build_temp]
43-
4442
return build_ext.run(self)
4543

4644

4745
if "--run-capi-tests" in sys.argv:
4846
sys.argv.pop()
47+
48+
kwargs: dict[str, Any]
49+
if sys.platform == "darwin":
50+
kwargs = {"language": "c++"}
51+
compile_args = []
52+
else:
53+
kwargs = {}
54+
compile_args = ["--std=c++11"]
55+
4956
setup(
5057
name="test_capi",
5158
version="0.1",
5259
ext_modules=[
5360
Extension(
5461
"test_capi",
55-
[
56-
"test_capi.cc",
57-
"init.c",
58-
"int_ops.c",
59-
"float_ops.c",
60-
"list_ops.c",
61-
"exc_ops.c",
62-
"generic_ops.c",
63-
"pythonsupport.c",
64-
],
62+
["test_capi.cc"] + C_APIS_TO_TEST,
6563
depends=["CPy.h", "mypyc_util.h", "pythonsupport.h"],
6664
extra_compile_args=["-Wno-unused-function", "-Wno-sign-compare"] + compile_args,
6765
libraries=["gtest"],
6866
include_dirs=["../external/googletest", "../external/googletest/include"],
6967
**kwargs,
7068
)
7169
],
72-
cmdclass={"build_ext": build_ext_custom},
70+
cmdclass={"build_ext": BuildExtGtest},
7371
)
7472
else:
75-
# TODO: this is a stub, we need a way to share common build logic with
73+
# TODO: we need a way to share our preferred C flags and get_extension() logic with
7674
# mypyc/build.py without code duplication.
7775
setup(
7876
name="mypy-native",
@@ -82,8 +80,6 @@ def run(self):
8280
"native_internal",
8381
["native_internal.c", "init.c", "int_ops.c", "exc_ops.c", "pythonsupport.c"],
8482
include_dirs=["."],
85-
**kwargs,
8683
)
8784
],
88-
cmdclass={"build_ext": build_ext_custom},
8985
)

0 commit comments

Comments
 (0)