This tool facilitates syncing of the project and the tool.poetry tables in your pyproject.toml.
Project description
Check PyProject
Table of Contents
Overview
Checks that [project] and [tool.poetry] tables are mostly in-sync in the
pyproject.toml
file.
The Python Packaging User Guide now specifies pyproject.toml
metadata.
Poetry <2.0 predates the metadata specification and instead used the then current standard of [tool.poetry] table. While there is a lot of overlap, there are some differences (ex. dependency package specifiers). Poetry 2.0 will support PyPA pyproject.toml specification (formerly PEP 621) which will obsolete this utility.
So if your project uses poetry and any other tool that requires the current pyproject.toml metadata, or you are prepping for Poetry 2.0 and do not want to use the development version of Poetry. then you need to manually maintain sync between [project] and [tool.poetry] tables.
This tool checks that overlapping metadata, between [project] and [tool.poetry] tables, are roughly in-sync.
Usage
The default usage will check the pyproject.toml file in the current directory showing everything it is checking. You probably ought to run this at least once to see what fields check_pyproject does not check. The last line is the number of issues found.
➤ check_pyproject
Checking: "pyproject.toml"
Reading pyproject.toml file: pyproject.toml
"name" found in both [project] and [tool.poetry]
"description" found in both [project] and [tool.poetry]
"readme" found in both [project] and [tool.poetry]
"version" found in both [project] and [tool.poetry]
"scripts" found in both [project] and [tool.poetry]
"urls" found in both [project] and [tool.poetry]
"keywords" found in both [project] and [tool.poetry]
"classifiers" found in both [project] and [tool.poetry]
"authors" found in both [project] and [tool.poetry]
"maintainers" found in both [project] and [tool.poetry]
Fields not checked in [project]: ['dynamic', 'license', 'requires-python']
Fields not checked in [tool.poetry]: ['documentation', 'homepage', 'include', 'license', 'packages', 'repository']
Note that the license tables have completely different formats between
[project] (takes either a file or a text attribute of the actual license and [tool.poetry] (takes the name of the license), so both must be manually set.
Check pyproject.toml file: pyproject.toml => 0 problems detected.
You can run check_pyproject quietly, where just issues are emitted. Here's an example where you specify the pyproject.toml file and find a version mismatch:
➤ check_pyproject --quiet pyproject.toml
Values do not match between project.version and tool.poetry.version.
Differences:
"0.1.1"
vs.
"0.1.1a1"
The most common issue check_pyproject finds is adding a dependency in only one table:
➤ check_pyproject --quiet
Dependencies "test" Differences:
project: []
vs
poetry: ["pytest-xdist[psutil]<4.0.0,>=3.6.1"]
Notice that the poetry version has been converted from the poetry syntax:
pytest-xdist = {extras = ["psutil"], version = "^3.6.1"}
to PEP-508 which is what the project table requires, facilitating copying the
dependency in check_pyproject's output, "pytest-xdist[psutil]<4.0.0,>=3.6.1"
,
to the project table's appropriate dependency table.
Installation
PyPI Installation
pip install check_pyproject
Development installation
Development Prerequisites
-
Install the task manager: Task
-
Optionally install pyenv-installer
-
Install dependent pythons, example:
pyenv local 3.11.9 3.12.3
Note you may need to install some libraries for the pythons to compile cleanly. For example on ubuntu (note I prefer
nala
overapt
):sudo nala install tk-dev libbz2-dev libreadline-dev libsqlite3-dev lzma-dev python3-tk libreadline-dev
-
-
Recommended to upgrade pip to latest.
-
Optionally install Poetry
-
Optionally install Hatch
-
Optionally install setuptools
- Install build
Install the package using your favorite dev tool. Examples:
git clone git@github.com:royw/check_pyproject.git
cd check_pyproject
task init
task make
Note, task init
will run git init .
, git add
the initial project files,
and do a git commit
. If you are using another VCS, please first edit the init
task in the Taskfile.yaml
file.
See the Developer README for detailed information on the development environment.
License
check_pyproject
is distributed under the terms of the
MIT license.
References
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
File details
Details for the file check_pyproject-0.1.1.tar.gz
.
File metadata
- Download URL: check_pyproject-0.1.1.tar.gz
- Upload date:
- Size: 132.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4003b55dd21447e385d61a9807cb008b938ea6b9cc6613470732cef8f6766732 |
|
MD5 | f0dea4f06fe27fd6ed925263ecdf406d |
|
BLAKE2b-256 | 01333fe3f58eb080711730d804322806dcb46f1717c979897c8cf36fc2c9f061 |
File details
Details for the file check_pyproject-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: check_pyproject-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d8b08536f06e4f2cb1af9a48d826eb489c529e2f5c4a09c3b21a6df59e9c55f |
|
MD5 | 20011037cdc2e9b12b389569483f15bf |
|
BLAKE2b-256 | bf6fce7d59765dc512a21b535fdeb129f4dcd7a7200acf1c52684556ac9f952d |