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

_service/pypi.py: Do not execute pip cache command when a custom directory is provided #161

Merged
merged 3 commits into from
Dec 2, 2021

Commits on Dec 2, 2021

  1. _service/pypi.py: Do not execute pip cache cmd if custom dir is given

    In a scenario where the pip cache directory isn't available because the
    user doesn't have permissions, pip will error with this message:
    
    ```
    ERROR: pip cache commands can not function since cache is disabled.
    ```
    
    This currently cannot be mitigated by specifying the `--cache-dir` flag
    because the `python -m pip cache dir` command is execute before this
    predicate is evaluated. By using an assignment expression (PEP 572), we
    can evaluate whether the expression evaluates to a truthy value in the
    `elif` branch (saving it's return value) AFTER first evaluating the
    custom directory value.
    JeffreyVdb committed Dec 2, 2021
    Configuration menu
    Copy the full SHA
    4960318 View commit details
    Browse the repository at this point in the history
  2. _service/pypi.py: assign pip_cache_dir outside of if statement

    Assignment expressions are only supported from Python 3.8 and upwards.
    Because the if statement consists out of early returns, we can create
    another if statement and assign the pip cache directory before the if
    statement and after the check for a custom directory has happened.
    JeffreyVdb committed Dec 2, 2021
    Configuration menu
    Copy the full SHA
    9a2d661 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6698f25 View commit details
    Browse the repository at this point in the history