Skip to main content

Poetry Plugin: Package Info

PyPi Stable Version Pre-release Version Python Versions Code coverage Status PyTest pre-commit.ci status Download Stats License: MIT pre-commit Code Style

This package is a plugin that generates an package_info.py file with variables containing values from pyproject.toml and git.

Installation

The easiest way to install the package-info plugin is via the self add command of Poetry.

poetry self add poetry-plugin-package-info

If you used pipx to install Poetry you can add the plugin via the pipx inject command.

pipx inject poetry poetry-plugin-package-info

Otherwise, if you used pip to install Poetry you can add the plugin packages via the pip install command.

pip install poetry-plugin-plugin-package-info

Usage

By default, the package-info.py file is generated only when using the generage-package-info command in poetry,

poetry generate-package-info

The plugin can be enabled to run before poetry build command by adding the run-before-build to the project pyproject.toml file.

[tool.poetry-plugin-package-info]
run-before-build = true

The plugin can be re-configured in the pyproject.toml file, below are the options and their defaults.

[tool.poetry-plugin-package-info]

# Run before poetry build command
run-before-build = false

# The path relative to the pyproject.toml file
package-info-file-path = "package_name_in_snake_case/package_info.py"

# The line length to fit python code into.
line-length = 79

# The line separate to use.
line-separator = "\n"

# Any header code to put at the top of the file.
header = "# Auto-generated by poetry-plugin-package-info at {file-write-time}"

# Any foot code to put at the bottom of the file.
footer = ""

# Search parent directories (relative to pyproject.toml) for .git
git-search-parent-directories = false

# ordered list of variables to include in the file.
include = [
    "project-name",
    "project-description",
    "project-version",
    "project-homepage",
    "project-repository",
    "project-documentation",
    "project-classifiers",
    "project-authors",
    "project-license",
    "git-commit-id",
    "git-commit-author-name",
    "git-commit-author-email",
    "git-commit-timestamp",
    "git-branch-name",
    "git-branch-path",
    "git-has-staged-changes",
    "git-has-unstaged-changes",
    "git-has-changes"
]

Give the defaults, below is an example package_info.py file.

# File was auto-generated by poetry-plugin-package-info at 2023-06-05T00:35:43Z
__project_name__ = "my-project"
__project_description__ = "Some description."
__project_version__ = "1.2.3"
__project_homepage__ = "https://python-poetry.org"
__project_repository__ = "https://github.com/python-poetry/poetry"
__project_documentation__ = "https://python-poetry.org/docs"
__project_classifiers__ = [
                              "Topic :: Software Development :: Build Tools",
                              "Topic :: Software Development :: Libraries :: Python Mo"
                              "dules",
                          ]
__project_authors__ = [
                          "Ben Ellis <ben.ellis@softweyr.co.uk>",
                      ]
__project_license__ = "MIT"
__git_commit_id__ = "c4192bc5524b6905de5bcbdc0840e932c48d90ff"
__git_commit_author_name__ = "Ben Ellis"
__git_commit_author_email__ = "ben.ellis@softweyr.co.uk"
__git_commit_timestamp__ = "2023-06-05T01:27:30+01:00"
__git_branch_name__ = "main"
__git_branch_path__ = "refs/heads/main"
__git_has_staged_changes__ = False
__git_has_unstaged_changes__ = False
__git_has_changes__ = False

How-to

Change variable names

[tool.poetry-plugin-package-info]

includes = [
    "project-name",
    "project-description",
    "git-commit-id",
    { "property" = "git-is-dirty", "variable_name" = "clean_me" }
]

Related Projects

  • website: The official Poetry website and blog
  • poetry-plugin-export: Export Poetry projects/lock files to foreign formats like requirements.txt (Used some test code from this project)

Release files for poetry-plugin-package-info 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for poetry-plugin-package-info 0.1.0
File Size Uploaded
poetry_plugin_package_info-0.1.0.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for poetry-plugin-package-info 0.1.0
File Interpreter ABI Platform
poetry_plugin_package_info-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / poetry_plugin_package_info-0.1.0.tar.gz

Download URL poetry_plugin_package_info-0.1.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e168624e2a6a79b06f3d0f5c741d661c067d85a32dc80f5f33dcc5bd8088884b
BLAKE2b-256 checksum
How to use checksums
7b582854c332caf758569841c8b09233cd60953ccc7d756f852c6a66cf5e1089
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / poetry_plugin_package_info-0.1.0-py3-none-any.whl

Download URL poetry_plugin_package_info-0.1.0-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
962ddb88cd5752398c6cf1ad4ca081edc3e332a0e5ba6be3eea1a5bce3f1e464
BLAKE2b-256 checksum
How to use checksums
5b292df98d906336a8b3a8fb811968f10710521cf41807fb8f3d83a7f73e5381
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

1.0.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page