|
1 | 1 | #!/usr/bin/env python |
2 | 2 | import sysconfig |
| 3 | +from typing import Any, Dict, List, Optional, Tuple |
3 | 4 |
|
4 | 5 | from setuptools import Extension, setup |
5 | 6 |
|
6 | | -if sysconfig.get_config_var("Py_GIL_DISABLED"): |
7 | | - options = {} |
8 | | - define_macros = [] |
9 | | - py_limited_api = False |
| 7 | +options: Dict[str, Any] = {} |
| 8 | +define_macros: List[Tuple[str, Optional[str]]] = [("_POSIX_C_SOURCE", "200809L")] |
| 9 | +py_limited_api: bool = not sysconfig.get_config_var("Py_GIL_DISABLED") |
| 10 | +cflags: List[str] = [] |
| 11 | + |
| 12 | +if sysconfig.get_platform().startswith("win"): |
| 13 | + cflags.append("/utf-8") |
| 14 | + cflags.append("/std:c17") |
| 15 | + cflags.append("/experimental:c11atomics") |
10 | 16 | else: |
11 | | - options = {"bdist_wheel": {"py_limited_api": "cp38"}} |
12 | | - define_macros = [("Py_LIMITED_API", "0x030800f0")] |
13 | | - py_limited_api = True |
| 17 | + cflags.append("-std=c17") |
| 18 | + |
| 19 | +if py_limited_api: |
| 20 | + options["bdist_wheel"] = {"py_limited_api": "cp38"} |
| 21 | + define_macros.append(("Py_LIMITED_API", "0x030800f0")) |
14 | 22 |
|
15 | 23 | setup( |
16 | 24 | options=options, |
|
20 | 28 | sources=[ |
21 | 29 | "src/sonyflake_turbo/_sonyflake.c", |
22 | 30 | "src/sonyflake_turbo/sonyflake.c", |
23 | | - "src/sonyflake_turbo/machine_ids.c" |
| 31 | + "src/sonyflake_turbo/machine_ids.c", |
24 | 32 | ], |
25 | 33 | define_macros=define_macros, |
26 | 34 | py_limited_api=py_limited_api, |
| 35 | + extra_compile_args=cflags, |
27 | 36 | ), |
28 | 37 | ], |
29 | 38 | ) |
0 commit comments