A helper to deploy poetry based python api server project.
Most of the codes are copied from Vercel's Python Package.
This module imitates the behavior of @vercel/python package.
Use this module in your builds
option in vercel.json
.
Check vercel-poetry-test repository to see the examples
{
...
"builds": [
{
"src": "api/main.py", // The file containing the main app (e.g. FastAPI)
"use": "@devjin8/vercel-poetry@latest"
}
],
// place custom redirects / rewrites here
}
The original @vercel/python
package installs dependencies from requirements.txt
into the current working path in the build process.
This module updated the behavior building process as the followings.
-
Removed
Pipfile.lock
file check. -
Install the
setuptools
andpoetry
module using current python environment. (Check Installing Poetry Manually.)Code is here
-
Creates the
requirements.txt
file using the following command.python -m poetry export --without-hashes -f requirements.txt --output requirements.txt
Code is here
The exact copy of vc_init.py
at https://github.com/vercel/vercel/blob/main/packages/python/vc_init.py
This file will be written as vc__handler__python.py
in work directory and will be the main entry file of web app.
It checks our app
(Django/Flask/FastAPI) or handler
(which are defined as entry point in vercel.json
file), and run WSGI, ASGI or Basic HTTP Server.