Skip to content

Commit f1fdfc7

Browse files
committed
Add MSVC support
1 parent 56be50e commit f1fdfc7

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
runs-on: ${{ matrix.os }}
3333
strategy:
3434
matrix:
35-
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-14]
35+
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-14, windows-2025]
3636
env:
3737
CIBW_SKIP: pp*
3838
CIBW_ENVIRONMENT: >-

setup.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
#!/usr/bin/env python
22
import sysconfig
3+
from typing import Any, Dict, List, Optional, Tuple
34

45
from setuptools import Extension, setup
56

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("/Zc:preprocessor")
16+
cflags.append("/experimental:c11atomics")
1017
else:
11-
options = {"bdist_wheel": {"py_limited_api": "cp38"}}
12-
define_macros = [("Py_LIMITED_API", "0x030800f0")]
13-
py_limited_api = True
18+
cflags.append("-std=c17")
19+
20+
if py_limited_api:
21+
options["bdist_wheel"] = {"py_limited_api": "cp38"}
22+
define_macros.append(("Py_LIMITED_API", "0x030800f0"))
1423

1524
setup(
1625
options=options,
@@ -20,10 +29,11 @@
2029
sources=[
2130
"src/sonyflake_turbo/_sonyflake.c",
2231
"src/sonyflake_turbo/sonyflake.c",
23-
"src/sonyflake_turbo/machine_ids.c"
32+
"src/sonyflake_turbo/machine_ids.c",
2433
],
2534
define_macros=define_macros,
2635
py_limited_api=py_limited_api,
36+
extra_compile_args=cflags,
2737
),
2838
],
2939
)

0 commit comments

Comments
 (0)