1
1
import os
2
- import shlex
3
2
from collections import defaultdict
4
3
5
4
import structlog
@@ -215,15 +214,13 @@ def checkout(self):
215
214
def post_checkout (self ):
216
215
commands = self .data .config .build .jobs .post_checkout
217
216
for command in commands :
218
- # TODO: we could make a helper `self.run(environment, command)`
219
- # that handles split and escape command
220
- self .vcs_environment .run (* shlex .split (command ), escape_command = False )
217
+ self .run_user_cmd (command )
221
218
222
219
# System dependencies (``build.apt_packages``)
223
220
def pre_system_dependencies (self ):
224
221
commands = self .data .config .build .jobs .pre_system_dependencies
225
222
for command in commands :
226
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
223
+ self .run_user_cmd ( command )
227
224
228
225
# NOTE: `system_dependencies` should not be possible to override by the
229
226
# user because it's executed as ``RTD_DOCKER_USER`` (e.g. ``root``) user.
@@ -263,37 +260,37 @@ def system_dependencies(self):
263
260
def post_system_dependencies (self ):
264
261
commands = self .data .config .build .jobs .post_system_dependencies
265
262
for command in commands :
266
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
263
+ self .run_user_cmd ( command )
267
264
268
265
# Language environment
269
266
def pre_create_environment (self ):
270
267
commands = self .data .config .build .jobs .pre_create_environment
271
268
for command in commands :
272
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
269
+ self .run_user_cmd ( command )
273
270
274
271
def create_environment (self ):
275
272
commands = [] # self.data.config.build.jobs.create_environment
276
273
for command in commands :
277
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
274
+ self .run_user_cmd ( command )
278
275
279
276
if not commands :
280
277
self .language_environment .setup_base ()
281
278
282
279
def post_create_environment (self ):
283
280
commands = self .data .config .build .jobs .post_create_environment
284
281
for command in commands :
285
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
282
+ self .run_user_cmd ( command )
286
283
287
284
# Install
288
285
def pre_install (self ):
289
286
commands = self .data .config .build .jobs .pre_install
290
287
for command in commands :
291
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
288
+ self .run_user_cmd ( command )
292
289
293
290
def install (self ):
294
291
commands = [] # self.data.config.build.jobs.install
295
292
for command in commands :
296
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
293
+ self .run_user_cmd ( command )
297
294
298
295
if not commands :
299
296
self .language_environment .install_core_requirements ()
@@ -302,19 +299,19 @@ def install(self):
302
299
def post_install (self ):
303
300
commands = self .data .config .build .jobs .post_install
304
301
for command in commands :
305
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
302
+ self .run_user_cmd ( command )
306
303
307
304
# Build
308
305
def pre_build (self ):
309
306
commands = self .data .config .build .jobs .pre_build
310
307
for command in commands :
311
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
308
+ self .run_user_cmd ( command )
312
309
313
310
def build_html (self ):
314
311
commands = [] # self.data.config.build.jobs.build.html
315
312
if commands :
316
313
for command in commands :
317
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
314
+ self .run_user_cmd ( command )
318
315
return True
319
316
320
317
return self .build_docs_class (self .data .config .doctype )
@@ -326,7 +323,7 @@ def build_pdf(self):
326
323
commands = [] # self.data.config.build.jobs.build.pdf
327
324
if commands :
328
325
for command in commands :
329
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
326
+ self .run_user_cmd ( command )
330
327
return True
331
328
332
329
# Mkdocs has no pdf generation currently.
@@ -345,7 +342,7 @@ def build_htmlzip(self):
345
342
commands = [] # self.data.config.build.jobs.build.htmlzip
346
343
if commands :
347
344
for command in commands :
348
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
345
+ self .run_user_cmd ( command )
349
346
return True
350
347
351
348
# We don't generate a zip for mkdocs currently.
@@ -360,7 +357,7 @@ def build_epub(self):
360
357
commands = [] # self.data.config.build.jobs.build.epub
361
358
if commands :
362
359
for command in commands :
363
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
360
+ self .run_user_cmd ( command )
364
361
return True
365
362
366
363
# Mkdocs has no epub generation currently.
@@ -371,12 +368,16 @@ def build_epub(self):
371
368
def post_build (self ):
372
369
commands = self .data .config .build .jobs .post_build
373
370
for command in commands :
374
- self .build_environment . run ( * shlex . split ( command ), escape_command = False )
371
+ self .run_user_cmd ( command )
375
372
376
373
# Helpers
377
374
#
378
375
# TODO: move somewhere or change names to make them private or something to
379
376
# easily differentiate them from the normal flow.
377
+ def run_user_cmd (self , cmd ):
378
+ cwd = self .data .project .checkout_path (self .data .version .slug )
379
+ self .build_environment .run (cmd .split (), escape_command = False , cwd = cwd )
380
+
380
381
def build_docs_class (self , builder_class ):
381
382
"""
382
383
Build docs with additional doc backends.
0 commit comments