{"id":2527,"library":"hatch-requirements-txt","title":"Hatch Requirements.txt Plugin","description":"hatch-requirements-txt is a Hatchling plugin that enables Hatch-managed Python projects to declare their runtime dependencies directly within a 'requirements.txt' file. This allows projects to maintain a familiar dependency declaration style while leveraging Hatch for modern packaging. The current version is 0.4.1, with relatively infrequent but stable releases.","status":"active","version":"0.4.1","language":"python","source_language":"en","source_url":"https://github.com/repo-helper/hatch-requirements-txt","tags":["hatch","hatchling","plugin","dependencies","requirements.txt","packaging","build-system"],"install":[{"cmd":"pip install hatch-requirements-txt","lang":"bash","label":"Install plugin"}],"dependencies":[{"reason":"Required build backend for Hatch, the plugin integrates with it.","package":"hatchling","optional":false},{"reason":"The CLI tool that uses hatchling and this plugin during project builds.","package":"hatch","optional":false}],"imports":[],"quickstart":{"code":"mkdir my_project\ncd my_project\n\n# Create pyproject.toml\ncat <<EOF > pyproject.toml\n[build-system]\nrequires = [\"hatchling>=1.8.0\", \"hatch-requirements-txt\"]\nbuild-backend = \"hatchling.build\"\n\n[project]\nname = \"my-hatch-app\"\nversion = \"0.1.0\"\ndynamic = [\"dependencies\"]\n\n[tool.hatch.metadata.hooks.requirements-txt]\nfiles = [\"requirements.txt\"]\nEOF\n\n# Create requirements.txt\ncat <<EOF > requirements.txt\nrequests>=2.28.0\nbeautifulsoup4\nEOF\n\n# Your project is now configured to use requirements.txt for dependencies.\n# To see it in action, you would typically run 'hatch build' (assuming 'hatch' CLI is installed).\n","lang":"bash","description":"To use `hatch-requirements-txt`, install the plugin and configure your `pyproject.toml` to declare 'dependencies' as dynamic. Then, create a `requirements.txt` file in your project root with your desired runtime dependencies. The Hatchling build backend will automatically parse this file when building your package. After setting up these files, you can use the `hatch` CLI (e.g., `hatch build`) to see the plugin in action."},"warnings":[{"fix":"Ensure `dynamic = ['dependencies']` is present in your `pyproject.toml` under the `[project]` table.","message":"The `dynamic = ['dependencies']` entry in `[project]` is mandatory. Without it, Hatch will not attempt to dynamically source dependencies from the `requirements.txt` file, and your project will have no declared runtime dependencies.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Change `files = 'requirements.txt'` to `files = ['requirements.txt']`.","message":"In versions 0.4.0 and later, the `files` option in `[tool.hatch.metadata.hooks.requirements-txt]` must be a list of strings, even if you are specifying only a single file. Previous versions accepted a single string.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Ensure your project's `name` and `version` are explicitly defined in `pyproject.toml` or sourced from other appropriate Hatch dynamic metadata hooks, not via `hatch-requirements-txt`.","message":"Support for dynamically sourcing `name` and `version` from `requirements.txt` was removed in version 0.4.0. The plugin now strictly focuses on project dependencies.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Add `\"hatch-requirements-txt\"` to the `requires` list under `[build-system]`.","message":"The `hatch-requirements-txt` plugin itself must be listed in `build-system.requires` in `pyproject.toml` so that Hatchling can find and load it during the build process.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.4.1':49 'allow':30 'build':63 'build-system':62 'current':46 'declar':20,37 'depend':23,36,59 'direct':24 'enabl':13 'familiar':35 'file':28 'hatch':1,5,15,41,56 'hatch-manag':14 'hatch-requirements-txt':4 'hatchl':10,57 'infrequ':52 'leverag':40 'maintain':33 'manag':16 'modern':43 'packag':44,61 'plugin':3,11,58 'project':18,31 'python':17 'relat':51 'releas':55 'requir':6 'requirements.txt':2,27,60 'runtim':22 'stabl':54 'style':38 'system':64 'txt':7 'version':47 'within':25","created_at":"2026-04-11T01:31:52.724382+00:00","updated_at":"2026-04-16T15:32:45.506323+00:00","problems":[{"fix":"Ensure your `pyproject.toml` includes `hatch-requirements-txt` in `build-system.requires`, adds `\"dependencies\"` to `project.dynamic`, and defines the `[tool.hatch.requirements-txt]` table. For example:\n```toml\n[build-system]\nrequires = [\"hatchling\", \"hatch-requirements-txt\"]\nbuild-backend = \"hatchling.build\"\n\n[project]\nname = \"your-project\"\nversion = \"0.1.0\"\ndynamic = [\"dependencies\"]\n\n[tool.hatch.requirements-txt]\nfiles = [\"requirements.txt\"]\n```","cause":"The `pyproject.toml` file is likely missing the necessary configuration to inform Hatch to use the `hatch-requirements-txt` plugin or to recognize 'dependencies' as dynamic.","error":"hatch requirements.txt not working"},{"fix":"Remove editable installs (`-e`) from your `requirements.txt` file. For local or development dependencies, consider using Hatch's environment-specific dependencies or other mechanisms outside of the main `requirements.txt` parsed by this plugin.","cause":"The `requirements.txt` file contains an editable install (`-e` option), which is explicitly not supported by `hatch-requirements-txt`.","error":"hatch-requirements-txt unsupported format '-e'"},{"fix":"Consolidate all direct dependencies into a single `requirements.txt` file that `hatch-requirements-txt` processes, or manage interconnected dependency files using a different approach that doesn't rely on `-r` or `-c` within the plugin's scope.","cause":"Your `requirements.txt` file includes references to other requirement files (`-r`) or constraint files (`-c`), which `hatch-requirements-txt` does not support.","error":"hatch-requirements-txt references to other requirements or constraints files"},{"fix":"Ensure all entries in `requirements.txt` strictly adhere to PEP 508 requirement specifier syntax. Avoid local filesystem paths or complex URL forms that are not compliant, or verify correct quoting/escaping for URLs like `git+https://` if they are intended to be PEP 508 compliant.","cause":"The `requirements.txt` file contains a dependency specification that the underlying parsing library (like `setuptools` which `hatch-requirements-txt` relies on) cannot interpret, often due to non-standard syntax, local paths, or complex URL formats.","error":"pkg_resources.RequirementParseError: Invalid requirement"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/repo-helper/hatch-requirements-txt","docs":null,"changelog":null,"pypi":"https://pypi.org/project/hatch-requirements-txt/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-04-10","next_check":"2026-07-09","install_tag":null}}