Skip to content

Config file: system_site_packages overwritten from project's setting #8783

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

Merged
merged 3 commits into from
Jan 7, 2022
Merged
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
6 changes: 1 addition & 5 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,13 +938,9 @@ def validate_python(self):
]

with self.catch_validation_error('python.system_packages'):
system_packages = self.defaults.get(
'use_system_packages',
False,
)
system_packages = self.pop_config(
'python.system_packages',
system_packages,
False,
)
python['use_system_site_packages'] = validate_bool(system_packages)

Expand Down
6 changes: 2 additions & 4 deletions readthedocs/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,25 +1604,23 @@ def test_python_system_packages_check_default(self):
build.validate()
assert build.python.use_system_site_packages is False

def test_python_system_packages_respects_default(self):
def test_python_system_packages_dont_respects_default(self):
build = self.get_build_config(
{},
{'defaults': {'use_system_packages': True}},
)
build.validate()
assert build.python.use_system_site_packages is True
assert build.python.use_system_site_packages is False

def test_python_system_packages_priority_over_default(self):
build = self.get_build_config(
{'python': {'system_packages': False}},
{'defaults': {'use_system_packages': True}},
)
build.validate()
assert build.python.use_system_site_packages is False

build = self.get_build_config(
{'python': {'system_packages': True}},
{'defaults': {'use_system_packages': False}},
)
build.validate()
assert build.python.use_system_site_packages is True
Expand Down
32 changes: 32 additions & 0 deletions readthedocs/rtd_tests/tests/test_config_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,38 @@ def test_system_packages(self, run, checkout_path, tmpdir):
assert '--system-site-packages' in args
assert config.python.use_system_site_packages

@patch('readthedocs.doc_builder.environments.BuildEnvironment.run')
def test_system_packages_project_overrides(self, run, checkout_path, tmpdir):

# Define `project.use_system_packages` as if it was marked in the Advanced settings.
self.version.project.use_system_packages = True
self.version.project.save()

checkout_path.return_value = str(tmpdir)
self.create_config_file(
tmpdir,
{
# Do not define `system_packages: True` in the config file.
'python': {},
},
)

update_docs = self.get_update_docs_task()
config = update_docs.config

python_env = Virtualenv(
version=self.version,
build_env=update_docs.build_env,
config=config,
)
update_docs.python_env = python_env
update_docs.python_env.setup_base()

args, kwargs = run.call_args

assert '--system-site-packages' not in args
assert not config.python.use_system_site_packages

@pytest.mark.parametrize(
'value,result',
[
Expand Down