From b89badab65b969cb2e7bc4c405134c3d16414719 Mon Sep 17 00:00:00 2001 From: Anthony Johnson Date: Thu, 6 Sep 2018 00:04:04 -0600 Subject: [PATCH 1/2] Add cwd to subprocess calls We were assuming this path before, which defaulted to the path you executed django from on the host machine. The cwd was used in commands run on inside Docker however. On Linux dev environments, this path is most likely missing. By specifying paths, we will get paths that have been created inside the container. --- readthedocs/doc_builder/backends/sphinx.py | 16 ++++++++++++++-- readthedocs/doc_builder/python_environments.py | 11 ++++++++--- readthedocs/rtd_tests/tests/test_doc_building.py | 8 ++++---- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py index ba719cf6226..d1a7d1925f7 100644 --- a/readthedocs/doc_builder/backends/sphinx.py +++ b/readthedocs/doc_builder/backends/sphinx.py @@ -310,7 +310,13 @@ def move(self, **__): self.target, '{}.epub'.format(self.project.slug), ) - self.run('mv', '-f', from_file, to_file) + self.run( + 'mv', + '-f', + from_file, + to_file, + cwd=self.project.checkout_path(self.version.slug), + ) class LatexBuildCommand(BuildCommand): @@ -429,4 +435,10 @@ def move(self, **__): if from_file: to_file = os.path.join( self.target, '{}.pdf'.format(self.project.slug)) - self.run('mv', '-f', from_file, to_file) + self.run( + 'mv', + '-f', + from_file, + to_file, + cwd=self.project.checkout_path(self.version.slug), + ) diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index 7ee1e2f676c..367923a27f8 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -214,6 +214,7 @@ def setup_base(self): '--no-download', env_path, bin_path=None, # Don't use virtualenv bin that doesn't exist yet + cwd=self.checkout_path, ) def install_core_requirements(self): @@ -267,7 +268,8 @@ def install_core_requirements(self): cmd.extend(requirements) self.build_env.run( *cmd, - bin_path=self.venv_bin() + bin_path=self.venv_bin(), + cwd=self.checkout_path, ) def install_user_requirements(self): @@ -334,6 +336,7 @@ def setup_base(self): '--file', self.config.conda.environment, bin_path=None, # Don't use conda bin that doesn't exist yet + cwd=self.checkout_path, ) def install_core_requirements(self): @@ -364,7 +367,8 @@ def install_core_requirements(self): ] cmd.extend(requirements) self.build_env.run( - *cmd + *cmd, + cwd=self.checkout_path, ) pip_cmd = [ @@ -378,7 +382,8 @@ def install_core_requirements(self): pip_cmd.extend(pip_requirements) self.build_env.run( *pip_cmd, - bin_path=self.venv_bin() + bin_path=self.venv_bin(), + cwd=self.checkout_path, ) def install_user_requirements(self): diff --git a/readthedocs/rtd_tests/tests/test_doc_building.py b/readthedocs/rtd_tests/tests/test_doc_building.py index 971d0f69659..d85e3a07038 100644 --- a/readthedocs/rtd_tests/tests/test_doc_building.py +++ b/readthedocs/rtd_tests/tests/test_doc_building.py @@ -1335,8 +1335,8 @@ def test_install_core_requirements_sphinx_conda(self, checkout_path): args_conda.extend(conda_requirements) self.build_env_mock.run.assert_has_calls([ - mock.call(*args_conda), - mock.call(*args_pip, bin_path=mock.ANY) + mock.call(*args_conda, cwd=mock.ANY), + mock.call(*args_pip, bin_path=mock.ANY, cwd=mock.ANY) ]) @patch('readthedocs.projects.models.Project.checkout_path') @@ -1374,8 +1374,8 @@ def test_install_core_requirements_mkdocs_conda(self, checkout_path): args_conda.extend(conda_requirements) self.build_env_mock.run.assert_has_calls([ - mock.call(*args_conda), - mock.call(*args_pip, bin_path=mock.ANY) + mock.call(*args_conda, cwd=mock.ANY), + mock.call(*args_pip, bin_path=mock.ANY, cwd=mock.ANY) ]) @patch('readthedocs.projects.models.Project.checkout_path') From c311c583a85870b47be36ed5cb20715d00aad0f8 Mon Sep 17 00:00:00 2001 From: Anthony Johnson Date: Thu, 6 Sep 2018 09:42:34 -0600 Subject: [PATCH 2/2] Fix py27 oddity with trailing commas --- readthedocs/doc_builder/python_environments.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index 367923a27f8..1c79c8bd9f3 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -78,7 +78,7 @@ def install_package(self): self.project.pip_cache_path, '.{0}'.format(extra_req_param), cwd=self.checkout_path, - bin_path=self.venv_bin() + bin_path=self.venv_bin(), ) elif self.config.python.install_with_setup: self.build_env.run( @@ -87,7 +87,7 @@ def install_package(self): 'install', '--force', cwd=self.checkout_path, - bin_path=self.venv_bin() + bin_path=self.venv_bin(), ) def venv_bin(self, filename=None): @@ -269,7 +269,7 @@ def install_core_requirements(self): self.build_env.run( *cmd, bin_path=self.venv_bin(), - cwd=self.checkout_path, + cwd=self.checkout_path # noqa - no comma here in py27 :/ ) def install_user_requirements(self): @@ -304,7 +304,7 @@ def install_user_requirements(self): self.build_env.run( *args, cwd=self.checkout_path, - bin_path=self.venv_bin() + bin_path=self.venv_bin() # noqa - no comma here in py27 :/ ) @@ -368,7 +368,7 @@ def install_core_requirements(self): cmd.extend(requirements) self.build_env.run( *cmd, - cwd=self.checkout_path, + cwd=self.checkout_path # noqa - no comma here in py27 :/ ) pip_cmd = [ @@ -383,7 +383,7 @@ def install_core_requirements(self): self.build_env.run( *pip_cmd, bin_path=self.venv_bin(), - cwd=self.checkout_path, + cwd=self.checkout_path # noqa - no comma here in py27 :/ ) def install_user_requirements(self):