Repository navigation
ci: use the CI image's packages and share a pip cache between jobs #4592
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 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/usr/bin/env python3 | ||
| """Report which requirements the current environment does not already satisfy. | ||
|
|
||
| Prints one unsatisfied requirement per line on stdout, ready to pass to | ||
| `pip install`. Exit codes: 0 all satisfied, 1 some printed, 2 the check could | ||
| not run, so callers can fall back to a full dependency sync. | ||
| """ | ||
|
|
||
| import sys | ||
| from importlib.metadata import PackageNotFoundError, version | ||
|
|
||
| try: | ||
| from packaging.requirements import InvalidRequirement, Requirement | ||
| except ImportError as exc: # pragma: no cover - packaging ships in every CI image | ||
| print(f"cannot check requirements: {exc}", file=sys.stderr) | ||
| raise SystemExit(2) from exc | ||
|
|
||
|
|
||
| def parse_requirements(path): | ||
| """Read a requirements file, ignoring comments, blanks, and pip options.""" | ||
| requirements = [] | ||
| try: | ||
| with open(path, encoding="utf-8") as handle: | ||
| lines = handle.read().splitlines() | ||
| except OSError as exc: | ||
| print(f"skipping {path}: {exc}", file=sys.stderr) | ||
| return requirements | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| for raw in lines: | ||
| line = raw.split("#", 1)[0].strip() | ||
| if not line or line.startswith("-"): | ||
| continue | ||
| try: | ||
| requirements.append(Requirement(line)) | ||
| except InvalidRequirement as exc: | ||
| print(f"{path}: cannot parse {line!r}: {exc}", file=sys.stderr) | ||
| raise SystemExit(2) from exc | ||
| return requirements | ||
|
|
||
|
|
||
| def main(paths): | ||
| if not paths: | ||
| print("usage: check_requirements.py REQUIREMENTS_FILE...", file=sys.stderr) | ||
| return 2 | ||
|
|
||
| unsatisfied = [] | ||
| for path in paths: | ||
| for req in parse_requirements(path): | ||
| if req.marker is not None and not req.marker.evaluate(): | ||
| continue | ||
| try: | ||
| installed = version(req.name) | ||
| except PackageNotFoundError: | ||
| print(f"{req.name}: not installed", file=sys.stderr) | ||
| unsatisfied.append(str(req)) | ||
| continue | ||
| if not req.specifier.contains(installed, prereleases=True): | ||
| print( | ||
| f"{req.name}: installed {installed} does not satisfy " | ||
| f"{req.specifier}", | ||
| file=sys.stderr, | ||
| ) | ||
| unsatisfied.append(str(req)) | ||
|
|
||
| for req in unsatisfied: | ||
| print(req) | ||
| return 1 if unsatisfied else 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main(sys.argv[1:])) | ||
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.