Skip to content

Deprecation: remove "use system packages" (python.system_packages config key and UI checkbox) #10562

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 9 commits into from
Aug 22, 2023
1 change: 0 additions & 1 deletion docs/user/api/v3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ Build details
"requirements": ".../stable/tools/docs-requirements.txt"
}
],
"use_system_site_packages": false
},
"conda": null,
"build": {
Expand Down
17 changes: 0 additions & 17 deletions docs/user/config-file/v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,6 @@ the highest supported minor version will be selected.
python:
version: 3.5

python.use_system_site_packages
```````````````````````````````

* Default: ``false``
* Type: Boolean

When true, it gives the virtual environment access to the global site-packages directory.
Depending on the :ref:`config-file/v1:build.image`,
Read the Docs includes some libraries like scipy, numpy, etc.
See :doc:`/builds` for more details.

.. code-block:: yaml

python:
use_system_site_packages: true


python.setup_py_install
```````````````````````

Expand Down
17 changes: 0 additions & 17 deletions docs/user/config-file/v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ Configuration of the Python environment to be used.
- docs
- method: pip
path: another/package
system_packages: true

python.version
``````````````
Expand Down Expand Up @@ -228,20 +227,6 @@ With the previous settings, Read the Docs will execute the next commands:

pip install .[docs]

python.system_packages
``````````````````````

Give the virtual environment access to the global site-packages directory.

:Type: ``bool``
:Default: ``false``

.. warning::

If you are using a :ref:`Conda <config-file/v2:conda>` environment
to manage the build, this setting will not have any effect, since
the virtual environment creation is managed by Conda.

conda
~~~~~

Expand Down Expand Up @@ -869,8 +854,6 @@ Changes
- The settings ``python.setup_py_install`` and ``python.pip_install`` were replaced by ``python.install``.
And now it accepts a path to the package.
See :ref:`config-file/v2:Packages`.
- The setting ``python.use_system_site_packages`` was renamed to ``python.system_packages``.
See :ref:`config-file/v2:python.system_packages`.
- The build will fail if there are invalid keys (strict mode).

.. warning::
Expand Down
1 change: 0 additions & 1 deletion readthedocs/api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class Meta(ProjectSerializer.Meta):
"container_mem_limit",
"container_time_limit",
"install_project",
"use_system_packages",
"skip",
"requirements_file",
"python_interpreter",
Expand Down
19 changes: 0 additions & 19 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,8 @@ def validate_build(self):
def validate_python(self):
"""Validates the ``python`` key, set default values it's necessary."""
install_project = self.defaults.get('install_project', False)
use_system_packages = self.defaults.get('use_system_packages', False)
version = self.defaults.get('python_version', '2')
python = {
'use_system_site_packages': use_system_packages,
'install_with_pip': False,
'extra_requirements': [],
'install_with_setup': install_project,
Expand All @@ -526,13 +524,6 @@ def validate_python(self):
code=PYTHON_INVALID,
)

# Validate use_system_site_packages.
if 'use_system_site_packages' in raw_python:
with self.catch_validation_error('python.use_system_site_packages'):
python['use_system_site_packages'] = validate_bool(
raw_python['use_system_site_packages'],
)

# Validate pip_install.
if 'pip_install' in raw_python:
with self.catch_validation_error('python.pip_install'):
Expand Down Expand Up @@ -663,7 +654,6 @@ def python(self):
return Python(
version=python['version'],
install=python_install,
use_system_site_packages=python['use_system_site_packages'],
)

@property
Expand Down Expand Up @@ -967,7 +957,6 @@ def validate_python(self):
Fall back to the defaults of:
- ``requirements``
- ``install`` (only for setup.py method)
- ``system_packages``

.. note::
- ``version`` can be a string or number type.
Expand Down Expand Up @@ -1011,13 +1000,6 @@ def validate_python(self):
for index in range(len(raw_install))
]

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

return python

def validate_python_install(self, index):
Expand Down Expand Up @@ -1354,7 +1336,6 @@ def python(self):
return Python(
version=python.get('version'),
install=python_install,
use_system_site_packages=python['use_system_site_packages'],
)

@property
Expand Down
3 changes: 1 addition & 2 deletions readthedocs/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def __init__(self, **kwargs):


class Python(Base):

__slots__ = ('version', 'install', 'use_system_site_packages')
__slots__ = ("version", "install")


class PythonInstallRequirements(Base):
Expand Down
94 changes: 0 additions & 94 deletions readthedocs/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,24 +305,6 @@ def test_python_section_must_be_dict():
assert excinfo.value.code == PYTHON_INVALID


def test_use_system_site_packages_defaults_to_false():
build = get_build_config({'python': {}})
build.validate()
# Default is False.
assert not build.python.use_system_site_packages


@pytest.mark.parametrize('value', [True, False])
def test_use_system_site_packages_repects_default_value(value):
defaults = {
'use_system_packages': value,
}
build = get_build_config({}, {'defaults': defaults})
build.validate()
assert build.python.use_system_site_packages is value



class TestValidatePythonExtraRequirements:

def test_it_defaults_to_install_requirements_as_none(self):
Expand Down Expand Up @@ -357,32 +339,6 @@ def test_it_uses_validate_string(self, validate_string):
validate_string.assert_any_call('tests')


class TestValidateUseSystemSitePackages:

def test_it_defaults_to_false(self):
build = get_build_config({'python': {}})
build.validate()
assert build.python.use_system_site_packages is False

def test_it_validates_value(self):
build = get_build_config(
{'python': {'use_system_site_packages': 'invalid'}},
)
with raises(InvalidConfig) as excinfo:
build.validate()
excinfo.value.key = 'python.use_system_site_packages'
excinfo.value.code = INVALID_BOOL

@patch('readthedocs.config.config.validate_bool')
def test_it_uses_validate_bool(self, validate_bool):
validate_bool.return_value = True
build = get_build_config(
{'python': {'use_system_site_packages': 'to-validate'}},
)
build.validate()
validate_bool.assert_any_call('to-validate')


class TestValidateSetupPyInstall:

def test_it_defaults_to_false(self):
Expand Down Expand Up @@ -796,7 +752,6 @@ def test_as_dict(tmpdir):
'install': [{
'requirements': 'requirements.txt',
}],
'use_system_site_packages': False,
},
'build': {
'image': 'readthedocs/build:latest',
Expand Down Expand Up @@ -1801,53 +1756,6 @@ def test_python_install_several_respects_order(self, tmpdir):

assert install[2].requirements == 'three.txt'

@pytest.mark.parametrize('value', [True, False])
def test_python_system_packages_check_valid(self, value):
build = self.get_build_config({
'python': {
'system_packages': value,
},
})
build.validate()
assert build.python.use_system_site_packages is value

@pytest.mark.parametrize('value', [[], 'invalid', 5])
def test_python_system_packages_check_invalid(self, value):
build = self.get_build_config({
'python': {
'system_packages': value,
},
})
with raises(InvalidConfig) as excinfo:
build.validate()
assert excinfo.value.key == 'python.system_packages'

def test_python_system_packages_check_default(self):
build = self.get_build_config({})
build.validate()
assert build.python.use_system_site_packages is False

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 False

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

build = self.get_build_config(
{'python': {'system_packages': True}},
)
build.validate()
assert build.python.use_system_site_packages is True

@pytest.mark.parametrize('value', [[], True, 0, 'invalid'])
def test_sphinx_validate_type(self, value):
build = self.get_build_config({'sphinx': value})
Expand Down Expand Up @@ -2446,7 +2354,6 @@ def test_as_dict(self, tmpdir):
'install': [{
'requirements': 'requirements.txt',
}],
'use_system_site_packages': False,
},
'build': {
'image': 'readthedocs/build:latest',
Expand Down Expand Up @@ -2506,7 +2413,6 @@ def test_as_dict_new_build_config(self, tmpdir):
'install': [{
'requirements': 'requirements.txt',
}],
'use_system_site_packages': False,
},
'build': {
'os': 'ubuntu-20.04',
Expand Down
1 change: 0 additions & 1 deletion readthedocs/doc_builder/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def load_yaml_config(version, readthedocs_yaml_path=None):
'defaults': {
'install_project': project.install_project,
'formats': get_default_formats(project),
'use_system_packages': project.use_system_packages,
'requirements_file': project.requirements_file,
'python_version': python_version,
'sphinx_configuration': sphinx_configuration,
Expand Down
15 changes: 2 additions & 13 deletions readthedocs/doc_builder/python_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,9 @@ def setup_base(self):
"""
cli_args = [
'-mvirtualenv',
# Append the positional destination argument
"$READTHEDOCS_VIRTUALENV_PATH",
]
if self.config.python.use_system_site_packages:
cli_args.append('--system-site-packages')

# Append the positional destination argument
cli_args.append("$READTHEDOCS_VIRTUALENV_PATH")

self.build_env.run(
self.config.python_interpreter,
Expand Down Expand Up @@ -292,14 +289,6 @@ def _install_old_requirements(self, pip_install_cmd):
requirements.extend(["jinja2<3.1.0"])

cmd = copy.copy(pip_install_cmd)
if self.config.python.use_system_site_packages:
# Other code expects sphinx-build to be installed inside the
# virtualenv. Using the -I option makes sure it gets installed
# even if it is already installed system-wide (and
# --system-site-packages is used)
cmd.append('-I')
# The same version of setuptools used above needs to be used here.
requirements.append(setuptools_version)
cmd.extend(requirements)
self.build_env.run(
*cmd,
Expand Down
Loading