Skip to content
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

ref: work around pip not having retries for streamed downloads #60195

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/actions/setup-sentry/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ runs:
with:
python-version: ${{ inputs.python-version }}
cache-dependency-path: ${{ inputs.workdir }}/requirements-dev-frozen.txt
install-cmd: pip install -r ${{ inputs.workdir }}/requirements-dev-frozen.txt
install-cmd: cd ${{ inputs.workdir }} && python3 -m tools.hack_pip && pip install -r requirements-dev-frozen.txt

- name: Set up outputs
id: config
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ jobs:
with:
python-version: 3.8.18
cache-dependency-path: requirements-dev-frozen.txt
install-cmd: pip install -q --constraint requirements-dev-frozen.txt pip-tools
install-cmd: python3 -m tools.hack_pip && pip install -q --constraint requirements-dev-frozen.txt pip-tools
- name: check requirements
run: |
python -S -m tools.freeze_requirements
Expand Down Expand Up @@ -280,7 +280,7 @@ jobs:
with:
python-version: 3.8.18
cache-dependency-path: requirements-dev-frozen.txt
install-cmd: pip install -r requirements-dev-frozen.txt
install-cmd: python3 -m tools.hack_pip && pip install -r requirements-dev-frozen.txt

- name: setup sentry (lite)
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/development-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
cache-dependency-path: |
requirements-dev.txt
requirements-dev-frozen.txt
install-cmd: pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
install-cmd: python3 -m tools.hack_pip && pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
- name: run tests
run: make test-tools
- name: Handle artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
cache-dependency-path: |
requirements-dev.txt
requirements-dev-frozen.txt
install-cmd: pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
install-cmd: python3 -m tools.hack_pip && pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
- uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: ~/.cache/pre-commit
Expand Down
31 changes: 31 additions & 0 deletions tools/hack_pip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import annotations

import os.path
import sys
import sysconfig

PTH = """\
from pip._internal.network.download import Downloader
from pip._vendor.tenacity import retry, stop_after_attempt
Downloader.__call__ = retry(
reraise=True,
stop=stop_after_attempt(5),
after=lambda state: print(f'!!! retry: attempt {state.attempt_number + 1} !!!')
)(Downloader.__call__)
"""


def main() -> int:
assert not sys.flags.no_site, sys.flags.no_site
target = os.path.join(sysconfig.get_path("purelib"), "sentry-pip-hack.pth")
assert "/.venv/" in target, target

print("working around https://github.com/pypa/pip/issues/12383#issuecomment-1808598097")
print(f"writing: {target}")
with open(target, "w") as f:
f.write(f"import sys;exec({PTH!r})\n")
return 0


if __name__ == "__main__":
raise SystemExit(main())
Loading