Skip to main content

Copy fields from pyproject.toml to source directory

Project description

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/

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

poetry_plugin_pycopy-1.0.6.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

poetry_plugin_pycopy-1.0.6-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page