validate-pyproject


Namevalidate-pyproject JSON
Version 0.23 PyPI version JSON
download
home_pageNone
SummaryValidation library and CLI tool for checking on 'pyproject.toml' files using JSON Schema
upload_time2024-11-11 15:02:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMPL-2.0 and MIT and BSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            .. These are examples of badges you might want to add to your README:
   please update the URLs accordingly

    .. image:: https://img.shields.io/conda/vn/conda-forge/validate-pyproject.svg
        :alt: Conda-Forge
        :target: https://anaconda.org/conda-forge/validate-pyproject
    .. image:: https://pepy.tech/badge/validate-pyproject/month
        :alt: Monthly Downloads
        :target: https://pepy.tech/project/validate-pyproject
    .. image:: https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Twitter
        :alt: Twitter
        :target: https://twitter.com/validate-pyproject

.. image:: https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold
    :alt: Project generated with PyScaffold
    :target: https://pyscaffold.org/
.. image:: https://api.cirrus-ci.com/github/abravalheri/validate-pyproject.svg?branch=main
    :alt: Built Status
    :target: https://cirrus-ci.com/github/abravalheri/validate-pyproject
.. image:: https://readthedocs.org/projects/validate-pyproject/badge/?version=latest
    :alt: ReadTheDocs
    :target: https://validate-pyproject.readthedocs.io
.. image:: https://img.shields.io/coveralls/github/abravalheri/validate-pyproject/main.svg
    :alt: Coveralls
    :target: https://coveralls.io/r/abravalheri/validate-pyproject
.. image:: https://img.shields.io/pypi/v/validate-pyproject.svg
    :alt: PyPI-Server
    :target: https://pypi.org/project/validate-pyproject/

|

==================
validate-pyproject
==================


    Automated checks on ``pyproject.toml`` powered by JSON Schema definitions


.. important:: This project is **experimental** and under active development.
   Issue reports and contributions are very welcome.


Description
===========

With the approval of `PEP 517`_ and `PEP 518`_, the Python community shifted
towards a strong focus on standardisation for packaging software, which allows
more freedom when choosing tools during development and make sure packages
created using different technologies can interoperate without the need for
custom installation procedures.

This shift became even more clear when `PEP 621`_ was also approved, as a
standardised way of specifying project metadata and dependencies.

``validate-pyproject`` was born in this context, with the mission of validating
``pyproject.toml`` files, and make sure they are compliant with the standards
and PEPs. Behind the scenes, ``validate-pyproject`` relies on `JSON Schema`_
files, which, in turn, are also a standardised way of checking if a given data
structure complies with a certain specification.


.. _installation:

Usage
=====

The easiest way of using ``validate-pyproject`` is via CLI.
To get started, you need to install the package, which can be easily done
using |pipx|_:

.. code-block:: bash

    $ pipx install 'validate-pyproject[all]'

Now you can use ``validate-pyproject`` as a command line tool:

.. code-block:: bash

    # in you terminal
    $ validate-pyproject --help
    $ validate-pyproject path/to/your/pyproject.toml

You can also use ``validate-pyproject`` in your Python scripts or projects:

.. _example-api:

.. code-block:: python

    # in your python code
    from validate_pyproject import api, errors

    # let's assume that you have access to a `loads` function
    # responsible for parsing a string representing the TOML file
    # (you can check the `toml` or `tomli` projects for that)
    pyproject_as_dict = loads(pyproject_toml_str)

    # now we can use validate-pyproject
    validator = api.Validator()

    try:
        validator(pyproject_as_dict)
    except errors.ValidationError as ex:
        print(f"Invalid Document: {ex.message}")

To do so, don't forget to add it to your `virtual environment`_ or specify it as a
`project`_ or `library dependency`_.

.. note::
   When you install ``validate-pyproject[all]``, the packages ``tomli``,
   ``packaging`` and ``trove-classifiers`` will be automatically pulled as
   dependencies. ``tomli`` is a lightweight parser for TOML, while
   ``packaging`` and ``trove-classifiers`` are used to validate aspects of `PEP
   621`_.

   If you are only interested in using the Python API and wants to keep the
   dependencies minimal, you can also install ``validate-pyproject``
   (without the ``[all]`` extra dependencies group).

   If you don't install ``trove-classifiers``, ``validate-pyproject`` will
   try to download a list of valid classifiers directly from PyPI
   (to prevent that, set the environment variable
   ``NO_NETWORK`` or ``VALIDATE_PYPROJECT_NO_NETWORK``).

   On the other hand, if ``validate-pyproject`` cannot find a copy of
   ``packaging`` in your environment, the validation will fail.

More details about ``validate-pyproject`` and its Python API can be found in
`our docs`_, which includes a description of the `used JSON schemas`_,
instructions for using it in a |pre-compiled way|_ and information about
extending the validation with your own plugins_.

.. _pyscaffold-notes:

.. tip::
   If you consider contributing to this project, have a look on our
   `contribution guides`_.

Plugins
=======

The `validate-pyproject-schema-store`_ plugin has a vendored copy of
pyproject.toml related `SchemaStore`_ entries.  You can even install this using
the ``[store]`` extra:

    $ pipx install 'validate-pyproject[all,store]'

Some of the tools in SchemaStore also have integrated validate-pyproject
plugins, like ``cibuildwheel`` and ``scikit-build-core``. However, unless you
want to pin an exact version of those tools, the SchemaStore copy is lighter
weight than installing the entire package.

If you want to write a custom plugin for your tool, please consider also contributing a copy to SchemaStore.

pre-commit
==========

``validate-pyproject`` can be installed as a pre-commit hook:

.. code-block:: yaml

    ---
    repos:
      - repo: https://github.com/abravalheri/validate-pyproject
        rev: <insert current version here>
        hooks:
          - id: validate-pyproject
            # Optional extra validations from SchemaStore:
            additional_dependencies: ["validate-pyproject-schema-store[all]"]

By default, this ``pre-commit`` hook will only validate the ``pyproject.toml``
file at the root of the project repository.
You can customize that by defining a `custom regular expression pattern`_ using
the ``files`` parameter.

You can also use ``pre-commit autoupdate`` to update to the latest stable
version of ``validate-pyproject`` (recommended).

You can also use `validate-pyproject-schema-store`_ as a pre-commit hook, which
allows pre-commit to pin and update that instead of ``validate-pyproject`` itself.

Note
====

This project and its sister project ini2toml_ were initially created in the
context of PyScaffold, with the purpose of helping migrating existing projects
to `PEP 621`_-style configuration when it is made available on ``setuptools``.
For details and usage information on PyScaffold see https://pyscaffold.org/.


.. |pipx| replace:: ``pipx``
.. |pre-compiled way| replace:: *pre-compiled* way


.. _contribution guides: https://validate-pyproject.readthedocs.io/en/latest/contributing.html
.. _custom regular expression pattern: https://pre-commit.com/#regular-expressions
.. _our docs: https://validate-pyproject.readthedocs.io
.. _ini2toml: https://ini2toml.readthedocs.io
.. _JSON Schema: https://json-schema.org/
.. _library dependency: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html
.. _PEP 517: https://peps.python.org/pep-0517/
.. _PEP 518: https://peps.python.org/pep-0518/
.. _PEP 621: https://peps.python.org/pep-0621/
.. _pipx: https://pipx.pypa.io/stable/
.. _project: https://packaging.python.org/tutorials/managing-dependencies/
.. _setuptools: https://setuptools.pypa.io/en/stable/
.. _used JSON schemas: https://validate-pyproject.readthedocs.io/en/latest/schemas.html
.. _pre-compiled way: https://validate-pyproject.readthedocs.io/en/latest/embedding.html
.. _plugins: https://validate-pyproject.readthedocs.io/en/latest/dev-guide.html
.. _virtual environment: https://realpython.com/python-virtual-environments-a-primer/
.. _validate-pyproject-schema-store: https://github.com/henryiii/validate-pyproject-schema-store
.. _SchemaStore: https://www.schemastore.org

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "validate-pyproject",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Anderson Bravalheri <andersonbravalheri@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/5c/07/b24689b11ef23226bdd3eebd8d89e103236f4c91043b71d707612a4c3ad7/validate_pyproject-0.23.tar.gz",
    "platform": null,
    "description": ".. These are examples of badges you might want to add to your README:\n   please update the URLs accordingly\n\n    .. image:: https://img.shields.io/conda/vn/conda-forge/validate-pyproject.svg\n        :alt: Conda-Forge\n        :target: https://anaconda.org/conda-forge/validate-pyproject\n    .. image:: https://pepy.tech/badge/validate-pyproject/month\n        :alt: Monthly Downloads\n        :target: https://pepy.tech/project/validate-pyproject\n    .. image:: https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Twitter\n        :alt: Twitter\n        :target: https://twitter.com/validate-pyproject\n\n.. image:: https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold\n    :alt: Project generated with PyScaffold\n    :target: https://pyscaffold.org/\n.. image:: https://api.cirrus-ci.com/github/abravalheri/validate-pyproject.svg?branch=main\n    :alt: Built Status\n    :target: https://cirrus-ci.com/github/abravalheri/validate-pyproject\n.. image:: https://readthedocs.org/projects/validate-pyproject/badge/?version=latest\n    :alt: ReadTheDocs\n    :target: https://validate-pyproject.readthedocs.io\n.. image:: https://img.shields.io/coveralls/github/abravalheri/validate-pyproject/main.svg\n    :alt: Coveralls\n    :target: https://coveralls.io/r/abravalheri/validate-pyproject\n.. image:: https://img.shields.io/pypi/v/validate-pyproject.svg\n    :alt: PyPI-Server\n    :target: https://pypi.org/project/validate-pyproject/\n\n|\n\n==================\nvalidate-pyproject\n==================\n\n\n    Automated checks on ``pyproject.toml`` powered by JSON Schema definitions\n\n\n.. important:: This project is **experimental** and under active development.\n   Issue reports and contributions are very welcome.\n\n\nDescription\n===========\n\nWith the approval of `PEP 517`_ and `PEP 518`_, the Python community shifted\ntowards a strong focus on standardisation for packaging software, which allows\nmore freedom when choosing tools during development and make sure packages\ncreated using different technologies can interoperate without the need for\ncustom installation procedures.\n\nThis shift became even more clear when `PEP 621`_ was also approved, as a\nstandardised way of specifying project metadata and dependencies.\n\n``validate-pyproject`` was born in this context, with the mission of validating\n``pyproject.toml`` files, and make sure they are compliant with the standards\nand PEPs. Behind the scenes, ``validate-pyproject`` relies on `JSON Schema`_\nfiles, which, in turn, are also a standardised way of checking if a given data\nstructure complies with a certain specification.\n\n\n.. _installation:\n\nUsage\n=====\n\nThe easiest way of using ``validate-pyproject`` is via CLI.\nTo get started, you need to install the package, which can be easily done\nusing |pipx|_:\n\n.. code-block:: bash\n\n    $ pipx install 'validate-pyproject[all]'\n\nNow you can use ``validate-pyproject`` as a command line tool:\n\n.. code-block:: bash\n\n    # in you terminal\n    $ validate-pyproject --help\n    $ validate-pyproject path/to/your/pyproject.toml\n\nYou can also use ``validate-pyproject`` in your Python scripts or projects:\n\n.. _example-api:\n\n.. code-block:: python\n\n    # in your python code\n    from validate_pyproject import api, errors\n\n    # let's assume that you have access to a `loads` function\n    # responsible for parsing a string representing the TOML file\n    # (you can check the `toml` or `tomli` projects for that)\n    pyproject_as_dict = loads(pyproject_toml_str)\n\n    # now we can use validate-pyproject\n    validator = api.Validator()\n\n    try:\n        validator(pyproject_as_dict)\n    except errors.ValidationError as ex:\n        print(f\"Invalid Document: {ex.message}\")\n\nTo do so, don't forget to add it to your `virtual environment`_ or specify it as a\n`project`_ or `library dependency`_.\n\n.. note::\n   When you install ``validate-pyproject[all]``, the packages ``tomli``,\n   ``packaging`` and ``trove-classifiers`` will be automatically pulled as\n   dependencies. ``tomli`` is a lightweight parser for TOML, while\n   ``packaging`` and ``trove-classifiers`` are used to validate aspects of `PEP\n   621`_.\n\n   If you are only interested in using the Python API and wants to keep the\n   dependencies minimal, you can also install ``validate-pyproject``\n   (without the ``[all]`` extra dependencies group).\n\n   If you don't install ``trove-classifiers``, ``validate-pyproject`` will\n   try to download a list of valid classifiers directly from PyPI\n   (to prevent that, set the environment variable\n   ``NO_NETWORK`` or ``VALIDATE_PYPROJECT_NO_NETWORK``).\n\n   On the other hand, if ``validate-pyproject`` cannot find a copy of\n   ``packaging`` in your environment, the validation will fail.\n\nMore details about ``validate-pyproject`` and its Python API can be found in\n`our docs`_, which includes a description of the `used JSON schemas`_,\ninstructions for using it in a |pre-compiled way|_ and information about\nextending the validation with your own plugins_.\n\n.. _pyscaffold-notes:\n\n.. tip::\n   If you consider contributing to this project, have a look on our\n   `contribution guides`_.\n\nPlugins\n=======\n\nThe `validate-pyproject-schema-store`_ plugin has a vendored copy of\npyproject.toml related `SchemaStore`_ entries.  You can even install this using\nthe ``[store]`` extra:\n\n    $ pipx install 'validate-pyproject[all,store]'\n\nSome of the tools in SchemaStore also have integrated validate-pyproject\nplugins, like ``cibuildwheel`` and ``scikit-build-core``. However, unless you\nwant to pin an exact version of those tools, the SchemaStore copy is lighter\nweight than installing the entire package.\n\nIf you want to write a custom plugin for your tool, please consider also contributing a copy to SchemaStore.\n\npre-commit\n==========\n\n``validate-pyproject`` can be installed as a pre-commit hook:\n\n.. code-block:: yaml\n\n    ---\n    repos:\n      - repo: https://github.com/abravalheri/validate-pyproject\n        rev: <insert current version here>\n        hooks:\n          - id: validate-pyproject\n            # Optional extra validations from SchemaStore:\n            additional_dependencies: [\"validate-pyproject-schema-store[all]\"]\n\nBy default, this ``pre-commit`` hook will only validate the ``pyproject.toml``\nfile at the root of the project repository.\nYou can customize that by defining a `custom regular expression pattern`_ using\nthe ``files`` parameter.\n\nYou can also use ``pre-commit autoupdate`` to update to the latest stable\nversion of ``validate-pyproject`` (recommended).\n\nYou can also use `validate-pyproject-schema-store`_ as a pre-commit hook, which\nallows pre-commit to pin and update that instead of ``validate-pyproject`` itself.\n\nNote\n====\n\nThis project and its sister project ini2toml_ were initially created in the\ncontext of PyScaffold, with the purpose of helping migrating existing projects\nto `PEP 621`_-style configuration when it is made available on ``setuptools``.\nFor details and usage information on PyScaffold see https://pyscaffold.org/.\n\n\n.. |pipx| replace:: ``pipx``\n.. |pre-compiled way| replace:: *pre-compiled* way\n\n\n.. _contribution guides: https://validate-pyproject.readthedocs.io/en/latest/contributing.html\n.. _custom regular expression pattern: https://pre-commit.com/#regular-expressions\n.. _our docs: https://validate-pyproject.readthedocs.io\n.. _ini2toml: https://ini2toml.readthedocs.io\n.. _JSON Schema: https://json-schema.org/\n.. _library dependency: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html\n.. _PEP 517: https://peps.python.org/pep-0517/\n.. _PEP 518: https://peps.python.org/pep-0518/\n.. _PEP 621: https://peps.python.org/pep-0621/\n.. _pipx: https://pipx.pypa.io/stable/\n.. _project: https://packaging.python.org/tutorials/managing-dependencies/\n.. _setuptools: https://setuptools.pypa.io/en/stable/\n.. _used JSON schemas: https://validate-pyproject.readthedocs.io/en/latest/schemas.html\n.. _pre-compiled way: https://validate-pyproject.readthedocs.io/en/latest/embedding.html\n.. _plugins: https://validate-pyproject.readthedocs.io/en/latest/dev-guide.html\n.. _virtual environment: https://realpython.com/python-virtual-environments-a-primer/\n.. _validate-pyproject-schema-store: https://github.com/henryiii/validate-pyproject-schema-store\n.. _SchemaStore: https://www.schemastore.org\n",
    "bugtrack_url": null,
    "license": "MPL-2.0 and MIT and BSD-3-Clause",
    "summary": "Validation library and CLI tool for checking on 'pyproject.toml' files using JSON Schema",
    "version": "0.23",
    "project_urls": {
        "Changelog": "https://validate-pyproject.readthedocs.io/en/latest/changelog.html",
        "Documentation": "https://validate-pyproject.readthedocs.io/",
        "Download": "https://pypi.org/project/validate-pyproject/#files",
        "Homepage": "https://github.com/abravalheri/validate-pyproject/",
        "Source": "https://github.com/abravalheri/validate-pyproject",
        "Tracker": "https://github.com/abravalheri/validate-pyproject/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a3645f4bb7275b5afd70b1e4bc8b6bcf0c488cde20e39d72a3c98998ba8a9f5",
                "md5": "6dd92540749666f327851bf94f53215e",
                "sha256": "8c2e678d7d52cff56eb1670a627eaa808fe6334d7a7f15218d12b89642d8a077"
            },
            "downloads": -1,
            "filename": "validate_pyproject-0.23-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6dd92540749666f327851bf94f53215e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 52726,
            "upload_time": "2024-11-11T15:02:27",
            "upload_time_iso_8601": "2024-11-11T15:02:27.285580Z",
            "url": "https://files.pythonhosted.org/packages/7a/36/45f4bb7275b5afd70b1e4bc8b6bcf0c488cde20e39d72a3c98998ba8a9f5/validate_pyproject-0.23-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c07b24689b11ef23226bdd3eebd8d89e103236f4c91043b71d707612a4c3ad7",
                "md5": "0a6844f8e1c3fb571c47ef6a6f2294db",
                "sha256": "12b2714bf647265c60e4f24a20674428bd891a8aa168a1be535bb99f8c0af0e3"
            },
            "downloads": -1,
            "filename": "validate_pyproject-0.23.tar.gz",
            "has_sig": false,
            "md5_digest": "0a6844f8e1c3fb571c47ef6a6f2294db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 113397,
            "upload_time": "2024-11-11T15:02:29",
            "upload_time_iso_8601": "2024-11-11T15:02:29.364264Z",
            "url": "https://files.pythonhosted.org/packages/5c/07/b24689b11ef23226bdd3eebd8d89e103236f4c91043b71d707612a4c3ad7/validate_pyproject-0.23.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-11 15:02:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "abravalheri",
    "github_project": "validate-pyproject",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "validate-pyproject"
}
        
Elapsed time: 0.34222s