-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Perform editable package .pth and .egg-link path rewriting at runtime
Currently the build system performs builds in a different directory (`/tmp/build_<hash>`) to which the app will be run at runtime (`/app`). This means that any hardcoded paths in the slug must be rewritten by the buildpack, so the app still works after being moved. One such case of hardcoded paths, are the `.pth` and `.egg-link` files that are created in the `site-packages` directory by Pip/setuptools for editable package installs (aka develop mode). The most common way someone might use editable mode is via `-e <package specifier>` entries in their `requirements.txt` file. Until now, the Python buildpack rewrote paths inside these files during the compile itself, which meant the build-time paths were no longer present when subsequent buildpacks ran. This happened to work due to an interaction of legacy setuptools behaviour and a buildpack bug, but stops working in setuptools 47.2.0 or later - as described in #1006. Longer term we would like to stop building in one location and running the app from another, so that the path rewriting isn't required at all. However that change breaks some other buildpacks so requires a long-term transition plan. In the meantime, this change moves path rewriting to a `.profile.d/` script, so that it occurs at runtime, and so after all other buildpacks have run. Additional test coverage of editable packages was added previously in #1251 and #1253, and has confirmed that this new `profile.d/` script approach will prevent the issues in #1006 when setuptools is updated in a future PR. There is one subtle implication of moving this path rewriting, in that subsequent cached builds will no longer see the existing package as being already installed, so won't uninstall if before reinstalling it (as seen in the test log output change). However this is not believed to have any significant impact. Fixes #1006. (And so unblocks updating to the newer setuptools required for #1248.)
- Loading branch information
Showing
6 changed files
with
17 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,7 +118,7 @@ | |
remote: -----> Inline app detected | ||
remote: ==> .heroku/python/lib/python.*/site-packages/easy-install.pth <== | ||
remote: /app/.heroku/src/gunicorn | ||
remote: /app/local_package | ||
remote: /tmp/build_.*/local_package | ||
remote: | ||
remote: ==> .heroku/python/lib/python.*/site-packages/gunicorn.egg-link <== | ||
remote: /app/.heroku/src/gunicorn | ||
|
@@ -140,7 +140,7 @@ | |
/app/.heroku/src/gunicorn | ||
. | ||
==> .heroku/python/lib/python.*/site-packages/local-package.egg-link <== | ||
/tmp/build_.*/local_package | ||
/app/local_package | ||
. | ||
Running entrypoint for the local package: Hello! | ||
Running entrypoint for the VCS package: gunicorn \\(version 20.1.0\\) | ||
|
@@ -159,17 +159,13 @@ | |
remote: Obtaining gunicorn from git\\+https://github.com/benoitc/[email protected]#egg=gunicorn \\(from -r /tmp/build_.*/requirements.txt \\(line 2\\)\\) | ||
remote: Cloning https://github.com/benoitc/gunicorn \\(to revision 20.1.0\\) to /app/.heroku/src/gunicorn | ||
remote: Installing collected packages: gunicorn, local-package | ||
remote: Attempting uninstall: gunicorn | ||
remote: Found existing installation: gunicorn 20.1.0 | ||
remote: Uninstalling gunicorn-20.1.0: | ||
remote: Successfully uninstalled gunicorn-20.1.0 | ||
remote: Running setup.py develop for gunicorn | ||
remote: Running setup.py develop for local-package | ||
remote: Successfully installed gunicorn local-package | ||
remote: -----> Running post-compile hook | ||
remote: ==> .heroku/python/lib/python.*/site-packages/easy-install.pth <== | ||
remote: /tmp/build_.*/local_package | ||
remote: /app/.heroku/src/gunicorn | ||
remote: /tmp/build_.*/local_package | ||
remote: | ||
remote: ==> .heroku/python/lib/python.*/site-packages/gunicorn.egg-link <== | ||
remote: /app/.heroku/src/gunicorn | ||
|
@@ -181,8 +177,8 @@ | |
remote: Running entrypoint for the VCS package: gunicorn \\(version 20.1.0\\) | ||
remote: -----> Inline app detected | ||
remote: ==> .heroku/python/lib/python.*/site-packages/easy-install.pth <== | ||
remote: /app/local_package | ||
remote: /app/.heroku/src/gunicorn | ||
remote: /tmp/build_.*/local_package | ||
remote: | ||
remote: ==> .heroku/python/lib/python.*/site-packages/gunicorn.egg-link <== | ||
remote: /app/.heroku/src/gunicorn | ||
|