heroku / heroku-buildpack-python

Heroku's buildpack for Python applications.
https://www.heroku.com/python
MIT License
974 stars 1.84k forks source link

Never skip running `pipenv install` #1526

Closed edmorley closed 8 months ago

edmorley commented 8 months ago

Previously the buildpack would skip running pipenv install for repeat Pipenv builds if (a) the SHA256 of the Pipfile.lock file had not changed since the last successful build, and (b) there were no Git VCS references in the lockfile.

However, this has a few issues:

  1. There are other cases where it's not safe to assume that there is no need to re-run pipenv install, such as when installing a non-editable local dependency (see #1525), or when using editable local dependencies with the current path re-writing strategy (see #1520).
  2. The current Git VCS check has false positives (see #1130, #1398).
  3. Even if we try and add more checks/workarounds to resolve (1) and (2), we're still having to make assumptions about internal Pipenv implementation details, and hardcode these in the buildpack, hoping we didn't miss anything and that Pipenv's behaviour doesn't change over time (which is not the case, as seen by the recent regression https://github.com/pypa/pipenv/issues/6054)

As such, we now instead always re-run pipenv install, and defer to Pipenv to decide whether the environment needs updating.

This should still be fast, since the cached site-packages is still being used (and if there are any scenarios in which it's not fast, then that's an upstream Pipenv bug).

Integration tests were also added for various types of editable Pipenv installs, since we previously only had test coverage of editable installs for Pip.

Fixes #1520. Fixes #1525. Closes #1130. Closes #1398. GUS-W-14762837.