Skip to content

Adds support for custom conda channels in the config file #2507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions readthedocs/doc_builder/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def conda_file(self):
else:
return None

@property
def conda_channels(self):
if 'channels' in self._yaml_config.get('conda', []):
return self._yaml_config['conda']['channels']
else:
return None

@property
def requirements_file(self):
if 'requirements_file' in self._yaml_config:
Expand Down
34 changes: 16 additions & 18 deletions readthedocs/doc_builder/python_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,20 @@ def setup_base(self):
# Re-create conda directory each time to keep fresh state
self._log('Removing existing conda directory')
shutil.rmtree(version_path)

conda_cmd = [
'conda', 'env', 'create', '--prefix', self.venv_path(),
'--file', self.config.conda_file
]

if self.config.conda_channels is not None:
for channel in self.config.conda_channels:
conda_cmd.append('-c')
conda_cmd.append(channel)

self.build_env.run(
'conda',
'env',
'create',
'--name',
self.version.slug,
'--file',
self.config.conda_file,
bin_path=None, # Don't use conda bin that doesn't exist yet
*conda_cmd
)

def install_core_requirements(self):
Expand All @@ -206,8 +211,8 @@ def install_core_requirements(self):
'conda',
'install',
'--yes',
'--name',
self.version.slug,
'--prefix',
self.venv_path(),
]
cmd.extend(requirements)
self.build_env.run(
Expand Down Expand Up @@ -238,12 +243,5 @@ def install_core_requirements(self):
)

def install_user_requirements(self):
self.build_env.run(
'conda',
'env',
'update',
'--name',
self.version.slug,
'--file',
self.config.conda_file,
)
# User requirements are installed during the conda create
pass