Skip to content

Add feature flip for always upgrading user defined packages on pip install #3201

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 23 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
59cccbf
Add feature flipping models to Projects, plus example feature flip
agjohnson Oct 5, 2017
d251bbd
Refactoring the make_api_* calls into the API models
agjohnson Oct 27, 2017
21bab41
Add migrations for proxy models
agjohnson Oct 27, 2017
954f632
Add some admin features
agjohnson Oct 27, 2017
ae8ec3d
Bump setuptools version.
bhearsum Oct 17, 2017
59f681f
Add feature flip for setuptools latest version
agjohnson Oct 27, 2017
889cf0b
Use `--upgrade` instead of `-U` in `pip` args
wmayner Aug 31, 2017
313ef52
Add upgrade flag to user environment pip install
wmayner Aug 31, 2017
8d6c673
Add feature flip for always upgrading user defined packages on pip in…
agjohnson Oct 27, 2017
e6d2bdc
Rework feature relationship, add default true value based on date
agjohnson Oct 27, 2017
adbe72a
Fix some issues, more tests
agjohnson Oct 27, 2017
2776764
Merge branch 'project-features' into project-feature-setuptools
agjohnson Oct 27, 2017
e1f4265
Merge branch 'project-features' into project-feature-pip-upgrade
agjohnson Oct 27, 2017
dbdf59f
Rename Feature.feature -> Feature.feature_id, other cleanup
agjohnson Oct 30, 2017
f48c702
Merge branch 'project-features' into project-feature-setuptools
agjohnson Oct 30, 2017
c4b0cac
Drop setuptools pinning
agjohnson Oct 30, 2017
92fcfc5
Merge branch 'project-feature-setuptools' into project-feature-pip-up…
agjohnson Oct 30, 2017
7ccbe97
Merge branch 'master' into project-feature-setuptools
agjohnson Oct 31, 2017
83b0a2f
Use semver for setuptools version
agjohnson Oct 31, 2017
3b3a996
Merge branch 'project-feature-setuptools' into project-feature-pip-up…
agjohnson Oct 31, 2017
5b185cc
Missed merge conflict
agjohnson Oct 31, 2017
2af3abf
Merge branch 'project-feature-setuptools' into project-feature-pip-up…
agjohnson Oct 31, 2017
9a2250a
Merge branch 'master' into project-feature-pip-upgrade
agjohnson Oct 31, 2017
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
32 changes: 23 additions & 9 deletions readthedocs/doc_builder/python_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ def install_core_requirements(self):
"""Install basic Read the Docs requirements into the virtualenv."""
requirements = [
'Pygments==2.2.0',
'setuptools==28.8.0',
# Assume semver for setuptools version, support up to next backwards
# incompatible release
self.project.get_feature_value(
Feature.USE_SETUPTOOLS_LATEST,
'setuptools<37',
'setuptools==28.8.0',
),
'docutils==0.13.1',
'mock==1.0.1',
'pillow==2.6.1',
Expand All @@ -129,13 +135,14 @@ def install_core_requirements(self):
if self.project.documentation_type == 'mkdocs':
requirements.append('mkdocs==0.15.0')
else:
if self.project.has_feature(Feature.USE_SPHINX_LATEST):
# We will assume semver here and only automate up to the next
# backward incompatible release: 2.x
requirements.append('sphinx<2')
else:
requirements.append('sphinx==1.5.6')
# We will assume semver here and only automate up to the next
# backward incompatible release: 2.x
requirements.extend([
self.project.get_feature_value(
Feature.USE_SPHINX_LATEST,
'sphinx<2',
'sphinx==1.5.6',
),
'sphinx-rtd-theme<0.3',
'readthedocs-sphinx-ext<0.6'
])
Expand All @@ -145,7 +152,7 @@ def install_core_requirements(self):
self.venv_bin(filename='pip'),
'install',
'--use-wheel',
'-U',
'--upgrade',
'--cache-dir',
self.project.pip_cache_path,
]
Expand Down Expand Up @@ -175,14 +182,21 @@ def install_user_requirements(self):
break

if requirements_file_path:
self.build_env.run(
args = [
'python',
self.venv_bin(filename='pip'),
'install',
]
if self.project.has_feature(Feature.PIP_ALWAYS_UPGRADE):
args += ['--upgrade']
args += [
'--exists-action=w',
'--cache-dir',
self.project.pip_cache_path,
'-r{0}'.format(requirements_file_path),
]
self.build_env.run(
*args,
cwd=self.checkout_path,
bin_path=self.venv_bin()
)
Expand Down
12 changes: 12 additions & 0 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,14 @@ def has_feature(self, feature_id):
"""
return self.features.filter(feature_id=feature_id).exists()

def get_feature_value(self, feature, positive, negative):
"""Look up project feature, return corresponding value

If a project has a feature, return ``positive``, otherwise return
``negative``
"""
return positive if self.has_feature(feature) else negative


class APIProject(Project):

Expand Down Expand Up @@ -994,9 +1002,13 @@ def add_features(sender, **kwargs):
# Feature constants - this is not a exhaustive list of features, features
# may be added by other packages
USE_SPHINX_LATEST = 'use_sphinx_latest'
USE_SETUPTOOLS_LATEST = 'use_setuptools_latest'
PIP_ALWAYS_UPGRADE = 'pip_always_upgrade'

FEATURES = (
(USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
(USE_SETUPTOOLS_LATEST, _('Use latest version of setuptools')),
(PIP_ALWAYS_UPGRADE, _('Always run pip install --upgrade')),
)

projects = models.ManyToManyField(
Expand Down