1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
=======================
hatch-requirements-txt
=======================
.. start short_desc
**Hatchling plugin to read project dependencies from requirements.txt**
.. end short_desc
.. list-table::
:stub-columns: 1
:widths: 10 90
* - Tests
- |actions_linux| |actions_windows| |actions_macos| |coveralls|
* - PyPI
- |pypi-version| |supported-versions| |supported-implementations| |wheel|
* - Anaconda
- |conda-version| |conda-platform|
* - Activity
- |commits-latest| |commits-since| |maintained| |pypi-downloads|
* - QA
- |codefactor| |actions_flake8| |actions_mypy|
* - Other
- |hatch| |license| |language| |requires|
.. |actions_linux| image:: https://github.com/repo-helper/hatch-requirements-txt/workflows/Linux/badge.svg
:target: https://github.com/repo-helper/hatch-requirements-txt/actions?query=workflow%3A%22Linux%22
:alt: Linux Test Status
.. |actions_windows| image:: https://github.com/repo-helper/hatch-requirements-txt/workflows/Windows/badge.svg
:target: https://github.com/repo-helper/hatch-requirements-txt/actions?query=workflow%3A%22Windows%22
:alt: Windows Test Status
.. |actions_macos| image:: https://github.com/repo-helper/hatch-requirements-txt/workflows/macOS/badge.svg
:target: https://github.com/repo-helper/hatch-requirements-txt/actions?query=workflow%3A%22macOS%22
:alt: macOS Test Status
.. |actions_flake8| image:: https://github.com/repo-helper/hatch-requirements-txt/workflows/Flake8/badge.svg
:target: https://github.com/repo-helper/hatch-requirements-txt/actions?query=workflow%3A%22Flake8%22
:alt: Flake8 Status
.. |actions_mypy| image:: https://github.com/repo-helper/hatch-requirements-txt/workflows/mypy/badge.svg
:target: https://github.com/repo-helper/hatch-requirements-txt/actions?query=workflow%3A%22mypy%22
:alt: mypy status
.. |requires| image:: https://dependency-dash.repo-helper.uk/github/repo-helper/hatch-requirements-txt/badge.svg
:target: https://dependency-dash.repo-helper.uk/github/repo-helper/hatch-requirements-txt/
:alt: Requirements Status
.. |coveralls| image:: https://img.shields.io/coveralls/github/repo-helper/hatch-requirements-txt/master?logo=coveralls
:target: https://coveralls.io/github/repo-helper/hatch-requirements-txt?branch=master
:alt: Coverage
.. |codefactor| image:: https://img.shields.io/codefactor/grade/github/repo-helper/hatch-requirements-txt?logo=codefactor
:target: https://www.codefactor.io/repository/github/repo-helper/hatch-requirements-txt
:alt: CodeFactor Grade
.. |pypi-version| image:: https://img.shields.io/pypi/v/hatch-requirements-txt
:target: https://pypi.org/project/hatch-requirements-txt/
:alt: PyPI - Package Version
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/hatch-requirements-txt?logo=python&logoColor=white
:target: https://pypi.org/project/hatch-requirements-txt/
:alt: PyPI - Supported Python Versions
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/hatch-requirements-txt
:target: https://pypi.org/project/hatch-requirements-txt/
:alt: PyPI - Supported Implementations
.. |wheel| image:: https://img.shields.io/pypi/wheel/hatch-requirements-txt
:target: https://pypi.org/project/hatch-requirements-txt/
:alt: PyPI - Wheel
.. |conda-version| image:: https://img.shields.io/conda/v/conda-forge/hatch-requirements-txt?logo=anaconda
:target: https://anaconda.org/conda-forge/hatch-requirements-txt
:alt: Conda - Package Version
.. |conda-platform| image:: https://img.shields.io/conda/pn/conda-forge/hatch-requirements-txt?label=conda%7Cplatform
:target: https://anaconda.org/conda-forge/hatch-requirements-txt
:alt: Conda - Platform
.. |hatch| image:: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg
:target: https://github.com/pypa/hatch
:alt: Hatch project
.. |license| image:: https://img.shields.io/github/license/repo-helper/hatch-requirements-txt
:target: https://github.com/repo-helper/hatch-requirements-txt/blob/master/LICENSE
:alt: License
.. |language| image:: https://img.shields.io/github/languages/top/repo-helper/hatch-requirements-txt
:alt: GitHub top language
.. |commits-since| image:: https://img.shields.io/github/commits-since/repo-helper/hatch-requirements-txt/v0.4.1
:target: https://github.com/repo-helper/hatch-requirements-txt/pulse
:alt: GitHub commits since tagged version
.. |commits-latest| image:: https://img.shields.io/github/last-commit/repo-helper/hatch-requirements-txt
:target: https://github.com/repo-helper/hatch-requirements-txt/commit/master
:alt: GitHub last commit
.. |maintained| image:: https://img.shields.io/maintenance/yes/2023
:alt: Maintenance
.. |pypi-downloads| image:: https://img.shields.io/pypi/dm/hatch-requirements-txt
:target: https://pypi.org/project/hatch-requirements-txt/
:alt: PyPI - Downloads
Usage
========
In your ``pyproject.toml`` make the following changes:
* Append ``hatch-requirements-txt`` to ``build-system.requires``.
* Append ``"dependencies"`` to ``project.dynamic``.
* Add the following table:
.. code-block:: toml
[tool.hatch.metadata.hooks.requirements_txt]
files = ["requirements.txt"]
The resulting ``pyproject.toml`` should look something like:
.. code-block:: toml
[build-system]
requires = ["hatchling", "hatch-requirements-txt"]
build-backend = "hatchling.build"
[project]
name = "my-project"
version = "1.0.0"
dynamic = ["dependencies"]
[tool.hatch.metadata.hooks.requirements_txt]
files = ["requirements.txt"]
You can also define groups of `optional dependencies <https://hatch.pypa.io/latest/config/dependency/#features>`_
(also known as "features") by appending ``optional-dependencies`` to ``project.dynamic`` and adding a table like:
.. code-block:: toml
[tool.hatch.metadata.hooks.requirements_txt.optional-dependencies]
crypto = ["requirements-crypto.txt"]
fastjson = ["requirements-fastjson.txt"]
cli = ["requirements-cli.txt"]
Requirements file format
============================
``hatch-requirements-txt`` only supports a subset of the ``requirements.txt`` format_ supported by ``pip``.
The following are supported:
* requirement specifiers, per `PEP 508`_
* Comments, prefixed with a ``#``.
* ``--<option>`` options, both on their own line and after a requirement specifier.
Note however that the options themselves are ignored.
The following are unsupported within ``requirements.txt`` files:
* Editable install commands with the ``-e`` option,
* References to other requirements or constraints files with the ``-r`` or ``-c`` options.
* References to paths on the local filesystem, or URLs.
**TL;DR**
For best compatibility, ensure all lines in your ``requirements.txt`` files
are valid PEP 508 requirements, or comments starting with a ``#``.
.. _format: https://pip.pypa.io/en/stable/reference/requirements-file-format/
.. _PEP 508: https://peps.python.org/pep-0508/
|