{"id":14224466,"url":"https://github.com/clbarnes/extreqs","last_synced_at":"2026-02-28T18:30:13.336Z","repository":{"id":56824473,"uuid":"477808470","full_name":"clbarnes/extreqs","owner":"clbarnes","description":"Parse python requirements.txt files into setuptools extras","archived":false,"fork":false,"pushed_at":"2024-02-03T11:39:41.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-31T15:39:35.200Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clbarnes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-04T17:40:20.000Z","updated_at":"2024-08-17T12:23:10.000Z","dependencies_parsed_at":"2024-11-08T08:38:12.181Z","dependency_job_id":"e906253e-c5cb-4f4c-9227-c4d6e65bcb11","html_url":"https://github.com/clbarnes/extreqs","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"7ca43f85cbc37a07137bac0c115fe7f09b48d470"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clbarnes%2Fextreqs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clbarnes%2Fextreqs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clbarnes%2Fextreqs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clbarnes%2Fextreqs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clbarnes","download_url":"https://codeload.github.com/clbarnes/extreqs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239877787,"owners_count":19712157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-19T23:01:03.925Z","updated_at":"2026-02-28T18:30:13.236Z","avatar_url":"https://github.com/clbarnes.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# extreqs\n\nParse python requirements.txt files into setuptools extras.\n\n## Usage\n\n`extreqs` looks for special comments (`#extra:`) in your requirements files.\nNote the lack of space after the `#`!\nAnything which follows that (until the end of line, or another `#`) is treated as a whitespace-separated list of extras.\nFor example, `#extra: dev test doc` marks dependencies belonging to the `dev`, `test`, and `doc` extras.\n\nIf the `#extra:` comment is on the same line as (following) a dependency, then just that dependency belongs to that extra.\nIf the `#extra:` comment is on a line on its own, all dependencies below it belong to that extra, until the next `#extra:` line.\n\nFor example:\n\n```txt\n# requirements.txt\ndep1\ndep2  #extra: extra1\n\n#extra: extra2\ndep3\n\n#extra: extra3  # you can still have freeform comments!\ndep4  #extra: extra4 extra5\ndep5\n```\n\nwould be parsed into\n\n```python\ninstall_requires = [\"dep1\"]\nextras_require = {\n    \"extra1\": [\"dep2\"],\n    \"extra2\": [\"dep3\"],\n    \"extra3\": [\"dep4\", \"dep5\"],\n    \"extra4\": [\"dep4\"],\n    \"extra5\": [\"dep4\"],\n}\n```\n\nAdditionally, entire files can belong to a particular extra.\n\nNote that python extras are not smart enough to deal with dependencies which belong only to _combinations_ of extras, or _negative_ extras: a dependency which belongs to multiple extras (given by the context of the file, block, or line) just belongs to multiple extras.\nThis is a limitation of python packaging and cannot be addressed here.\n\nIn your `setup.py`:\n\n```python\n#!/usr/bin/env python3\n\"\"\"setup.py\"\"\"\nfrom pathlib import Path\n\nfrom extreqs import parse_requirements_files_dict\nfrom setuptools import setup\n\nhere = Path(__file__).resolve().parent\n\nreq_kwargs = parse_requirements_files_dict(\n    # files without an extra context are in *args\n    here / \"requirements.txt\",\n    # files with an extra context are in **kwargs\n    optional=here / \"requirements-optional.txt\",\n)\n\nsetup(\n    name=\"my_package\",\n    ...\n    **req_kwargs,\n    ...\n)\n```\n\n`extreqs` is an install-time dependency, and so must be added to your `pyproject.toml`:\n\n```toml\n# pyproject.toml\n[build-system]\nrequires = [\"setuptools\", \"extreqs\"]\nbuild-backend = \"setuptools.build_meta\"\n```\n\nLook out for dependency specifiers which are accepted by pip, but not by setuptools (e.g. editable install `-e` or references to other requirement files `-r`).\n\n## Notes\n\nThis package should only be used in certain circumstances, and may lead to bad habits if over-used.\nRequirements files are intended for specifying reproducible (i.e. hard version constraints), maximal environments for other developers, CI, and so on to be able to run all tests, features, lints etc..\nPackage dependencies are intended to specify the minimal dependencies with permissive version constraints for users to install the package for use.\n\nThis package is, therefore, more applicable to distributing applications (CLI, web backends, etc.) than it is libraries.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclbarnes%2Fextreqs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclbarnes%2Fextreqs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclbarnes%2Fextreqs/lists"}