Skip to content
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

Respect env variables in all build environments #6478

Closed
wants to merge 3 commits into from
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
18 changes: 5 additions & 13 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ def __init__(
if cwd is None:
cwd = os.getcwd()
self.cwd = cwd
self.environment = os.environ.copy()
if environment is not None:
if 'PATH' in environment:
raise BuildEnvironmentError('\'PATH\' can\'t be set.')
self.environment.update(environment)

environment = environment or {}
self.environment = environment.copy()

self.combine_output = combine_output
self.input_data = input_data
Expand Down Expand Up @@ -150,13 +148,7 @@ def run(self):
if self.combine_output:
stderr = subprocess.STDOUT

environment = {}
environment.update(self.environment)
environment['READTHEDOCS'] = 'True'
if self.build_env is not None:
environment['READTHEDOCS_VERSION'] = self.build_env.version.slug
environment['READTHEDOCS_PROJECT'] = self.build_env.project.slug
environment['READTHEDOCS_LANGUAGE'] = self.build_env.project.language
environment = self.environment.copy()
if 'DJANGO_SETTINGS_MODULE' in environment:
del environment['DJANGO_SETTINGS_MODULE']
if 'PYTHONPATH' in environment:
Expand Down Expand Up @@ -329,6 +321,7 @@ def run(self):
exec_cmd = client.exec_create(
container=self.build_env.container_id,
cmd=self.get_wrapped_command(),
environment=self.environment,
stdout=True,
stderr=True,
)
Expand Down Expand Up @@ -1051,7 +1044,6 @@ def create_container(self):
volumes=self._get_binds(),
host_config=self.get_container_host_config(),
detach=True,
environment=self.environment,
user=settings.RTD_DOCKER_USER,
)
client.start(container=self.container_id)
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ def setup_vcs(self, environment):
def get_env_vars(self):
"""Get bash environment variables used for all builder commands."""
env = {
'READTHEDOCS': True,
'READTHEDOCS': 'True',
'READTHEDOCS_VERSION': self.version.slug,
'READTHEDOCS_PROJECT': self.project.slug,
'READTHEDOCS_LANGUAGE': self.project.language,
Expand Down
7 changes: 1 addition & 6 deletions readthedocs/vcs_support/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ def make_clean_working_dir(self):

@property
def env(self):
environment = os.environ.copy()

# TODO: kind of a hack
del environment['PATH']

return environment
return {}

def update(self):
"""
Expand Down