Copy fields from pyproject.toml to source directory
Project description
poetry-plugin-pycopy
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.
Use case
FastAPI app in which you want to show application name or version in API docs.
Installation
From Pypi:
$ poetry self add poetry-plugin-pycopy
Usage
$ poetry pycopy
Plugin configuration in pyproject.toml
[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.
Output file example
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:
__name = "poetry-plugin-pycopy"
__version = "1.0.0"
__description = "Copy fields from pyproject.toml to source directory"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for poetry_plugin_pycopy-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8603bdf48fee764fa0cff23cd532259d5597dab99a37e4cff30c4f9e2c385f64 |
|
MD5 | c3098e524ef76d3f9c73d86a7e0a537d |
|
BLAKE2b-256 | 99ae7c187e1f1161a1dfe3169302f5423f65178c20c9d7ecd79f55b74a057482 |
Hashes for poetry_plugin_pycopy-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 618d54eec814ab87ca35af5d7bcb9f55f1d40e63016cd92cb8e3ffe9c74b2974 |
|
MD5 | e4aa4f0961f99cc12e6cf574019741d9 |
|
BLAKE2b-256 | e6883398c4f347b52f26d1e1a5e09244cf14d55d5b3a126187e9f772331a993f |