Skip to content

Commit 1a6ba7a

Browse files
committed
Add windows support
1 parent af0f1f9 commit 1a6ba7a

2 files changed

Lines changed: 17 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: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
#!/usr/bin/env python
2+
import sys
23
import sysconfig
4+
from typing import Any, Dict, List, Optional, Tuple
35

46
from setuptools import Extension, setup
57

6-
if sysconfig.get_config_var("Py_GIL_DISABLED"):
7-
options = {}
8-
define_macros = []
9-
py_limited_api = False
8+
options: Dict[str, Any] = {}
9+
define_macros: List[Tuple[str, Optional[str]]] = [("_POSIX_C_SOURCE", "199309L")]
10+
py_limited_api: bool = not sysconfig.get_config_var("Py_GIL_DISABLED")
11+
cflags: List[str] = []
12+
13+
if sys.platform == "win32":
14+
cflags.append("/std:c17")
1015
else:
11-
options = {"bdist_wheel": {"py_limited_api": "cp38"}}
12-
define_macros = [("Py_LIMITED_API", "0x030800f0")]
13-
py_limited_api = True
16+
cflags.append("-std=c17")
17+
18+
if py_limited_api:
19+
options["bdist_wheel"] = {"py_limited_api": "cp38"}
20+
define_macros.append(("Py_LIMITED_API", "0x030800f0"))
1421

1522
setup(
1623
options=options,
@@ -20,10 +27,11 @@
2027
sources=[
2128
"src/sonyflake_turbo/_sonyflake.c",
2229
"src/sonyflake_turbo/sonyflake.c",
23-
"src/sonyflake_turbo/machine_ids.c"
30+
"src/sonyflake_turbo/machine_ids.c",
2431
],
2532
define_macros=define_macros,
2633
py_limited_api=py_limited_api,
34+
extra_compile_args=cflags,
2735
),
2836
],
2937
)

0 commit comments

Comments
 (0)