-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
PLAT-2060 Use pip-tools to manage requirements files #17825
Conversation
Your PR has finished running tests. |
251de85
to
f0d2d31
Compare
Your PR has finished running tests. |
f0d2d31
to
8436d0b
Compare
Your PR has finished running tests. |
8436d0b
to
ddcef1c
Compare
Your PR has finished running tests. |
ddcef1c
to
d3f1678
Compare
Your PR has finished running tests. |
Makefile
Outdated
pip-compile --upgrade -o requirements/edx/development.txt requirements/edx/development.in | ||
scripts/post-pip-compile.sh requirements/edx/base.txt requirements/edx/coverage.txt \ | ||
requirements/edx/development.txt requirements/edx/paver.txt requirements/edx/testing.txt \ | ||
requirements/edx-sandbox/shared.in requirements/edx-sandbox/base.in |
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.
Were these edx-sandbox
files supposed to be the .txt
versions?
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.
Yes, good catch. Fixing.
pip-compile --upgrade -o requirements/edx-sandbox/base.txt requirements/edx-sandbox/base.in | ||
pip-compile --upgrade -o requirements/edx/base.txt requirements/edx/base.in | ||
pip-compile --upgrade -o requirements/edx/testing.txt requirements/edx/testing.in | ||
pip-compile --upgrade -o requirements/edx/development.txt requirements/edx/development.in |
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.
Are these all just in a specific order which guarantees that no compilation is performed with an old compiled .txt file? In general I thought that no .in file would install a .txt file, but maybe we want to do that for performance reasons?
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.
Right, this sequence compiles them such that the ones which are included in other files get built before the ones that include them. The reason for including ".txt" instead of ".in" files is to ensure consistency of dependency versions across different contexts (so pip-tools doesn't resolve to one version for production and a different one for tests after constraints from additional dependencies are imposed). I'm currently making an edit to the draft OEP to explain that reasoning.
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.
There needs to be a comment here pointing at that explanation. This looks easy to screw up.
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.
Will add.
Makefile
Outdated
requirements/edx-sandbox/shared.in requirements/edx-sandbox/base.in | ||
# Let tox control the Django version for tests | ||
grep "^django==" requirements/edx/base.txt > requirements/edx/django.txt | ||
sed '/^django==/d' requirements/edx/testing.txt > requirements/edx/testing.tmp |
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 think we've run into problems with these lines in other repos with "django" vs "Django" and had to do case-insensitive searches
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.
One of the changes in this PR was to force-lowercase django itself, which I think solves the problem.
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.
pip-compile always lower-cases the package names, but it doesn't hurt to make it case-insensitive in case somebody edits it manually for some reason. Changing.
common/lib/chem/setup.py
Outdated
@@ -8,6 +8,6 @@ | |||
"pyparsing==2.0.7", | |||
"numpy==1.6.2", | |||
"scipy==0.14.0", | |||
"nltk==3.2.5", | |||
"nltk", |
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 think we need to bump the version of chem for this, otherwise existing virtualenvs might not install the new version and get the loosened requirement?
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.
The generated requirements file still pins it. I want to gradually get these local apps out of the business of pinning anything. The only potential problem I can see down the road is if we upgrade nltk later and it breaks existing virtualenvs that still remember the earlier pin here...but with devstack images now getting routinely rebuilt and pulled, that seems less likely than before (and a good reason to yank this sooner rather than later). Am I still missing any subtleties of the issue with this?
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.
Probably just me being traumatized from the ways this has broken recently. It's probably fine if nobody tries to touch that version any time soon. Seems like it would be safer to force the version so we know the right thing is there, but I don't feel strongly about it.
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.
Why unpin nltk but not the other requirements?
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.
n/m, "because nltk is at the latest version"
d3f1678
to
93873ed
Compare
Your PR has finished running tests. |
Makefile
Outdated
clean: | ||
help: ## display this help message | ||
@echo "Please use \`make <target>' where <target> is one of" | ||
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' |
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.
How can it be that make doesn't provide this functionality natively?? :(
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.
Yeah, I originally pulled this from an upstream Django cookiecutter template and it's been spreading throughout our repos. The closest built-in feature that GNU make has is make --print-data-base
, which omits the target description comments and includes piles of usually irrelevant cruft.
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.
Just because, I tried my hand at a python replacement. It's longer...
@python -c 'import fileinput,re; ms=filter(None, (re.search("([a-zA-Z_-]+):.*?## (.*)$$",l) for l in fileinput.input())); print("\n".join(sorted("\033[36m {:25}\033[0m {}".format(*m.groups()) for m in ms)))' $(MAKEFILE_LIST)
But how did perl get in there in the first place? It's just a grep:
@grep -E '^[a-zA-Z_-]+:.*?##' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
Which is shorter than the original, and just to continue the golfing:
@grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
And honestly, I'm not a fan of the terminal coloring, so why not just:
@grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf " %-26s%s\n", $$1, $$2}'
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.
BTW, you should add "help" to the .PHONY target, I think.
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.
Looks like that works, switching it is fine with me. Feel like submitting a PR upstream? https://github.com/pydanny/cookiecutter-djangopackage/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/Makefile#L16
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.
Fingers crossed! :) pydanny/cookiecutter-djangopackage#378
Makefile
Outdated
pip install -qr requirements/edx/development.txt --exists-action w | ||
|
||
upgrade: ## update the pip requirements files to use the latest releases satisfying our constraints | ||
pip install -q pip-tools |
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 want to get into an infinite loop here, but shouldn't we pin the version of pip-tools?
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.
It is pinned in requirements/edx/development.txt
, which is installed by the requirements
target. I could depend on that target here, but it's a little slow even in the case where everything's already up to date because of all the editable requirements; that gets annoying if you have to keep running this to resolve version conflicts. I'll try splitting that and its dependencies out into a separate file.
Makefile
Outdated
pip-compile --upgrade -o requirements/edx/development.txt requirements/edx/development.in | ||
scripts/post-pip-compile.sh requirements/edx/base.txt requirements/edx/coverage.txt \ | ||
requirements/edx/development.txt requirements/edx/paver.txt requirements/edx/testing.txt \ | ||
requirements/edx-sandbox/shared.txt requirements/edx-sandbox/base.txt |
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.
Let's put these each on their own line so we can see the list better.
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.
Actually, I think I'm going to switch this to scripts/pip-compile.sh
, which calls pip-compile and then does the post-processing on the output. That should simplify this make target a lot and make it less likely to forget something when updating it.
Makefile
Outdated
scripts/post-pip-compile.sh requirements/edx/base.txt requirements/edx/coverage.txt \ | ||
requirements/edx/development.txt requirements/edx/paver.txt requirements/edx/testing.txt \ | ||
requirements/edx-sandbox/shared.txt requirements/edx-sandbox/base.txt | ||
# Let tox control the Django version for tests |
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.
There isn't a better way to do this?
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.
Not that we've found yet. The requirements file we give tox can't have Django pinned to a specific version (it would conflict with the versions it assigns itself), but everything else should be. The "django.txt" file is here so Jenkins doesn't need to install all the development requirements, just the testing ones (since it isn't using tox for most runs yet, but installs the same test requirements file).
@@ -2590,7 +2590,7 @@ def _assert_time_zone_is_valid(self, time_zone_info): | |||
self.assertIn(time_zone_name, common_timezones_set) | |||
self.assertEqual(time_zone_info['description'], get_display_time_zone(time_zone_name)) | |||
|
|||
@ddt.data((ALL_TIME_ZONES_URI, 436), | |||
@ddt.data((ALL_TIME_ZONES_URI, 439), | |||
(COUNTRY_TIME_ZONES_URI, 28)) |
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.
A comment here about when this number might have to change?
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.
Sure, adding.
common/lib/chem | ||
common/lib/sandbox-packages | ||
common/lib/symmath | ||
# Placeholder for code which hasn't yet been updated to no longer use this file. |
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.
What code hasn't been updated? Ansible?
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.
Yes, a few different places in the configuration repo. After that's updated I plan to come back and remove these now-unnecessary files.
requirements/edx/github.in
Outdated
# * The "-e" prefix is primarily for the benefit of pip-compile, which does | ||
# not yet support non-editable GitHub URLs. If a VERSION is correctly | ||
# specified as shown above, the "-e" prefix will be stripped from the | ||
# output file by the post-pip-compile.sh script. |
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.
We should mention that this is the opposite of previous advice.
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.
Adding.
93873ed
to
60c3a23
Compare
Your PR has finished running tests. |
60c3a23
to
432347b
Compare
Your PR has finished running tests. |
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production on Wednesday, April 11, 2018. |
EdX Release Notice: This PR has been deployed to the production environment. |
This splits requirements into high-level direct dependency files managed by hand, and fully detailed requirements files generated by pip-compile. The detailed files are all recreated by the "make upgrade" target. Points worth noting:
pre.txt
requirements file; those should probably be merged before this.pip install
with them as normal, we just don't gain the benefit of automatically uninstalling any packages which were removed from the requirements.Packages which were deliberately upgraded:
Packages with recent releases which hadn't been pinned: