Skip to content

Commit 4fbb305

Browse files
committed
Add windows support
1 parent 3557878 commit 4fbb305

2 files changed

Lines changed: 18 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-2022]
3636
env:
3737
CIBW_SKIP: pp*
3838
CIBW_ENVIRONMENT: >-

setup.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
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("/experimental:c11atomics")
1016
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"))
1422

1523
setup(
1624
options=options,
@@ -20,10 +28,11 @@
2028
sources=[
2129
"src/sonyflake_turbo/_sonyflake.c",
2230
"src/sonyflake_turbo/sonyflake.c",
23-
"src/sonyflake_turbo/machine_ids.c"
31+
"src/sonyflake_turbo/machine_ids.c",
2432
],
2533
define_macros=define_macros,
2634
py_limited_api=py_limited_api,
35+
extra_compile_args=cflags,
2736
),
2837
],
2938
)

0 commit comments

Comments
 (0)