+docs: build binary with mkPoetryApplication and build webserver wrapper binary

This commit is contained in:
Hung Tran 2023-03-14 15:55:21 -07:00 committed by GitHub
parent d45ca6fb03
commit 5f915f9500
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,6 +47,13 @@ Creates a Python application using the Python interpreter specified based on the
Other attributes are passed through to `buildPythonApplication`.
Make sure to add in your `pyproject.toml` the py-object for your `main()`. Otherwise, the result is empty.
```toml
[tool.poetry.scripts]
poetry = "poetry.console.application:main"
```
#### Example
```nix
poetry2nix.mkPoetryApplication {
@ -77,6 +84,8 @@ $ result/bin/python -m admin
$ result/bin/gunicorn web:app
```
If you prefer to build a single binary that runs `gunicorn web:app`, use [`pkgs.writeShellApplication`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L317) for a simple wrapper.
Note: If you need to perform overrides on the application, use `app.dependencyEnv.override { app = app.override { ... }; }`. See [./tests/dependency-environment/default.nix](./tests/dependency-environment/default.nix) for a full example.
### mkPoetryEnv