Skip to content

Commit 66fe0a7

Browse files
committed
Refactor: make venv_bin more concrete to match venv/conda
1 parent fb83a4e commit 66fe0a7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

readthedocs/doc_builder/python_environments.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,17 @@ def install_package(self, install):
8989
bin_path=self.venv_bin(),
9090
)
9191

92-
def venv_bin(self, filename=None, conda=False):
92+
def venv_bin(self, prefixes, filename=None):
9393
"""
9494
Return path to the virtualenv bin path, or a specific binary.
9595
9696
:param filename: If specified, add this filename to the path return
97+
:param prefix: List of path prefixes to include in the resulting path
9798
:returns: Path to virtualenv bin or filename in virtualenv bin
9899
"""
99-
parts = ["$READTHEDOCS_VIRTUALENV_PATH", "bin"]
100-
if conda:
101-
parts = ["$CONDA_ENVS_PATH", "$CONDA_DEFAULT_ENV", "bin"]
102-
103100
if filename is not None:
104-
parts.append(filename)
105-
return os.path.join(*parts)
101+
prefixes.append(filename)
102+
return os.path.join(*prefixes)
106103

107104

108105
class Virtualenv(PythonEnvironment):
@@ -113,6 +110,11 @@ class Virtualenv(PythonEnvironment):
113110
.. _virtualenv: https://virtualenv.pypa.io/
114111
"""
115112

113+
# pylint: disable=arguments-differ
114+
def venv_bin(self, filename=None):
115+
prefixes = ["$READTHEDOCS_VIRTUALENV_PATH", "bin"]
116+
super().venv_bin(prefixes, filename=filename)
117+
116118
def setup_base(self):
117119
"""
118120
Create a virtualenv, invoking ``python -mvirtualenv``.
@@ -320,7 +322,8 @@ class Conda(PythonEnvironment):
320322

321323
# pylint: disable=arguments-differ
322324
def venv_bin(self, filename=None):
323-
return super().venv_bin(filename=filename, conda=True)
325+
prefixes = ["$CONDA_ENVS_PATH", "$CONDA_DEFAULT_ENV", "bin"]
326+
return super().venv_bin(prefixes, filename=filename)
324327

325328
def conda_bin_name(self):
326329
"""

0 commit comments

Comments
 (0)