Skip to content

Commit 9dfa0de

Browse files
committed
Better defaults and some cleanup on Project.venv_bin
1 parent 23d2859 commit 9dfa0de

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

readthedocs/doc_builder/backends/mkdocs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def build(self, **kwargs):
141141
cmd_ret = self.run(
142142
*build_command,
143143
cwd=checkout_path,
144-
bin_path=self.project.venv_bin(version=self.version.slug, bin=None)
144+
bin_path=self.project.venv_bin(version=self.version.slug)
145145
)
146146
return cmd_ret.successful
147147

readthedocs/doc_builder/backends/sphinx.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def build(self, **kwargs):
142142
cmd_ret = self.run(
143143
*build_command,
144144
cwd=project.conf_dir(self.version.slug),
145-
bin_path=project.venv_bin(version=self.version.slug, bin=None)
145+
bin_path=project.venv_bin(version=self.version.slug)
146146
)
147147
return cmd_ret.successful
148148

@@ -244,7 +244,7 @@ def build(self, **kwargs):
244244
'.',
245245
'_build/latex',
246246
cwd=cwd,
247-
bin_path=self.project.venv_bin(version=self.version.slug, bin=None)
247+
bin_path=self.project.venv_bin(version=self.version.slug)
248248
)
249249
latex_cwd = os.path.join(cwd, '_build', 'latex')
250250
tex_files = glob(os.path.join(latex_cwd, '*.tex'))

readthedocs/projects/models.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -484,16 +484,17 @@ def single_version_symlink_path(self):
484484
# End symlink paths
485485
#
486486

487-
def venv_bin(self, version=LATEST, bin='python'):
487+
def venv_bin(self, version=LATEST, bin=None):
488488
"""Return path to the virtualenv bin path, or a specific binary
489489
490-
By default, return the path to the ``python`` binary in the virtual
491-
environment path. If ``bin`` is :py:data:`None`, then return the path to
492-
the virtual env path.
490+
If ``bin`` is :py:data:`None`, then return the path to the virtual env
491+
path, otherwise, return the path to the executable ``bin`` in the
492+
virtual env ``bin`` path
493493
"""
494-
if bin is None:
495-
bin = ''
496-
return os.path.join(self.venv_path(version), 'bin', bin)
494+
parts = [self.venv_path(version), 'bin']
495+
if bin is not None:
496+
parts.append(bin)
497+
return os.path.join(*parts)
497498

498499
def full_doc_path(self, version=LATEST):
499500
"""

readthedocs/projects/tasks.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def setup_environment(self):
283283
cmd.extend(requirements)
284284
self.build_env.run(
285285
*cmd,
286-
bin_path=self.project.venv_bin(version=self.version.slug, bin=None)
286+
bin_path=self.project.venv_bin(version=self.version.slug)
287287
)
288288

289289
# Handle requirements
@@ -308,8 +308,7 @@ def setup_environment(self):
308308
'--exists-action=w',
309309
'-r{0}'.format(requirements_file_path),
310310
cwd=checkout_path,
311-
bin_path=self.project.venv_bin(version=self.version.slug,
312-
bin=None)
311+
bin_path=self.project.venv_bin(version=self.version.slug)
313312
)
314313

315314
# Handle setup.py
@@ -324,8 +323,7 @@ def setup_environment(self):
324323
'--ignore-installed',
325324
'.',
326325
cwd=checkout_path,
327-
bin_path=self.project.venv_bin(version=self.version.slug,
328-
bin=None)
326+
bin_path=self.project.venv_bin(version=self.version.slug)
329327
)
330328
else:
331329
self.build_env.run(
@@ -334,8 +332,7 @@ def setup_environment(self):
334332
'install',
335333
'--force',
336334
cwd=checkout_path,
337-
bin_path=self.project.venv_bin(version=self.version.slug,
338-
bin=None)
335+
bin_path=self.project.venv_bin(version=self.version.slug)
339336
)
340337

341338
def build_docs(self):

0 commit comments

Comments
 (0)