python-poetry-buildpack
python-poetry-buildpack copied to clipboard
Python version extraction breaks if a trailing space exists
Hello! It appears that Python version extraction is currently breaking if the python-versions = "x.x.x"
line in poetry.lock
includes a trailing space. This trailing space will be added if the Python version specification in pyproject.toml
also includes a trailing space. I found this because the VSCode TOML plugin I am using adds these spaces: https://github.com/oovm/vscode-toml/issues/7.
When that happens, the Heroku build fails with the following message:
-----> 3.9.11 is not valid, please specify an exact Python version (e.g. 3.8.1) in your pyproject.toml (and thus poetry.lock)
To make this more robust, I propose that we strip out spaces in this command: https://github.com/moneymeets/python-poetry-buildpack/blob/868d88bd7a4b11e62d57dbf673394ebf38962857/bin/compile#L85
I may have a chance to contribute a patch, but wanted to put this up in case someone else gets to it first!
Oh, that's a good catch. I wonder if adjusting tr
set would be enough:
-PYTHON_RUNTIME_VERSION="$(sed -n -e '/^\[metadata\]/,/^\[/p' poetry.lock | sed -n -e 's/^python-versions\s*=\s*//p' | tr -d \"\')"
+PYTHON_RUNTIME_VERSION="$(sed -n -e '/^\[metadata\]/,/^\[/p' poetry.lock | sed -n -e 's/^python-versions\s*=\s*//p' | tr -d \" \')"
A PR with a test would be appreciated.
Since we are at it, maybe you could have a look @felix11h ?
Since we are at it, maybe you could have a look @felix11h ?
Sure thing, I will have a look! I'm hoping to get to it next week.