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:
pyproject_toml = {
"name": "test-venv-1",
"version": "0.1.0",
"description": "dsa",
}
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.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff5223da1a4029b85b73f5c6cf2bb738d94c9274f90a4c541f32e12ddb9570a9 |
|
MD5 | 1428e9841c693c9099a45f692c06d754 |
|
BLAKE2b-256 | 48c2f3e52a2da7177bdfa2e9df59c8d68f6b470533b19128052fa703d5a9e361 |
Hashes for poetry_plugin_pycopy-1.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36b01c7fb6fdc577dbc5ce1fb14d3ef493d5e0dde416c92b4ca3257698cfc12a |
|
MD5 | 718fe01f87498371b6f544e1e671a7b6 |
|
BLAKE2b-256 | d5174428db43d67e0fc2e7cc170dec827ba5670cc99abbc19f142b5b680e0bd7 |