build-image
build-image copied to clipboard
Support Poetry for Python
Would it be possible to support the Poetry package manager for python site builders?
It works a bit like pipenv but has less buggy dependency resolution, and reads dependencies from the pyproject.toml file instead.
It can be detected by looking for its poetry.lock
file and running poetry install
Works now with this config:
[build]
publish = "site/"
command = """
restore_home_cache ".cache" "pip cache" &&
restore_cwd_cache '.venv' 'python virtualenv' &&
pip3 install -q poetry &&
poetry config settings.virtualenvs.in-project true &&
poetry install &&
poetry run mkdocs build
"""
Although first-class support would be really nice!
Could we get this re-evaluated? It seems the latest version of build images breaks this workaround:
https://app.netlify.com/sites/typical-python/deploys/5ede622683dcd06f1b4ff3db
I've moved my Python-based sites to GitLab Pages for the time being. There's another option I'm considering but not sure if it's OK to post it here as it's a direct competitor to Netlify :')
@seandstewart I've observed the exact same issue. Have you been able to work around it?
Removing the restore_home_cache
and restore_cwd_cache
lines works for me. Unfortunately, that means those directories are no longer cached, but the builds work so 🤷♀️
@ogazitt - I resolved to use a pre-commit hook to export my project's dependencies.
I have a starter one here: pre-commit-poetry-export
Unfortunately, I now have a use-case where I need to install my package in editable mode alongside the package dependencies, so this won't work for me. 😑
@Benaiah apologies for the direct tag, but do you have a recommended workflow for sources which use Poetry for dependency management that would allow us to continue caching builds?
Thanks @excitedleigh - I tried the same thing and it worked (without the caching of course).
Also thanks @seandstewart - great tip - I will try the pre-commit hook approach.
The restore_home_cache
and restore_cwd_cache
not no longer working. Here is my alternative approach, in case anyone is interested:
pip install -q poetry &&
poetry export --dev --without-hashes | grep mkdocs > requirements.txt &&
pip install -r requirements.txt &&
mkdocs build
Make sure you are using Python 3, see included_software.md.