This plugin adds command pycopy
to Poetry which will copy information from pyproject.toml
to source
directory.
The goal is to have pyproject.toml
as a single source of truth for app version, name, description etc. and to have these values available during a program runtime.
FastAPI app in which you want to show application name or version in API docs.
From Pypi:
$ poetry self add poetry-plugin-pycopy
$ poetry pycopy
[tool.poetry-plugin-pycopy]
keys = ["name", "version", "description"]
dest_dir = "<some_package_name>"
dest_file = "__init__.py"
keys
list tells which fields should by copied from[tool.poetry]
dest_dir
is package/module rootdest_file
is the name of an output file
Plugin also runs with $poetry version
command automatically. So when you use version bump, e.g.: $poetry version patch
the plugin will copy the new version value into the output file.
The dest_file
is set to __init__.py
. Thus the plugin will create or replace that file with current values for a given keys
. For example:
pyproject_toml = {
"name": "test-venv-1",
"version": "0.1.0",
"description": "dsa",
}