Skip to content

Commit

Permalink
Merge pull request #161 from JeffreyVdb/evaluate-pip-cache-dir-after-…
Browse files Browse the repository at this point in the history
…custom-check

_service/pypi.py: Do not execute pip cache command when a custom directory is provided
  • Loading branch information
di authored Dec 2, 2021
2 parents 5216e4a + 6698f25 commit bca886a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ All versions prior to 0.0.9 are untracked.
`--strict` mode) is produced
([#162](https://github.com/trailofbits/pip-audit/pull/162))

* CLI: When providing the `--cache-dir` flag, the command to read the pip cache
directory is no longer executed. Previously this was always executed and
could result into failure when the command fails. In CI environments, the
default `~/.cache` directory is typically not writable by the build user and
this meant that the `python -m pip cache dir` would fail before this fix,
even if the `--cache-dir` flag was provided.
([#161](https://github.com/trailofbits/pip-audit/pull/161))

### Removed

## [1.0.0] - 2021-12-1
Expand Down
7 changes: 3 additions & 4 deletions pip_audit/_service/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ def _get_pip_cache() -> str:


def _get_cache_dir(custom_cache_dir: Optional[Path]) -> str:
pip_cache_dir: Optional[str] = (
_get_pip_cache() if _PIP_VERSION >= _MINIMUM_PIP_VERSION else None
)
if custom_cache_dir is not None:
return str(custom_cache_dir)
elif pip_cache_dir is not None: # pragma: no cover

pip_cache_dir = _get_pip_cache() if _PIP_VERSION >= _MINIMUM_PIP_VERSION else None
if pip_cache_dir is not None: # pragma: no cover
return pip_cache_dir
else:
fallback_path = os.path.join(Path.home(), ".pip-audit-cache")
Expand Down

0 comments on commit bca886a

Please sign in to comment.