Skip to content

Poetry plugin which copies project metadata like version, name, description etc. to code directory as /src or /project_name to be used during runtime.

License

Notifications You must be signed in to change notification settings

daaniam/poetry-plugin-pycopy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

poetry-plugin-pycopy

GitHub repo size GitHub contributors GitHub stars GitHub forks Twitter Follow

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 root
  • dest_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",
}

-> https://unlicense.org/

About

Poetry plugin which copies project metadata like version, name, description etc. to code directory as /src or /project_name to be used during runtime.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages