@@ -77,7 +77,7 @@ def venv_bin(self, version=LATEST, filename=None):
77
77
class Virtualenv (PythonEnvironment ):
78
78
79
79
def venv_path (self , version = LATEST ):
80
- return os .path .join (self .doc_path , 'envs' , version )
80
+ return os .path .join (self .project . doc_path , 'envs' , version )
81
81
82
82
def setup_base (self , config ):
83
83
site_packages = '--no-site-packages'
@@ -131,7 +131,7 @@ def install_user_requirements(self, config):
131
131
requirements_file_path = self .project .requirements_file
132
132
if not requirements_file_path :
133
133
builder_class = get_builder_class (self .project .documentation_type )
134
- docs_dir = (builder_class (self .build_env )
134
+ docs_dir = (builder_class (build_env = self .build_env , python_env = self )
135
135
.docs_dir ())
136
136
for path in [docs_dir , '' ]:
137
137
for req_file in ['pip_requirements.txt' , 'requirements.txt' ]:
@@ -157,25 +157,31 @@ def install_user_requirements(self, config):
157
157
class Conda (PythonEnvironment ):
158
158
159
159
def venv_path (self , version = LATEST ):
160
- return os .path .join (self .doc_path , 'conda' , version )
160
+ return os .path .join (self .project . doc_path , 'conda' , version )
161
161
162
162
def setup_base (self , config ):
163
- env_path = self .venv_path (version = self .version .slug )
164
- if 'python' in config :
165
- python_version = config ['python' ].get ('version' , 2 )
166
- else :
167
- python_version = 2
168
- if not os .path .exists (env_path ):
169
- self .build_env .run (
170
- 'conda' ,
171
- 'create' ,
172
- '--yes' ,
173
- '--prefix' ,
174
- env_path ,
175
- 'python={python_version}' .format (python_version = python_version ),
176
- )
163
+ conda_env_path = os .path .join (self .project .doc_path , 'conda' )
164
+ version_path = os .path .join (conda_env_path , self .version .slug )
165
+
166
+ python_version = config ['python' ].get ('version' , 2 )
167
+ if os .path .exists (version_path ):
168
+ # Re-create conda directory each time to keep fresh state
169
+ self ._log ('Removing existing conda directory' )
170
+ shutil .rmtree (version_path )
171
+ self .build_env .run (
172
+ 'conda' ,
173
+ 'create' ,
174
+ '--yes' ,
175
+ '--name' ,
176
+ self .version .slug ,
177
+ 'python={python_version}' .format (python_version = python_version ),
178
+ environment = {'CONDA_ENVS_PATH' : conda_env_path }
179
+ )
177
180
178
181
def install_core_requirements (self , config ):
182
+ conda_env_path = os .path .join (self .project .doc_path , 'conda' )
183
+
184
+ # Use conda for requirements it packages
179
185
requirements = [
180
186
'sphinx==1.3.1' ,
181
187
'Pygments==2.0.2' ,
@@ -192,11 +198,34 @@ def install_core_requirements(self, config):
192
198
cmd = [
193
199
'conda' ,
194
200
'install' ,
195
- '-y' ,
201
+ '--yes' ,
202
+ '--name' ,
203
+ self .version .slug ,
196
204
]
197
205
cmd .extend (requirements )
198
206
self .build_env .run (
199
207
* cmd ,
208
+ environment = {'CONDA_ENVS_PATH' : conda_env_path }
209
+ )
210
+
211
+ # Install pip-only things.
212
+ pip_requirements = [
213
+ 'mkdocs==0.14.0' ,
214
+ 'readthedocs-sphinx-ext==0.5.4' ,
215
+ 'recommonmark==0.1.1' ,
216
+ ]
217
+
218
+ pip_cmd = [
219
+ 'python' ,
220
+ self .venv_bin (version = self .version .slug , filename = 'pip' ),
221
+ 'install' ,
222
+ '-U' ,
223
+ '--cache-dir' ,
224
+ self .project .pip_cache_path ,
225
+ ]
226
+ pip_cmd .extend (pip_requirements )
227
+ self .build_env .run (
228
+ * pip_cmd ,
200
229
bin_path = self .venv_bin (version = self .version .slug )
201
230
)
202
231
@@ -210,6 +239,5 @@ def install_user_requirements(self, config):
210
239
self .version .slug ,
211
240
'--file' ,
212
241
config ['conda' ]['file' ],
213
- cwd = self .checkout_path ,
214
242
environment = {'CONDA_ENVS_PATH' : conda_env_path }
215
243
)
0 commit comments