{"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":"en","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,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}