Skip to content

Commit 4417322

Browse files
authored
Add feature flip for always upgrading user defined packages on pip install (#3201)
* Add feature flipping models to Projects, plus example feature flip Also, use a new pattern for API instance objects * Refactoring the make_api_* calls into the API models * Add migrations for proxy models * Add some admin features * Bump setuptools version. * Add feature flip for setuptools latest version Also, add a convenience method on the Project model for feature flag dependent values. * Use `--upgrade` instead of `-U` in `pip` args * Add upgrade flag to user environment pip install Installs the user-provided requirements with the `--upgrade` flag. * Add feature flip for always upgrading user defined packages on pip install We're not yet sure if this will blow up user defined requirements, feature here will be used to test on a sample. Refs #3077 Closes #3077 * Rework feature relationship, add default true value based on date This allows for features on deprecated code, where we can say the feature is true historically. * Fix some issues, more tests * Rename Feature.feature -> Feature.feature_id, other cleanup * Drop setuptools pinning * Use semver for setuptools version * Missed merge conflict
1 parent a6ec23c commit 4417322

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

readthedocs/doc_builder/python_environments.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def install_core_requirements(self):
152152
self.venv_bin(filename='pip'),
153153
'install',
154154
'--use-wheel',
155-
'-U',
155+
'--upgrade',
156156
'--cache-dir',
157157
self.project.pip_cache_path,
158158
]
@@ -182,14 +182,21 @@ def install_user_requirements(self):
182182
break
183183

184184
if requirements_file_path:
185-
self.build_env.run(
185+
args = [
186186
'python',
187187
self.venv_bin(filename='pip'),
188188
'install',
189+
]
190+
if self.project.has_feature(Feature.PIP_ALWAYS_UPGRADE):
191+
args += ['--upgrade']
192+
args += [
189193
'--exists-action=w',
190194
'--cache-dir',
191195
self.project.pip_cache_path,
192196
'-r{0}'.format(requirements_file_path),
197+
]
198+
self.build_env.run(
199+
*args,
193200
cwd=self.checkout_path,
194201
bin_path=self.venv_bin()
195202
)

readthedocs/projects/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,10 +1003,12 @@ def add_features(sender, **kwargs):
10031003
# may be added by other packages
10041004
USE_SPHINX_LATEST = 'use_sphinx_latest'
10051005
USE_SETUPTOOLS_LATEST = 'use_setuptools_latest'
1006+
PIP_ALWAYS_UPGRADE = 'pip_always_upgrade'
10061007

10071008
FEATURES = (
10081009
(USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
10091010
(USE_SETUPTOOLS_LATEST, _('Use latest version of setuptools')),
1011+
(PIP_ALWAYS_UPGRADE, _('Always run pip install --upgrade')),
10101012
)
10111013

10121014
projects = models.ManyToManyField(

0 commit comments

Comments
 (0)