Plugin for poetry that creates/updates an package_info.py file with various details about the project/package.
Project description
Poetry Plugin: Package Info
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)
Project details
Release history Release notifications | RSS feed
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_package_info-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e168624e2a6a79b06f3d0f5c741d661c067d85a32dc80f5f33dcc5bd8088884b |
|
MD5 | 0a3880658d2f3fa8e1ed67566b896c57 |
|
BLAKE2b-256 | 7b582854c332caf758569841c8b09233cd60953ccc7d756f852c6a66cf5e1089 |
Hashes for poetry_plugin_package_info-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 962ddb88cd5752398c6cf1ad4ca081edc3e332a0e5ba6be3eea1a5bce3f1e464 |
|
MD5 | c831a77996bb72d99931d3a4cacfb9db |
|
BLAKE2b-256 | 5b292df98d906336a8b3a8fb811968f10710521cf41807fb8f3d83a7f73e5381 |