Skip to content

Commit 757e9c4

Browse files
authored
Merge pull request #44 from adrientetar/modernize-build-and-add-win-arm64
Modernize build system and add Windows ARM64 wheel support
2 parents 154f1c1 + dd2f8ab commit 757e9c4

4 files changed

Lines changed: 12 additions & 28 deletions

File tree

.github/workflows/wheels.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
build_wheels:
13-
name: Build wheel ${{ matrix.os }}
13+
name: Build wheel ${{ matrix.os }} (${{ matrix.arch }})
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
fail-fast: false
@@ -24,6 +24,8 @@ jobs:
2424
arch: universal2
2525
- os: ubuntu-24.04-arm
2626
arch: aarch64
27+
- os: windows-latest
28+
arch: ARM64
2729
env:
2830
CIBW_ARCHS: ${{ matrix.arch }}
2931
# Skip

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ requires = [
44
"setuptools<72.2.0; platform_python_implementation == 'PyPy'",
55
"setuptools; platform_python_implementation != 'PyPy'",
66
"wheel",
7+
"packaging",
8+
"setuptools_scm",
79
"cython >= 0.28.5",
810
]
911
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@
44
from distutils import log
55
import os
66
import sys
7-
import pkg_resources
8-
from io import open
7+
from importlib.metadata import version as get_version, PackageNotFoundError
8+
from packaging.version import Version
99
import re
1010

11-
12-
argv = sys.argv[1:]
13-
needs_wheel = {"bdist_wheel"}.intersection(argv)
14-
wheel = ["wheel"] if needs_wheel else []
15-
1611
# check if minimum required Cython is available
1712
cython_version_re = re.compile(r'\s*"cython\s*>=\s*([0-9][0-9\w\.]*)\s*"')
1813
with open("pyproject.toml", "r", encoding="utf-8") as fp:
@@ -23,13 +18,11 @@
2318
break
2419
else:
2520
sys.exit("error: could not parse cython version from pyproject.toml")
21+
required_cython = "cython >= %s" % cython_min_version
2622
try:
27-
required_cython = "cython >= %s" % cython_min_version
28-
pkg_resources.require(required_cython)
29-
except pkg_resources.ResolutionError:
23+
with_cython = Version(get_version("cython")) >= Version(cython_min_version)
24+
except PackageNotFoundError:
3025
with_cython = False
31-
else:
32-
with_cython = True
3326

3427

3528
class cython_build_ext(_build_ext):
@@ -91,19 +84,11 @@ def run(self):
9184
_sdist.run(self)
9285

9386

94-
# need to include this for Visual Studio 2008 doesn't have stdint.h
95-
include_dirs = (
96-
[os.path.join(os.path.dirname(__file__), "vendor", "msinttypes")]
97-
if os.name == "nt" and sys.version_info < (3,)
98-
else []
99-
)
100-
10187
cython_modules = ["parser", "util", "writer", "_test"]
10288
extensions = [
10389
Extension(
10490
"openstep_plist." + mod,
10591
sources=["src/openstep_plist/%s.pyx" % mod],
106-
include_dirs=include_dirs,
10792
language="c++",
10893
extra_compile_args=["-std=c++11"] if sys.platform != "win32" else [],
10994
)
@@ -130,7 +115,6 @@ def run(self):
130115
include_package_data=True,
131116
exclude_package_data={"": ["*.cpp"]},
132117
ext_modules=extensions,
133-
setup_requires=["setuptools_scm"] + wheel,
134118
python_requires=">=3.8",
135119
cmdclass={"build_ext": cython_build_ext, "sdist": cython_sdist},
136120
zip_safe=False,

src/openstep_plist/util.pyx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
#cython: language_level=3
22
#distutils: define_macros=CYTHON_TRACE_NOGIL=1
33

4-
from cpython.version cimport PY_MAJOR_VERSION
54
from libc.stdint cimport uint16_t, uint32_t
6-
import sys
75

86

97
cdef inline unicode tounicode(s, encoding="ascii", errors="strict"):
108
if type(s) is unicode:
119
return <unicode>s
12-
elif PY_MAJOR_VERSION < 3 and isinstance(s, bytes):
13-
return (<bytes>s).decode(encoding, errors=errors)
1410
elif isinstance(s, unicode):
1511
return unicode(s)
1612
else:
@@ -19,9 +15,9 @@ cdef inline unicode tounicode(s, encoding="ascii", errors="strict"):
1915

2016
cdef inline object tostr(s, encoding="ascii", errors="strict"):
2117
if isinstance(s, bytes):
22-
return s if PY_MAJOR_VERSION < 3 else s.decode(encoding, errors=errors)
18+
return s.decode(encoding, errors=errors)
2319
elif isinstance(s, unicode):
24-
return s.encode(encoding, errors=errors) if PY_MAJOR_VERSION < 3 else s
20+
return s
2521
else:
2622
raise TypeError(f"Could not convert to str: {s!r}")
2723

0 commit comments

Comments
 (0)