-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Build: install all the latest Python "core requirements" #10508
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
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c063414
Build: install all the latest Python "core requirements"
humitos f028546
Build: remove deprecated dependencies
humitos 1af8d48
Build: install latest core requirements when using Conda
humitos b1e44d5
Docs: update default versions documentation to match the changes
humitos 2ce5d41
Feedback from review
humitos 8e3e874
Update documentation
humitos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,63 @@ def install_core_requirements(self): | |
'--no-cache-dir', | ||
] | ||
|
||
if self.project.has_feature(Feature.INSTALL_LATEST_CORE_REQUIREMENTS): | ||
self._install_latest_requirements(pip_install_cmd) | ||
else: | ||
self._install_old_requirements(pip_install_cmd) | ||
|
||
def _install_latest_requirements(self, pip_install_cmd): | ||
""" | ||
Install all the latest core requirements. | ||
|
||
By enabling the feature flag ``INSTALL_LATEST_CORE_REQUIREMENTS`` | ||
projects will automatically get installed all the latest core | ||
requirements: pip, sphinx, mock, alabaster, setuptools, etc. | ||
humitos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This is the new behavior and where we are moving towards. | ||
""" | ||
# First, upgrade pip and setuptools to their latest versions | ||
cmd = pip_install_cmd + ["pip", "setuptools"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do think upgrading pip & setuptools will definitely cause us issues when they ship busted versions, but hopefully that will teach users to pin their deps! 🗡️ |
||
self.build_env.run( | ||
*cmd, | ||
bin_path=self.venv_bin(), | ||
cwd=self.checkout_path, | ||
) | ||
|
||
# Second, install all the latest core requirements | ||
requirements = [ | ||
"setuptools", | ||
humitos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
] | ||
|
||
if self.config.doctype == "mkdocs": | ||
requirements.append("mkdocs") | ||
else: | ||
requirements.extend( | ||
[ | ||
"sphinx", | ||
"sphinx-rtd-theme", | ||
humitos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"readthedocs-sphinx-ext", | ||
] | ||
) | ||
|
||
cmd = copy.copy(pip_install_cmd) | ||
cmd.extend(requirements) | ||
self.build_env.run( | ||
*cmd, | ||
bin_path=self.venv_bin(), | ||
cwd=self.checkout_path, | ||
) | ||
|
||
def _install_old_requirements(self, pip_install_cmd): | ||
""" | ||
Install old core requirements. | ||
|
||
There are bunch of feature flags that will be taken in consideration to | ||
decide whether or not upgrade some of the core dependencies to their | ||
latest versions. | ||
|
||
This is the old behavior and the one we want to get rid off. | ||
""" | ||
# Install latest pip and setuptools first, | ||
# so it is used when installing the other requirements. | ||
pip_version = self.project.get_feature_value( | ||
|
@@ -420,7 +477,10 @@ def _append_core_requirements(self): | |
else: | ||
# Append conda dependencies directly to ``dependencies`` and pip | ||
# dependencies to ``dependencies.pip`` | ||
pip_requirements, conda_requirements = self._get_core_requirements() | ||
if self.project.has_feature(Feature.INSTALL_LATEST_CORE_REQUIREMENTS): | ||
pip_requirements, conda_requirements = self._get_new_core_requirements() | ||
else: | ||
pip_requirements, conda_requirements = self._get_old_core_requirements() | ||
dependencies = environment.get('dependencies', []) | ||
pip_dependencies = {'pip': pip_requirements} | ||
|
||
|
@@ -458,7 +518,22 @@ def _append_core_requirements(self): | |
'environment file.', | ||
) | ||
|
||
def _get_core_requirements(self): | ||
def _get_new_core_requirements(self): | ||
# Use conda for requirements it packages | ||
conda_requirements = [] | ||
|
||
# Install pip-only things. | ||
pip_requirements = [] | ||
|
||
if self.config.doctype == "mkdocs": | ||
pip_requirements.append("mkdocs") | ||
else: | ||
pip_requirements.append("readthedocs-sphinx-ext") | ||
conda_requirements.extend(["sphinx", "sphinx_rtd_theme"]) | ||
humitos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return pip_requirements, conda_requirements | ||
|
||
def _get_old_core_requirements(self): | ||
# Use conda for requirements it packages | ||
conda_requirements = [ | ||
'mock', | ||
|
@@ -487,7 +562,7 @@ def install_core_requirements(self): | |
# create`` step. | ||
return | ||
|
||
pip_requirements, conda_requirements = self._get_core_requirements() | ||
pip_requirements, conda_requirements = self._get_old_core_requirements() | ||
# Install requirements via ``conda install`` command if they were | ||
# not appended to the ``environment.yml`` file. | ||
cmd = [ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will break anything, since it's for new projects, so I'm fine doing it sooner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I targeted this for next month to give us some time to review the PR, make the adjustments, etc and maybe write a pretty small changelog blog post announcing this so we have something to link people to when they ask.