build-image icon indicating copy to clipboard operation
build-image copied to clipboard

Support Poetry for Python

Open danielknell opened this issue 6 years ago • 8 comments

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

danielknell avatar Nov 17 '18 21:11 danielknell

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!

notpushkin avatar Jun 21 '19 10:06 notpushkin

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

seandstewart avatar Jun 08 '20 16:06 seandstewart

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 :')

notpushkin avatar Jun 09 '20 00:06 notpushkin

@seandstewart I've observed the exact same issue. Have you been able to work around it?

ogazitt avatar Jun 16 '20 08:06 ogazitt

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 🤷‍♀️

daisylb avatar Jun 16 '20 09:06 daisylb

@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?

seandstewart avatar Jun 16 '20 12:06 seandstewart

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.

ogazitt avatar Jun 16 '20 20:06 ogazitt

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.

queensferryme avatar Oct 13 '21 12:10 queensferryme