1111import sysconfig
1212import tempfile
1313from collections import UserDict
14- from dataclasses import dataclass
14+ from dataclasses import KW_ONLY , dataclass
1515from typing import TYPE_CHECKING
1616
1717import colorama
2222colorama .just_fix_windows_console ()
2323
2424
25- @dataclass ( init = False ) # Python 3.10+: Use "_: KW_ONLY"
25+ @dataclass
2626class Config :
2727 """
2828 Set of user-specified configuration options for setting up the import logic of :class:`JITCompileFinder`.
@@ -33,14 +33,16 @@ class Config:
3333 project_directory : pathlib .Path | str
3434 """The absolute path to the root directory of the C++/CUDA extension containing the root ``CMakeLists.txt`` file."""
3535
36- build_directory : pathlib .Path | str | None
36+ build_directory : pathlib .Path | str | None = None
3737 """
3838 An optional absolute path to a build directory.
3939
4040 If not specified, the build will be placed in the temporary directory of the operating system.
4141 """
4242
43- clean_build : bool
43+ _ : KW_ONLY
44+
45+ clean_build : bool = False
4446 """
4547 Whether to remove all cached files of previous builds from the build directory.
4648
@@ -53,13 +55,13 @@ class Config:
5355 :class:`ResolvedConfig`.
5456 """
5557
56- build_type : str
58+ build_type : str = "RelWithDebInfo"
5759 """The build type passed to CMake to compile the extension."""
5860
59- cmake_options : dict [str , str ] | None
61+ cmake_options : dict [str , str ] | None = None
6062 """Additional CMake options to pass to the project when JIT compiling."""
6163
62- stubs_directory : pathlib .Path | str | None
64+ stubs_directory : pathlib .Path | str | None = None
6365 """
6466 An optional absolute path to the directory where stub files of the extension should be generated.
6567
@@ -68,7 +70,7 @@ class Config:
6870 if set to ``None``.
6971 """
7072
71- stubs_invalid_ok : bool
73+ stubs_invalid_ok : bool = False
7274 """
7375 Whether to accept invalid stubs and skip raising an error.
7476
@@ -79,7 +81,7 @@ class Config:
7981 :class:`ResolvedConfig`.
8082 """
8183
82- verbose : bool
84+ verbose : bool = False
8385 """
8486 Whether to enable printing the full log of the JIT compilation.
8587
@@ -92,36 +94,17 @@ class Config:
9294 :class:`ResolvedConfig`.
9395 """
9496
95- def __init__ (
96- self : Self ,
97- project_directory : pathlib .Path | str ,
98- build_directory : pathlib .Path | str | None = None ,
99- * ,
100- clean_build : bool = False ,
101- build_type : str = "RelWithDebInfo" ,
102- cmake_options : dict [str , str ] | None = None ,
103- stubs_directory : pathlib .Path | str | None = None ,
104- stubs_invalid_ok : bool = False ,
105- verbose : bool = False ,
106- ) -> None :
107- self .project_directory = project_directory
108- self .build_directory = build_directory
109- self .clean_build = clean_build
110- self .build_type = build_type
111- self .cmake_options = cmake_options
112- self .stubs_directory = stubs_directory
113- self .stubs_invalid_ok = stubs_invalid_ok
114- self .verbose = verbose
115-
116-
117- @dataclass (init = False ) # Python 3.10+: Use "kw_only=True"
97+
98+ @dataclass
11899class ResolvedConfig :
119100 """
120101 Set of resolved configuration options that is **actually used** in the import logic of :class:`JITCompileFinder`.
121102
122103 This has been resolved from :class:`Config` and from the environment variables.
123104 """
124105
106+ _ : KW_ONLY
107+
125108 full_project_directory : pathlib .Path
126109 """The full absolute path to the project directory."""
127110
@@ -146,27 +129,6 @@ class ResolvedConfig:
146129 verbose : bool
147130 """Flag to enable printing the full log of the JIT compilation."""
148131
149- def __init__ (
150- self : Self ,
151- * ,
152- full_project_directory : pathlib .Path ,
153- full_build_directory : pathlib .Path ,
154- clean_build : bool ,
155- build_type : str ,
156- cmake_options : dict [str , str ],
157- full_stubs_directory : pathlib .Path | None ,
158- stubs_invalid_ok : bool ,
159- verbose : bool ,
160- ) -> None :
161- self .full_project_directory = full_project_directory
162- self .full_build_directory = full_build_directory
163- self .clean_build = clean_build
164- self .build_type = build_type
165- self .cmake_options = cmake_options
166- self .full_stubs_directory = full_stubs_directory
167- self .stubs_invalid_ok = stubs_invalid_ok
168- self .verbose = verbose
169-
170132
171133class ConfigDict (UserDict [str , ResolvedConfig ]):
172134 """
0 commit comments