Skip to content

Commit bcac962

Browse files
humitosericholscheragjohnson
authored
Deprecation: remove "use system packages" (python.system_packages config key and UI checkbox) (#10562)
* Docs: do not mention `python.system_packages` This option doesn't work on builds using `build.os` because the Python binary used it's not the one from the system, but another one compiled via `asdf`. This means that creating a virtualenv with access to the "system packages" has no effect at all. As a first step, I'm removing this option from the documentation to avoid confusions. Next, we should probably our deprecation policy to contact users ands remove it from the code as well. Closes #10500 * Build: remove "use system package" option - Removed from the UI - Removed from the v1 and v2 config file * Do not remove the DB field for now We should remove this field after the deploy. * Remove `use_system_site_packages` leftovers * Display custom error messages based on the config key * Apply suggestions from code review Co-authored-by: Eric Holscher <[email protected]> * Minor code style changes * Update readthedocs/config/config.py Co-authored-by: Anthony <[email protected]> --------- Co-authored-by: Eric Holscher <[email protected]> Co-authored-by: Anthony <[email protected]>
1 parent 97b3b25 commit bcac962

File tree

20 files changed

+56
-341
lines changed

20 files changed

+56
-341
lines changed

docs/user/api/v3.rst

-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ Build details
697697
"requirements": ".../stable/tools/docs-requirements.txt"
698698
}
699699
],
700-
"use_system_site_packages": false
701700
},
702701
"conda": null,
703702
"build": {

docs/user/config-file/v1.rst

-17
Original file line numberDiff line numberDiff line change
@@ -167,23 +167,6 @@ the highest supported minor version will be selected.
167167
python:
168168
version: 3.5
169169
170-
python.use_system_site_packages
171-
```````````````````````````````
172-
173-
* Default: ``false``
174-
* Type: Boolean
175-
176-
When true, it gives the virtual environment access to the global site-packages directory.
177-
Depending on the :ref:`config-file/v1:build.image`,
178-
Read the Docs includes some libraries like scipy, numpy, etc.
179-
See :doc:`/builds` for more details.
180-
181-
.. code-block:: yaml
182-
183-
python:
184-
use_system_site_packages: true
185-
186-
187170
python.setup_py_install
188171
```````````````````````
189172

docs/user/config-file/v2.rst

-17
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ Configuration of the Python environment to be used.
130130
- docs
131131
- method: pip
132132
path: another/package
133-
system_packages: true
134133
135134
python.version
136135
``````````````
@@ -228,20 +227,6 @@ With the previous settings, Read the Docs will execute the next commands:
228227

229228
pip install .[docs]
230229

231-
python.system_packages
232-
``````````````````````
233-
234-
Give the virtual environment access to the global site-packages directory.
235-
236-
:Type: ``bool``
237-
:Default: ``false``
238-
239-
.. warning::
240-
241-
If you are using a :ref:`Conda <config-file/v2:conda>` environment
242-
to manage the build, this setting will not have any effect, since
243-
the virtual environment creation is managed by Conda.
244-
245230
conda
246231
~~~~~
247232

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

876859
.. warning::

readthedocs/api/v2/serializers.py

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class Meta(ProjectSerializer.Meta):
8484
"container_mem_limit",
8585
"container_time_limit",
8686
"install_project",
87-
"use_system_packages",
8887
"skip",
8988
"requirements_file",
9089
"python_interpreter",

readthedocs/config/config.py

+37-37
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
"""Build configuration for rtd."""
44

5+
import collections
56
import copy
67
import os
78
import re
@@ -128,14 +129,44 @@ class InvalidConfig(ConfigError):
128129

129130
"""Error for a specific key validation."""
130131

131-
message_template = 'Invalid "{key}": {error}'
132+
# Define the default message to show on ``InvalidConfig``
133+
default_message_template = 'Invalid configuration option "{key}"'
134+
135+
# Create customized message for based on each particular ``key``
136+
message_templates = collections.defaultdict(lambda: "{default_message}: {error}")
137+
138+
# Redirect the user to the blog post when using
139+
# `python.system_packages` or `python.use_system_site_packages`
140+
message_templates.update(
141+
{
142+
"python.system_packages": "{default_message}. "
143+
"This configuration key has been deprecated and removed. "
144+
"Refer to https://blog.readthedocs.com/use-system-packages-deprecated/ to read more about this change and how to upgrade your config file." # noqa
145+
}
146+
)
147+
# Use same message for `python.use_system_site_packages`
148+
message_templates.update(
149+
{
150+
"python.use_system_site_packages": message_templates.get(
151+
"python.system_packages"
152+
)
153+
}
154+
)
132155

133156
def __init__(self, key, code, error_message, source_file=None):
134157
self.key = key
135158
self.code = code
136159
self.source_file = source_file
137-
message = self.message_template.format(
138-
key=self._get_display_key(),
160+
161+
display_key = self._get_display_key()
162+
default_message = self.default_message_template.format(
163+
key=display_key,
164+
code=code,
165+
error=error_message,
166+
)
167+
message = self.message_templates[display_key].format(
168+
default_message=default_message,
169+
key=display_key,
139170
code=code,
140171
error=error_message,
141172
)
@@ -211,18 +242,10 @@ def __init__(self, env_config, raw_config, source_file, base_path=None):
211242

212243
def error(self, key, message, code):
213244
"""Raise an error related to ``key``."""
214-
if not os.path.isdir(self.source_file):
215-
source = os.path.relpath(self.source_file, self.base_path)
216-
error_message = '{source}: {message}'.format(
217-
source=source,
218-
message=message,
219-
)
220-
else:
221-
error_message = message
222245
raise InvalidConfig(
223246
key=key,
224247
code=code,
225-
error_message=error_message,
248+
error_message=message,
226249
source_file=self.source_file,
227250
)
228251

@@ -507,10 +530,8 @@ def validate_build(self):
507530
def validate_python(self):
508531
"""Validates the ``python`` key, set default values it's necessary."""
509532
install_project = self.defaults.get('install_project', False)
510-
use_system_packages = self.defaults.get('use_system_packages', False)
511533
version = self.defaults.get('python_version', '2')
512534
python = {
513-
'use_system_site_packages': use_system_packages,
514535
'install_with_pip': False,
515536
'extra_requirements': [],
516537
'install_with_setup': install_project,
@@ -526,13 +547,6 @@ def validate_python(self):
526547
code=PYTHON_INVALID,
527548
)
528549

529-
# Validate use_system_site_packages.
530-
if 'use_system_site_packages' in raw_python:
531-
with self.catch_validation_error('python.use_system_site_packages'):
532-
python['use_system_site_packages'] = validate_bool(
533-
raw_python['use_system_site_packages'],
534-
)
535-
536550
# Validate pip_install.
537551
if 'pip_install' in raw_python:
538552
with self.catch_validation_error('python.pip_install'):
@@ -663,7 +677,6 @@ def python(self):
663677
return Python(
664678
version=python['version'],
665679
install=python_install,
666-
use_system_site_packages=python['use_system_site_packages'],
667680
)
668681

669682
@property
@@ -967,7 +980,6 @@ def validate_python(self):
967980
Fall back to the defaults of:
968981
- ``requirements``
969982
- ``install`` (only for setup.py method)
970-
- ``system_packages``
971983
972984
.. note::
973985
- ``version`` can be a string or number type.
@@ -1011,13 +1023,6 @@ def validate_python(self):
10111023
for index in range(len(raw_install))
10121024
]
10131025

1014-
with self.catch_validation_error('python.system_packages'):
1015-
system_packages = self.pop_config(
1016-
'python.system_packages',
1017-
False,
1018-
)
1019-
python['use_system_site_packages'] = validate_bool(system_packages)
1020-
10211026
return python
10221027

10231028
def validate_python_install(self, index):
@@ -1275,18 +1280,14 @@ def validate_keys(self):
12751280
This should be called after all the validations are done and all keys
12761281
are popped from `self._raw_config`.
12771282
"""
1278-
msg = (
1279-
'Invalid configuration option: {}. '
1280-
'Make sure the key name is correct.'
1281-
)
12821283
# The version key isn't popped, but it's
12831284
# validated in `load`.
12841285
self.pop_config('version', None)
12851286
wrong_key = '.'.join(self._get_extra_key(self._raw_config))
12861287
if wrong_key:
12871288
self.error(
1288-
wrong_key,
1289-
msg.format(wrong_key),
1289+
key=wrong_key,
1290+
message="Make sure the key name is correct.",
12901291
code=INVALID_KEY,
12911292
)
12921293

@@ -1354,7 +1355,6 @@ def python(self):
13541355
return Python(
13551356
version=python.get('version'),
13561357
install=python_install,
1357-
use_system_site_packages=python['use_system_site_packages'],
13581358
)
13591359

13601360
@property

readthedocs/config/models.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ def __init__(self, **kwargs):
8080

8181

8282
class Python(Base):
83-
84-
__slots__ = ('version', 'install', 'use_system_site_packages')
83+
__slots__ = ("version", "install")
8584

8685

8786
class PythonInstallRequirements(Base):

0 commit comments

Comments
 (0)