20
20
# The name must be the _single_ output extension from the CMake build.
21
21
# If you need multiple extensions, see scikit-build.
22
22
class CMakeExtension (Extension ):
23
- def __init__ (self , name , sourcedir = "" ):
24
- Extension .__init__ (self , name , sources = [])
25
- self .sourcedir = os .path . abspath ( sourcedir )
23
+ def __init__ (self , name : str , sourcedir : str = "" ) -> None :
24
+ super () .__init__ (name , sources = [])
25
+ self .sourcedir = os .fspath ( Path ( sourcedir ). resolve () )
26
26
27
27
28
28
class CMakeBuild (build_ext ):
29
29
def build_extension (self , ext : CMakeExtension ) -> None :
30
30
# Must be in this form due to bug in .resolve() only fixed in Python 3.10+
31
- ext_fullpath = Path .cwd () / self .get_ext_fullpath (ext .name ) # type: ignore[no-untyped-call]
31
+ ext_fullpath = Path .cwd () / self .get_ext_fullpath (ext .name )
32
32
extdir = ext_fullpath .parent .resolve ()
33
33
34
34
# Using this requires trailing slash for auto-detection & inclusion of
@@ -56,7 +56,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
56
56
cmake_args += [item for item in os .environ ["CMAKE_ARGS" ].split (" " ) if item ]
57
57
58
58
# In this example, we pass in the version to C++. You might not need to.
59
- cmake_args += [f"-DEXAMPLE_VERSION_INFO={ self .distribution .get_version ()} " ] # type: ignore[attr-defined]
59
+ cmake_args += [f"-DEXAMPLE_VERSION_INFO={ self .distribution .get_version ()} " ]
60
60
61
61
if self .compiler .compiler_type != "msvc" :
62
62
# Using Ninja-build since it a) is available as a wheel and b)
@@ -66,7 +66,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
66
66
# 3.15+.
67
67
if not cmake_generator or cmake_generator == "Ninja" :
68
68
try :
69
- import ninja # noqa: F401
69
+ import ninja
70
70
71
71
ninja_executable_path = Path (ninja .BIN_DIR ) / "ninja"
72
72
cmake_args += [
@@ -77,7 +77,6 @@ def build_extension(self, ext: CMakeExtension) -> None:
77
77
pass
78
78
79
79
else :
80
-
81
80
# Single config generators are handled "normally"
82
81
single_config = any (x in cmake_generator for x in {"NMake" , "Ninja" })
83
82
@@ -117,10 +116,10 @@ def build_extension(self, ext: CMakeExtension) -> None:
117
116
build_temp .mkdir (parents = True )
118
117
119
118
subprocess .run (
120
- ["cmake" , ext .sourcedir ] + cmake_args , cwd = build_temp , check = True
119
+ ["cmake" , ext .sourcedir , * cmake_args ] , cwd = build_temp , check = True
121
120
)
122
121
subprocess .run (
123
- ["cmake" , "--build" , "." ] + build_args , cwd = build_temp , check = True
122
+ ["cmake" , "--build" , "." , * build_args ] , cwd = build_temp , check = True
124
123
)
125
124
126
125
@@ -157,7 +156,7 @@ def __getattribute__(self, name):
157
156
'codecov>=2.1.9'
158
157
]
159
158
160
- python_requires = '>=3.6, <3.12 '
159
+ python_requires = '>=3.6, <3.13 '
161
160
162
161
setup (
163
162
name = package_info .__package_name__ ,
0 commit comments