Skip to content

Add feature flip for setuptools latest version #3200

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 16 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from 15 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
21 changes: 14 additions & 7 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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this pattern, more explicit. Could maybe use kwargs here, to make it more obvious what the options are.

),
'sphinx-rtd-theme<0.3',
'readthedocs-sphinx-ext<0.6'
])
Expand Down
10 changes: 10 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,11 @@ 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'

FEATURES = (
(USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
(USE_SETUPTOOLS_LATEST, _('Use latest version of setuptools')),
)

projects = models.ManyToManyField(
Expand Down