Skip to content

Commit ade1885

Browse files
committed
Use implied version in all python env logic.
1 parent bc45f83 commit ade1885

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

readthedocs/doc_builder/python_environments.py

+17-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from django.conf import settings
66

7-
from readthedocs.builds.constants import LATEST
87
from readthedocs.doc_builder.config import ConfigWrapper
98
from readthedocs.doc_builder.loader import get_builder_class
109
from readthedocs.projects.constants import LOG_TEMPLATE
@@ -35,7 +34,7 @@ def delete_existing_build_dir(self):
3534

3635
# Handle deleting old build dir
3736
build_dir = os.path.join(
38-
self.venv_path(version=self.version.slug),
37+
self.venv_path(),
3938
'build')
4039
if os.path.exists(build_dir):
4140
self._log('Removing existing build directory')
@@ -47,14 +46,14 @@ def install_package(self):
4746
if getattr(settings, 'USE_PIP_INSTALL', False):
4847
self.build_env.run(
4948
'python',
50-
self.venv_bin(version=self.version.slug, filename='pip'),
49+
self.venv_bin(filename='pip'),
5150
'install',
5251
'--ignore-installed',
5352
'--cache-dir',
5453
self.project.pip_cache_path,
5554
'.',
5655
cwd=self.checkout_path,
57-
bin_path=self.venv_bin(version=self.version.slug)
56+
bin_path=self.venv_bin()
5857
)
5958
else:
6059
self.build_env.run(
@@ -63,32 +62,31 @@ def install_package(self):
6362
'install',
6463
'--force',
6564
cwd=self.checkout_path,
66-
bin_path=self.venv_bin(version=self.version.slug)
65+
bin_path=self.venv_bin()
6766
)
6867

69-
def venv_bin(self, version=LATEST, filename=None):
68+
def venv_bin(self, filename=None):
7069
"""Return path to the virtualenv bin path, or a specific binary
7170
72-
:param version: Version slug to use in path name
7371
:param filename: If specified, add this filename to the path return
7472
:returns: Path to virtualenv bin or filename in virtualenv bin
7573
"""
76-
parts = [self.venv_path(version), 'bin']
74+
parts = [self.venv_path(), 'bin']
7775
if filename is not None:
7876
parts.append(filename)
7977
return os.path.join(*parts)
8078

8179

8280
class Virtualenv(PythonEnvironment):
8381

84-
def venv_path(self, version=LATEST):
85-
return os.path.join(self.project.doc_path, 'envs', version)
82+
def venv_path(self):
83+
return os.path.join(self.project.doc_path, 'envs', self.version.slug)
8684

8785
def setup_base(self):
8886
site_packages = '--no-site-packages'
8987
if self.config.use_system_site_packages:
9088
site_packages = '--system-site-packages'
91-
env_path = self.venv_path(version=self.version.slug)
89+
env_path = self.venv_path()
9290
self.build_env.run(
9391
self.config.python_interpreter,
9492
'-mvirtualenv',
@@ -114,7 +112,7 @@ def install_core_requirements(self):
114112

115113
cmd = [
116114
'python',
117-
self.venv_bin(version=self.version.slug, filename='pip'),
115+
self.venv_bin(filename='pip'),
118116
'install',
119117
'--use-wheel',
120118
'-U',
@@ -130,7 +128,7 @@ def install_core_requirements(self):
130128
cmd.extend(requirements)
131129
self.build_env.run(
132130
*cmd,
133-
bin_path=self.venv_bin(version=self.version.slug)
131+
bin_path=self.venv_bin()
134132
)
135133

136134
def install_user_requirements(self):
@@ -149,21 +147,21 @@ def install_user_requirements(self):
149147
if requirements_file_path:
150148
self.build_env.run(
151149
'python',
152-
self.venv_bin(version=self.version.slug, filename='pip'),
150+
self.venv_bin(filename='pip'),
153151
'install',
154152
'--exists-action=w',
155153
'--cache-dir',
156154
self.project.pip_cache_path,
157155
'-r{0}'.format(requirements_file_path),
158156
cwd=self.checkout_path,
159-
bin_path=self.venv_bin(version=self.version.slug)
157+
bin_path=self.venv_bin()
160158
)
161159

162160

163161
class Conda(PythonEnvironment):
164162

165-
def venv_path(self, version=LATEST):
166-
return os.path.join(self.project.doc_path, 'conda', version)
163+
def venv_path(self):
164+
return os.path.join(self.project.doc_path, 'conda', self.version.slug)
167165

168166
def setup_base(self):
169167
conda_env_path = os.path.join(self.project.doc_path, 'conda')
@@ -220,7 +218,7 @@ def install_core_requirements(self):
220218

221219
pip_cmd = [
222220
'python',
223-
self.venv_bin(version=self.version.slug, filename='pip'),
221+
self.venv_bin(filename='pip'),
224222
'install',
225223
'-U',
226224
'--cache-dir',
@@ -229,7 +227,7 @@ def install_core_requirements(self):
229227
pip_cmd.extend(pip_requirements)
230228
self.build_env.run(
231229
*pip_cmd,
232-
bin_path=self.venv_bin(version=self.version.slug)
230+
bin_path=self.venv_bin()
233231
)
234232

235233
def install_user_requirements(self):

0 commit comments

Comments
 (0)