Browse Source

ref: remove tools.hack_pip (#79555)

- this has been "broken" since end of july (when pip 24.2 released)
- it's unclear when the underlying problem was fixed (if it was?)
- I suspect github might have improved their networking? or gcp?
- we haven't seen ReadTimeout errors though so presumably something in
pip changed to resolve this
- we can always bring this back later with the correct `retry` decorator
-- but it's simpler to just remove this!

```
working around https://github.com/pypa/pip/issues/12383#issuecomment-1808598097
writing: /home/runner/work/sentry/sentry/.venv/lib/python3.12/site-packages/sentry-pip-hack.pth
Error processing line 1 of /home/runner/work/sentry/sentry/.venv/lib/python3.12/site-packages/sentry-pip-hack.pth:

  Traceback (most recent call last):
    File "<frozen site>", line 206, in addpackage
    File "<string>", line 1, in <module>
    File "<string>", line 2, in <module>
  ModuleNotFoundError: No module named 'pip._vendor.tenacity'

Remainder of file ignored
```

getsentry first: https://github.com/getsentry/getsentry/pull/15456

<!-- Describe your PR here. -->
anthony sottile 4 months ago
parent
commit
6ddaa27987

+ 1 - 1
.github/actions/setup-sentry/action.yml

@@ -114,7 +114,7 @@ runs:
       with:
         python-version: ${{ inputs.python-version }}
         cache-dependency-path: ${{ inputs.workdir }}/requirements-dev-frozen.txt
-        install-cmd: cd ${{ inputs.workdir }} && python3 -m tools.hack_pip && pip install -r requirements-dev-frozen.txt
+        install-cmd: cd ${{ inputs.workdir }} && pip install -r requirements-dev-frozen.txt
 
     - name: Set up outputs
       id: config

+ 1 - 1
.github/actions/test-setup-sentry-devservices/action.yml

@@ -78,7 +78,7 @@ runs:
       with:
         python-version: ${{ inputs.python-version }}
         cache-dependency-path: ${{ inputs.workdir }}/requirements-dev-frozen.txt
-        install-cmd: cd ${{ inputs.workdir }} && python3 -m tools.hack_pip && pip install -r requirements-dev-frozen.txt
+        install-cmd: cd ${{ inputs.workdir }} && pip install -r requirements-dev-frozen.txt
 
     - name: Set up outputs
       id: config

+ 2 - 2
.github/workflows/backend.yml

@@ -210,7 +210,7 @@ jobs:
         with:
           python-version: 3.12.6
           cache-dependency-path: requirements-dev-frozen.txt
-          install-cmd: python3 -m tools.hack_pip && pip install -q --constraint requirements-dev-frozen.txt pip-tools
+          install-cmd: pip install -q --constraint requirements-dev-frozen.txt pip-tools
       - name: check requirements
         run: |
           python -S -m tools.freeze_requirements
@@ -303,7 +303,7 @@ jobs:
         with:
           python-version: 3.12.6
           cache-dependency-path: requirements-dev-frozen.txt
-          install-cmd: python3 -m tools.hack_pip && pip install -r requirements-dev-frozen.txt
+          install-cmd: pip install -r requirements-dev-frozen.txt
 
       - name: setup sentry (lite)
         run: |

+ 2 - 2
.github/workflows/development-environment.yml

@@ -37,7 +37,7 @@ jobs:
           cache-dependency-path: |
             requirements-dev.txt
             requirements-dev-frozen.txt
-          install-cmd: python3 -m tools.hack_pip && pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
+          install-cmd: pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
       - name: test-tools
         run: make test-tools
       - name: Handle artifacts
@@ -56,7 +56,7 @@ jobs:
           cache-dependency-path: |
             requirements-dev.txt
             requirements-dev-frozen.txt
-          install-cmd: python3 -m tools.hack_pip && pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
+          install-cmd: pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
       - name: devenv sync
         run: |
           devenv --nocoderoot sync

+ 1 - 1
.github/workflows/pre-commit.yml

@@ -75,7 +75,7 @@ jobs:
           cache-dependency-path: |
             requirements-dev.txt
             requirements-dev-frozen.txt
-          install-cmd: python3 -m tools.hack_pip && pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
+          install-cmd: pip install -r requirements-dev.txt -c requirements-dev-frozen.txt
       - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
         with:
           path: ~/.cache/pre-commit

+ 1 - 1
.github/workflows/self-hosted.yml

@@ -33,7 +33,7 @@ jobs:
         with:
           python-version: 3.12.6
           cache-dependency-path: requirements-dev-frozen.txt
-          install-cmd: python3 -m tools.hack_pip
+          install-cmd: echo
 
       - name: Step configurations
         id: config

+ 0 - 31
tools/hack_pip.py

@@ -1,31 +0,0 @@
-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())