@@ -65,6 +65,7 @@ def check_initial_contents(filename):
65
65
[
66
66
"pyproject_dir" ,
67
67
"dependencies_file" ,
68
+ "write_dependencies_file" ,
68
69
"cuda_version" ,
69
70
"cuda_suffix" ,
70
71
"cuda_python_requirement" ,
@@ -75,6 +76,7 @@ def check_initial_contents(filename):
75
76
(
76
77
"." ,
77
78
"dependencies.yaml" ,
79
+ True ,
78
80
("11" , "5" ),
79
81
"-cu11" ,
80
82
"cuda-python>=11.5,<11.6.dev0" ,
@@ -84,6 +86,7 @@ def check_initial_contents(filename):
84
86
(
85
87
"." ,
86
88
"dependencies.yaml" ,
89
+ True ,
87
90
("11" , "5" ),
88
91
"-cu11" ,
89
92
"cuda-python>=11.5,<11.6.dev0" ,
@@ -93,17 +96,29 @@ def check_initial_contents(filename):
93
96
(
94
97
"python" ,
95
98
"../dependencies.yaml" ,
99
+ True ,
96
100
("12" , "1" ),
97
101
"-cu12" ,
98
102
"cuda-python>=12.1,<12.2.dev0" ,
99
103
"arch=ppc64" ,
100
104
"some-ppc-package" ,
101
105
),
106
+ (
107
+ "." ,
108
+ "dependencies.yaml" ,
109
+ False ,
110
+ ("11" , "5" ),
111
+ "-cu11" ,
112
+ None ,
113
+ "arch=aarch64" ,
114
+ None ,
115
+ ),
102
116
],
103
117
)
104
118
def test_edit_pyproject (
105
119
pyproject_dir ,
106
120
dependencies_file ,
121
+ write_dependencies_file ,
107
122
cuda_version ,
108
123
cuda_suffix ,
109
124
cuda_python_requirement ,
@@ -129,86 +144,87 @@ def test_edit_pyproject(
129
144
with open ("pyproject.toml" , "w" ) as f :
130
145
f .write (original_contents )
131
146
132
- with open (dependencies_file , "w" ) as f :
133
- f .write (
134
- dedent (
135
- f"""\
136
- files:
137
- project:
138
- output: pyproject
139
- includes:
140
- - project
141
- - arch
142
- pyproject_dir: { pyproject_dir }
143
- matrix:
144
- cuda: ["11.5"]
145
- arch: ["x86_64"]
146
- extras:
147
- table: project
148
- build_system:
149
- output: pyproject
150
- includes:
151
- - build_system
152
- pyproject_dir: { pyproject_dir }
153
- extras:
154
- table: build-system
155
- other_project:
156
- output: pyproject
157
- includes:
158
- - bad
159
- pyproject_dir: python_bad
160
- extras:
161
- table: project
162
- conda:
163
- output: conda
164
- includes:
165
- - bad
166
- dependencies:
167
- project:
168
- common:
169
- - output_types: [pyproject]
170
- packages:
171
- - tomli
172
- specific:
173
- - output_types: [pyproject]
174
- matrices:
175
- - matrix:
176
- cuda: "11.5"
177
- packages:
178
- - cuda-python>=11.5,<11.6.dev0
179
- - matrix:
180
- cuda: "12.1"
181
- packages:
182
- - cuda-python>=12.1,<12.2.dev0
183
- build_system:
184
- common:
185
- - output_types: [pyproject]
186
- packages:
187
- - scikit-build-core
188
- arch:
189
- specific:
190
- - output_types: [pyproject]
191
- matrices:
192
- - matrix:
193
- arch: x86_64
147
+ if write_dependencies_file :
148
+ with open (dependencies_file , "w" ) as f :
149
+ f .write (
150
+ dedent (
151
+ f"""\
152
+ files:
153
+ project:
154
+ output: pyproject
155
+ includes:
156
+ - project
157
+ - arch
158
+ pyproject_dir: { pyproject_dir }
159
+ matrix:
160
+ cuda: ["11.5"]
161
+ arch: ["x86_64"]
162
+ extras:
163
+ table: project
164
+ build_system:
165
+ output: pyproject
166
+ includes:
167
+ - build_system
168
+ pyproject_dir: { pyproject_dir }
169
+ extras:
170
+ table: build-system
171
+ other_project:
172
+ output: pyproject
173
+ includes:
174
+ - bad
175
+ pyproject_dir: python_bad
176
+ extras:
177
+ table: project
178
+ conda:
179
+ output: conda
180
+ includes:
181
+ - bad
182
+ dependencies:
183
+ project:
184
+ common:
185
+ - output_types: [pyproject]
194
186
packages:
195
- - some-x86-package
196
- - matrix:
197
- arch: aarch64
187
+ - tomli
188
+ specific:
189
+ - output_types: [pyproject]
190
+ matrices:
191
+ - matrix:
192
+ cuda: "11.5"
193
+ packages:
194
+ - cuda-python>=11.5,<11.6.dev0
195
+ - matrix:
196
+ cuda: "12.1"
197
+ packages:
198
+ - cuda-python>=12.1,<12.2.dev0
199
+ build_system:
200
+ common:
201
+ - output_types: [pyproject]
198
202
packages:
199
- - some-arm-package
200
- - matrix:
201
- arch: ppc64
203
+ - scikit-build-core
204
+ arch:
205
+ specific:
206
+ - output_types: [pyproject]
207
+ matrices:
208
+ - matrix:
209
+ arch: x86_64
210
+ packages:
211
+ - some-x86-package
212
+ - matrix:
213
+ arch: aarch64
214
+ packages:
215
+ - some-arm-package
216
+ - matrix:
217
+ arch: ppc64
218
+ packages:
219
+ - some-ppc-package
220
+ bad:
221
+ common:
222
+ - output_types: [pyproject, conda]
202
223
packages:
203
- - some-ppc-package
204
- bad:
205
- common:
206
- - output_types: [pyproject, conda]
207
- packages:
208
- - bad-package
209
- """
224
+ - bad-package
225
+ """
226
+ )
210
227
)
211
- )
212
228
config = Mock (
213
229
require_cuda = False ,
214
230
dependencies_file = dependencies_file ,
@@ -224,22 +240,34 @@ def test_edit_pyproject(
224
240
):
225
241
with _edit_pyproject (config ):
226
242
with open ("pyproject.toml" ) as f :
227
- assert f .read () == dedent (
228
- f"""\
229
- [project]
230
- name = "test-project{ cuda_suffix } "
231
- dependencies = [
232
- "{ cuda_python_requirement } ",
233
- "{ arch_requirement } ",
234
- "tomli",
235
- ]
236
-
237
- [build-system]
238
- requires = [
239
- "scikit-build-core",
240
- ]
241
- """
242
- )
243
+ if write_dependencies_file :
244
+ assert f .read () == dedent (
245
+ f"""\
246
+ [project]
247
+ name = "test-project{ cuda_suffix } "
248
+ dependencies = [
249
+ "{ cuda_python_requirement } ",
250
+ "{ arch_requirement } ",
251
+ "tomli",
252
+ ]
253
+
254
+ [build-system]
255
+ requires = [
256
+ "scikit-build-core",
257
+ ]
258
+ """
259
+ )
260
+ else :
261
+ assert f .read () == dedent (
262
+ f"""\
263
+ [project]
264
+ name = "test-project{ cuda_suffix } "
265
+ dependencies = []
266
+
267
+ [build-system]
268
+ requires = []
269
+ """
270
+ )
243
271
with open (".pyproject.toml.rapids-build-backend.bak" ) as f :
244
272
assert f .read () == original_contents
245
273
0 commit comments