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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file poetry_plugin_pycopy-1.0.6.tar.gz.

File metadata

  • Download URL: poetry_plugin_pycopy-1.0.6.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.6 Linux/5.15.0-52-generic

File hashes

Hashes for poetry_plugin_pycopy-1.0.6.tar.gz
Algorithm Hash digest
SHA256 ff5223da1a4029b85b73f5c6cf2bb738d94c9274f90a4c541f32e12ddb9570a9
MD5 1428e9841c693c9099a45f692c06d754
BLAKE2b-256 48c2f3e52a2da7177bdfa2e9df59c8d68f6b470533b19128052fa703d5a9e361

See more details on using hashes here.

File details

Details for the file poetry_plugin_pycopy-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: poetry_plugin_pycopy-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.6 Linux/5.15.0-52-generic

File hashes

Hashes for poetry_plugin_pycopy-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 36b01c7fb6fdc577dbc5ce1fb14d3ef493d5e0dde416c92b4ca3257698cfc12a
MD5 718fe01f87498371b6f544e1e671a7b6
BLAKE2b-256 d5174428db43d67e0fc2e7cc170dec827ba5670cc99abbc19f142b5b680e0bd7

See more details on using hashes here.

Supported by

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