@@ -75,9 +75,19 @@ def delete_existing_venv_dir(self):
75
75
shutil .rmtree (venv_dir )
76
76
77
77
def install_build_tools (self ):
78
+ """
79
+ Install all ``build.tools`` defined by the user in the config file.
80
+
81
+ It uses ``asdf`` behind the scenes to manage all the tools and versions
82
+ of them. These tools/versions are stored in the Cloud cache and are
83
+ downloaded on each build (~50 - ~100Mb).
84
+
85
+ If the requested tool/version is not present in the cache, it's
86
+ installed via ``asdf`` on the fly.
87
+ """
78
88
if settings .RTD_DOCKER_COMPOSE :
79
89
# Create a symlink for ``root`` user to use the same ``.asdf``
80
- # installation than ``docs`` user. Required for local building
90
+ # installation as the ``docs`` user. Required for local building
81
91
# since everything is run as ``root`` when using Local Development
82
92
# instance
83
93
cmd = [
@@ -91,11 +101,12 @@ def install_build_tools(self):
91
101
)
92
102
93
103
for tool , version in self .config .build .tools .items ():
94
- version = version .full_version # e.g. 3.9 -> 3.9.7
104
+ full_version = version .full_version # e.g. 3.9 -> 3.9.7
95
105
96
106
# TODO: generate the correct path for the Python version
97
- # tool_path = f'{self.config.build.os}/{tool}/2021-08-30/{version}.tar.gz'
98
- tool_path = f'{ self .config .build .os } -{ tool } -{ version } .tar.gz'
107
+ # see https://github.com/readthedocs/readthedocs.org/pull/8447#issuecomment-911562267
108
+ # tool_path = f'{self.config.build.os}/{tool}/2021-08-30/{full_version}.tar.gz'
109
+ tool_path = f'{ self .config .build .os } -{ tool } -{ full_version } .tar.gz'
99
110
tool_version_cached = build_tools_storage .exists (tool_path )
100
111
if tool_version_cached :
101
112
remote_fd = build_tools_storage .open (tool_path , mode = 'rb' )
@@ -107,10 +118,10 @@ def install_build_tools(self):
107
118
# Move the extracted content to the ``asdf`` installation
108
119
cmd = [
109
120
'mv' ,
110
- f'{ extract_path } /{ version } ' ,
121
+ f'{ extract_path } /{ full_version } ' ,
111
122
os .path .join (
112
123
settings .RTD_DOCKER_WORKDIR ,
113
- f'.asdf/installs/{ tool } /{ version } ' ,
124
+ f'.asdf/installs/{ tool } /{ full_version } ' ,
114
125
),
115
126
]
116
127
self .build_env .run (
@@ -121,18 +132,21 @@ def install_build_tools(self):
121
132
'Cached version for tool not found. os=%s tool=%s version=% filename=%s' ,
122
133
self .config .build .os ,
123
134
tool ,
124
- version ,
135
+ full_version ,
125
136
tool_path ,
126
137
)
127
138
# If the tool version selected is not available from the
128
139
# cache we compile it at build time
129
140
cmd = [
130
- # TODO: make this environment variable to work
131
- # 'PYTHON_CONFIGURE_OPTS="--enable-shared"',
141
+ # TODO: make ``PYTHON_CONFIGURE_OPTS="--enable-shared"``
142
+ # environment variable to work here. Note that
143
+ # ``self.build_env.run`` does not support passing
144
+ # environment for a particular command:
145
+ # https://github.com/readthedocs/readthedocs.org/blob/9d2d1a2/readthedocs/doc_builder/environments.py#L430-L431
132
146
'asdf' ,
133
147
'install' ,
134
148
tool ,
135
- version ,
149
+ full_version ,
136
150
]
137
151
self .build_env .run (
138
152
* cmd ,
@@ -143,14 +157,15 @@ def install_build_tools(self):
143
157
'asdf' ,
144
158
'global' ,
145
159
tool ,
146
- version ,
160
+ full_version ,
147
161
]
148
162
self .build_env .run (
149
163
* cmd ,
150
164
)
151
165
152
166
# Recreate shims for this tool to make the new version
153
167
# installed available
168
+ # https://asdf-vm.com/learn-more/faq.html#newly-installed-exectable-not-running
154
169
cmd = [
155
170
'asdf' ,
156
171
'reshim' ,
@@ -163,9 +178,14 @@ def install_build_tools(self):
163
178
if all ([
164
179
tool == 'python' ,
165
180
# Do not install them if the tool version was cached
181
+ # because these dependencies are already installed when
182
+ # created with our script and uploaded to the cache's
183
+ # bucket
166
184
not tool_version_cached ,
167
- # Do not install them on conda/mamba
168
- self .config .python_interpreter == 'python' ,
185
+ # Do not install them on conda/mamba since they are not
186
+ # needed because the environment is managed by conda/mamba
187
+ # itself
188
+ self .config .python_interpreter not in ('conda' , 'mamba' ),
169
189
]):
170
190
# Install our own requirements if the version is compiled
171
191
cmd = [
@@ -673,7 +693,8 @@ def setup_base(self):
673
693
if all ([
674
694
# The project has CONDA_USES_MAMBA feature enabled and,
675
695
self .project .has_feature (Feature .CONDA_USES_MAMBA ),
676
- # the project is not using ``build.tools``
696
+ # the project is not using ``build.tools``,
697
+ # which has mamba installed via asdf.
677
698
not self .config .using_build_tools ,
678
699
]):
679
700
self ._install_mamba ()
0 commit comments