Comments (3)
@arel Hi! Thank you for filing an issue.
On 2023-11-30 the version of pipenv was updated from 2023.7.23
to 2023.11.15
(plus setuptools was upgraded):
https://github.com/heroku/heroku-buildpack-python/blob/main/CHANGELOG.md#v240---2023-11-30
If pipenv related behaviour has changed recently, then it's likely the new version of pipenv is the cause.
I will take a look at the repro you have provided soon (a minimal repro like that is very helpful, thank you!) - however, we are in the middle of a production change freeze until January due to the holidays, so I won't be able to make any changes to the buildpack until then (and I'm shortly going to be away myself).
To switch back to the old pipenv version in the meantime, you can use a buildpack URL of:
https://github.com/heroku/heroku-buildpack-python.git#v239
See:
https://devcenter.heroku.com/articles/buildpacks#buildpack-references
https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-buildpacks-set-buildpack
from heroku-buildpack-python.
Hi, @edmorley! I appreciate the fast response! That seems like a likely culprit.
I think the issue would affect any python package installed in site-packages (as egg-link
, .pth
, or *_finder.py
) that references the build directory, since that only gets rewritten at runtime and I presume the build directory is ephemeral.
heroku-buildpack-python/bin/compile
Lines 303 to 310 in edcd18b
One potential solution would be to broaden the replace-pattern to match any Heroku build directory. Or, better, you could cache a list of all prior build directories and change the line above to replace any of them that are found.
Have a nice vacation, and happy holidays!
from heroku-buildpack-python.
I've managed to track this down - it's actually a combination of a few separate issues.
First, the reason this started affecting your builds only recently, is that between Pipenv v2023.7.23
and v2023.8.19
an upstream regression was introduced, which changed the installation mode for local file =
dependencies from being a standard install, to being an editable install.
That is, a dependency specifier like so:
[packages]
mypackage = {file = "packages/mypackage"}
...would previously have been installed as non-editable, whereas now it's installed as though editable = true
had been specified.
Worse, it appears that even if one includes an explicit editable = false
(note: false) to try and disable editable installation mode, it doesn't do anything.
I've filed this regression as:
pypa/pipenv#6054
Whilst this was still a regression, the only reason it caused issues here is that there was a pre-existing bug in the buildpack around local file =
dependencies when installed in editable mode (as you noted).
Specifically, the current path rewriting handling relies on the fact that that we expect the installer to always be re-run to fix up any stale paths from the previous build.
(There's some backstory on the path rewriting in #1006 and #1252. The fact that paths change between build-time and run-time is a massive pain and thankfully going away with the next generation Cloud Native Buildpacks aka CNBs, xref CNB spec and the WIP Python CNB)
This re-running of the installer always occurs for standard Pip builds (since requirements files are non-deterministic given e.g. transitive deps, includes etc), and already occurred for Git VCS Pipenv builds (via this fragile check), however, there was no check for local path =
file dependency builds.
I also found another bug unrelated to path rewriting (#1525), which makes me think that we should just never skip pipenv install
as the lockfile is still not always deterministic, and instead defer to Pipenv to decide whether an environment needs updating.
One potential solution would be to broaden the replace-pattern to match any Heroku build directory.
So the problem with trying to match any build directory is that we would have to hardcode the expected build path style in the buildpack (eg via a hardcoded /tmp/build_*
glob), and that path (a) is not guaranteed to stay the same over time on Heroku (in fact it's already changed once in the last couple of years), (b) could be a completely different path on non-Heroku platforms (this buildpack is used by eg Dokku and others).
Or, better, you could cache a list of all prior build directories and change the line above to replace any of them that are found.
Yeah one solution would be to:
- During each build, store the current build directory path in the build cache at a known location
- At the start of each cached build, rewrite paths in the restored-from-cache
site-packages
fromOLD_BUILD_DIR
toNEW_BUILD_DIR
However:
- this still wouldn't help the first build of apps that occurs after the fix lands, since they won't have a cached previous build directory - so we'd either need another fix as well, or to force the cache to be cleaned
- it adds more implementation (and test permutation) complexity, when our primary focus for new development is the upcoming CNBs (which don't need path rewriting)
- we still need to re-run
pipenv install
for cached builds to resolve issues not related to path rewriting (such as #1525), and re-runningpipenv install
resolves this issue in a simpler way
I've opened #1526, which resolves the issue when tested against https://github.com/arel/debug-heroku-pipenv and also adds integration tests for editable Pipenv installs (the buildpack previously only tested editable installs with Pip).
Note: I ran into setuptools related import errors on the first rebuild using the fix branch of the buildpack - clearing the build cache resolved these. I believe they are caused by the debug-heroku-pipenv
repo having a very old setuptools version in its lockfile, which can cause issues depending on which order Pipenv attempts to install packages. There is possibly another upstream Pipenv bug causing this, but for now I'd recommend keeping your lockfile up to date, so the setuptools version in there is compatible with what gets pulled in via Pipenv itself.
from heroku-buildpack-python.
Related Issues (20)
- Setuptools no longer compatible with pinned version of pipenv when used with git-repo version spec and multiple install_requires HOT 3
- PYPY36 and PYPY27 is not available for stack (heroku-22) HOT 3
- Python 3.10.5 buildpack run results in "error while loading shared libraries: libpython3.10.so.1.0" HOT 6
- Support the PDM package manager HOT 7
- Add warning when using `tensorflow` rather than `tensorflow-cpu`
- Simple Django project deploys successfully on v218, fails on v219 and following HOT 2
- Possible out-of-date setuptools /wheel versions HOT 4
- upgrade to stack heroku-22 using python version 3.6.7. is it possible? HOT 2
- Problem trying to deploy in heroku-22 anyjson setup command: use_2to3 is invalid. HOT 2
- Heroku problem with redis conection HOT 1
- pipenv cache is skipped when it should not be HOT 3
- Error running locally built image with pack: Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding HOT 4
- Can I change the python source? HOT 1
- `Requested runtime 'python-3.X.Y' is not available for this stack` due to hitting curl connection timeouts on Dokku HOT 3
- Add support for config vars in Pip requirements files HOT 4
- Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, HOT 4
- Streamlit application w Anaconda requirements to be deployed w Heroku HOT 2
- Pipenv install is skipped in cases where it's not safe to do so
- Source repos for editable Pipenv VCS installs are not cached between builds
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from heroku-buildpack-python.