使用 poetry 环境在 heroku 中部署 django 应用程序

Deploy django app in heroku with poetry environment

我在很多实践项目中使用 poetry 已经有一段时间了,但直到现在还没有部署任何东西,当我尝试在 heroku 中部署时,我遇到了这个错误。

-----> Installing python-3.9.1
-----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
-----> Installing SQLite3
-----> Installing requirements with pip
       Processing /home/santi/.cache/pypoetry/artifacts/9c/90/26/d9fa1dfd567d8ba46faa44b741eb6442f3b97eb9f10a40bc1ad7a7f10e/asgiref-3.3.1-py3-none-any.whl
       ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/santi/.cache/pypoetry/artifacts/9c/90/26/d9fa1dfd567d8ba46faa44b741eb6442f3b97eb9f10a40bc1ad7a7f10e/asgiref-3.3.1-py3-none-any.whl'
       
 !     Push rejected, failed to compile Python app.
 !     Push failed

我似乎找不到任何关于这个 django-poetry-heroku 问题的具体信息,所以也许我可以在这里找到一些帮助,我有我的 petry.lock 和 .toml 文件,还有一个 requirements.txt 因为 heroku 需要它,所以它们在这里...

pyproject.toml
[tool.poetry]
name = "Team Wool Capstone App"
version = "0.1.0"
description = "News app with likes, and user submission feature"
authors = ["Joseph Dubon <josephdubon@pm.me>"]

[tool.poetry.dependencies]
python = "^3.9"
Django = "^3.1.7"
flake8 = "^3.9.0"
Pillow = "^8.2.0"
whitenoise = "^5.2.0"
django-environ = "^0.4.5"
gunicorn = "^20.1.0"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

您是否正在使用 heroku buildpack 编写诗歌? Heroku 在构建 python 项目时只读取 requirements.txt 文件,你需要设置多个配置变量并明确告诉 heroku 使用 poetry buildpack。

heroku buildpacks:clear
heroku buildpacks:add https://github.com/moneymeets/python-poetry-buildpack.git
heroku buildpacks:add heroku/python

Check this link out to see more explicit directions