Skip to content

Commit 04901b3

Browse files
authored
Merge pull request #4611 from rtfd/agj/add-cwd
Add cwd to subprocess calls
2 parents cbfc791 + c311c58 commit 04901b3

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

readthedocs/doc_builder/backends/sphinx.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,13 @@ def move(self, **__):
310310
self.target,
311311
'{}.epub'.format(self.project.slug),
312312
)
313-
self.run('mv', '-f', from_file, to_file)
313+
self.run(
314+
'mv',
315+
'-f',
316+
from_file,
317+
to_file,
318+
cwd=self.project.checkout_path(self.version.slug),
319+
)
314320

315321

316322
class LatexBuildCommand(BuildCommand):
@@ -429,4 +435,10 @@ def move(self, **__):
429435
if from_file:
430436
to_file = os.path.join(
431437
self.target, '{}.pdf'.format(self.project.slug))
432-
self.run('mv', '-f', from_file, to_file)
438+
self.run(
439+
'mv',
440+
'-f',
441+
from_file,
442+
to_file,
443+
cwd=self.project.checkout_path(self.version.slug),
444+
)

readthedocs/doc_builder/python_environments.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def install_package(self):
7878
self.project.pip_cache_path,
7979
'.{0}'.format(extra_req_param),
8080
cwd=self.checkout_path,
81-
bin_path=self.venv_bin()
81+
bin_path=self.venv_bin(),
8282
)
8383
elif self.config.python.install_with_setup:
8484
self.build_env.run(
@@ -87,7 +87,7 @@ def install_package(self):
8787
'install',
8888
'--force',
8989
cwd=self.checkout_path,
90-
bin_path=self.venv_bin()
90+
bin_path=self.venv_bin(),
9191
)
9292

9393
def venv_bin(self, filename=None):
@@ -214,6 +214,7 @@ def setup_base(self):
214214
'--no-download',
215215
env_path,
216216
bin_path=None, # Don't use virtualenv bin that doesn't exist yet
217+
cwd=self.checkout_path,
217218
)
218219

219220
def install_core_requirements(self):
@@ -267,7 +268,8 @@ def install_core_requirements(self):
267268
cmd.extend(requirements)
268269
self.build_env.run(
269270
*cmd,
270-
bin_path=self.venv_bin()
271+
bin_path=self.venv_bin(),
272+
cwd=self.checkout_path # noqa - no comma here in py27 :/
271273
)
272274

273275
def install_user_requirements(self):
@@ -302,7 +304,7 @@ def install_user_requirements(self):
302304
self.build_env.run(
303305
*args,
304306
cwd=self.checkout_path,
305-
bin_path=self.venv_bin()
307+
bin_path=self.venv_bin() # noqa - no comma here in py27 :/
306308
)
307309

308310

@@ -334,6 +336,7 @@ def setup_base(self):
334336
'--file',
335337
self.config.conda.environment,
336338
bin_path=None, # Don't use conda bin that doesn't exist yet
339+
cwd=self.checkout_path,
337340
)
338341

339342
def install_core_requirements(self):
@@ -364,7 +367,8 @@ def install_core_requirements(self):
364367
]
365368
cmd.extend(requirements)
366369
self.build_env.run(
367-
*cmd
370+
*cmd,
371+
cwd=self.checkout_path # noqa - no comma here in py27 :/
368372
)
369373

370374
pip_cmd = [
@@ -378,7 +382,8 @@ def install_core_requirements(self):
378382
pip_cmd.extend(pip_requirements)
379383
self.build_env.run(
380384
*pip_cmd,
381-
bin_path=self.venv_bin()
385+
bin_path=self.venv_bin(),
386+
cwd=self.checkout_path # noqa - no comma here in py27 :/
382387
)
383388

384389
def install_user_requirements(self):

readthedocs/rtd_tests/tests/test_doc_building.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1335,8 +1335,8 @@ def test_install_core_requirements_sphinx_conda(self, checkout_path):
13351335
args_conda.extend(conda_requirements)
13361336

13371337
self.build_env_mock.run.assert_has_calls([
1338-
mock.call(*args_conda),
1339-
mock.call(*args_pip, bin_path=mock.ANY)
1338+
mock.call(*args_conda, cwd=mock.ANY),
1339+
mock.call(*args_pip, bin_path=mock.ANY, cwd=mock.ANY)
13401340
])
13411341

13421342
@patch('readthedocs.projects.models.Project.checkout_path')
@@ -1374,8 +1374,8 @@ def test_install_core_requirements_mkdocs_conda(self, checkout_path):
13741374
args_conda.extend(conda_requirements)
13751375

13761376
self.build_env_mock.run.assert_has_calls([
1377-
mock.call(*args_conda),
1378-
mock.call(*args_pip, bin_path=mock.ANY)
1377+
mock.call(*args_conda, cwd=mock.ANY),
1378+
mock.call(*args_pip, bin_path=mock.ANY, cwd=mock.ANY)
13791379
])
13801380

13811381
@patch('readthedocs.projects.models.Project.checkout_path')

0 commit comments

Comments
 (0)