extreqs 1.2.0__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
extreqs-1.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022, Chris L. Barnes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
extreqs-1.3.0/PKG-INFO ADDED
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: extreqs
3
+ Version: 1.3.0
4
+ Summary: Parse python requirements.txt files into setuptools extras
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Programming Language :: Python :: 3.15
15
+ Requires-Dist: requirements-parser>=0.13.1
16
+ Requires-Python: >=3.10, <4.0
17
+ Description-Content-Type: text/markdown
18
+
19
+ # extreqs
20
+
21
+ Parse python requirements.txt files into setuptools extras.
22
+
23
+ `extreqs` is a build-time dependency used in projects with a `requirements.txt` and a `setup.py`,
24
+ where the `setup.py` reads the `requirements.txt` to determine the runtime dependencies.
25
+
26
+ ## Do not use this package
27
+
28
+ `extreqs` was written in a simpler but much worse time for python packaging.
29
+ Historically, `setup.cfg` or `setup.py` was used to specify runtime dependencies.
30
+ Applications were supposed to use strict version constraints,
31
+ and libraries permissive version constraints.
32
+
33
+ For CI and development purposes,
34
+ it was convenient to use `requirements.txt` files to fix specific versions,
35
+ or to specify additional dependencies used at development time and not at runtime.
36
+
37
+ This meant manually syncing two files, which is a pain.
38
+ So the intended walls between the use of `requirements.txt` and `setup.py` started to break down, and a pattern emerged of parsing your single-source-of-truth `requirements.txt` to feed into your `setup.py`.
39
+
40
+ `extreqs` was developed to fill the need of describing ["extras"](https://stackoverflow.com/questions/52474931/what-is-extra-in-pypi-dependency) while still maintaining `requirements.txt` as your single source of truth.
41
+ `extreqs` was always intended primarily to support application development,
42
+ but could be used for library development as well as a bridge (or crutch?) for people who preferred using `requirements.txt` for specifying dependencies.
43
+
44
+ Today, various development tools, most notably [`uv`](https://docs.astral.sh/uv/), handle lock files for you based on the canonical `pyproject.toml` dependency list, which also handles extras and groups (for development dependencies).
45
+ Those tools, in particular `uv`, should be used instead.
46
+
47
+ This package is maintained for legacy purposes.
48
+
49
+ ## Usage
50
+
51
+ `extreqs` looks for special comments (`#extra:`) in your requirements files.
52
+ Note the lack of space after the `#`!
53
+ Anything which follows that (until the end of line, or another `#`) is treated as a whitespace-separated list of extras.
54
+ For example, `#extra: dev test doc` marks dependencies belonging to the `dev`, `test`, and `doc` extras.
55
+
56
+ If the `#extra:` comment is on the same line as (following) a dependency, then just that dependency belongs to that extra.
57
+ If the `#extra:` comment is on a line on its own, all dependencies below it belong to that extra, until the next `#extra:` line.
58
+
59
+ For example:
60
+
61
+ ```txt
62
+ # requirements.txt
63
+ dep1
64
+ dep2 #extra: e1
65
+
66
+ #extra: e2
67
+ dep3
68
+
69
+ #extra: e3 # you can still have freeform comments!
70
+ dep4 #extra: e4 e5
71
+ dep5
72
+ ```
73
+
74
+ would be parsed into
75
+
76
+ ```python
77
+ install_requires = ["dep1"]
78
+ extras_require = {
79
+ "e1": ["dep2"],
80
+ "e2": ["dep3"],
81
+ "e3": ["dep4", "dep5"],
82
+ "e4": ["dep4"],
83
+ "e5": ["dep4"],
84
+ }
85
+ ```
86
+
87
+ Additionally, entire files can belong to a particular extra.
88
+
89
+ Note 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.
90
+ This is a limitation of python packaging and cannot be addressed here.
91
+
92
+ In your `setup.py`:
93
+
94
+ ```python
95
+ #!/usr/bin/env python3
96
+ """setup.py"""
97
+ from pathlib import Path
98
+
99
+ from extreqs import parse_requirements_files_dict
100
+ from setuptools import setup
101
+
102
+ here = Path(__file__).resolve().parent
103
+
104
+ req_kwargs = parse_requirements_files_dict(
105
+ # files without an extra context are in *args
106
+ here / "requirements.txt",
107
+ # files with an extra context are in **kwargs
108
+ optional=here / "requirements-optional.txt",
109
+ )
110
+
111
+ setup(
112
+ name="my_package",
113
+ ...
114
+ **req_kwargs,
115
+ ...
116
+ )
117
+ ```
118
+
119
+ `extreqs` is an install-time dependency, and so must be added to your `pyproject.toml`:
120
+
121
+ ```toml
122
+ # pyproject.toml
123
+ [build-system]
124
+ requires = ["setuptools", "extreqs"]
125
+ build-backend = "setuptools.build_meta"
126
+ ```
127
+
128
+ Look 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`).
129
+
130
+ ## Development
131
+
132
+ Contributions are welcome, although any broadening of extreqs' scope is unlikely to be accepted - raise an issue first!
133
+
134
+ Releases are made like this
135
+
136
+ ```sh
137
+ # commit all your changes, push, and ensure that CI passes
138
+ git add .
139
+ git commit -m "Prepare for a new version"
140
+ git push
141
+
142
+ # bump the version
143
+ uv version --bump minor
144
+
145
+ # commit the version bump
146
+ git add .
147
+ git commit -m "Bump to version $(uv version --short)"
148
+
149
+ # tag the commit
150
+ git tag -a "v$(uv version --short)" -m "New feature X"
151
+
152
+ # push to CI, which will do the releasing
153
+ git push --follow-tags
154
+ ```
@@ -0,0 +1,136 @@
1
+ # extreqs
2
+
3
+ Parse python requirements.txt files into setuptools extras.
4
+
5
+ `extreqs` is a build-time dependency used in projects with a `requirements.txt` and a `setup.py`,
6
+ where the `setup.py` reads the `requirements.txt` to determine the runtime dependencies.
7
+
8
+ ## Do not use this package
9
+
10
+ `extreqs` was written in a simpler but much worse time for python packaging.
11
+ Historically, `setup.cfg` or `setup.py` was used to specify runtime dependencies.
12
+ Applications were supposed to use strict version constraints,
13
+ and libraries permissive version constraints.
14
+
15
+ For CI and development purposes,
16
+ it was convenient to use `requirements.txt` files to fix specific versions,
17
+ or to specify additional dependencies used at development time and not at runtime.
18
+
19
+ This meant manually syncing two files, which is a pain.
20
+ So the intended walls between the use of `requirements.txt` and `setup.py` started to break down, and a pattern emerged of parsing your single-source-of-truth `requirements.txt` to feed into your `setup.py`.
21
+
22
+ `extreqs` was developed to fill the need of describing ["extras"](https://stackoverflow.com/questions/52474931/what-is-extra-in-pypi-dependency) while still maintaining `requirements.txt` as your single source of truth.
23
+ `extreqs` was always intended primarily to support application development,
24
+ but could be used for library development as well as a bridge (or crutch?) for people who preferred using `requirements.txt` for specifying dependencies.
25
+
26
+ Today, various development tools, most notably [`uv`](https://docs.astral.sh/uv/), handle lock files for you based on the canonical `pyproject.toml` dependency list, which also handles extras and groups (for development dependencies).
27
+ Those tools, in particular `uv`, should be used instead.
28
+
29
+ This package is maintained for legacy purposes.
30
+
31
+ ## Usage
32
+
33
+ `extreqs` looks for special comments (`#extra:`) in your requirements files.
34
+ Note the lack of space after the `#`!
35
+ Anything which follows that (until the end of line, or another `#`) is treated as a whitespace-separated list of extras.
36
+ For example, `#extra: dev test doc` marks dependencies belonging to the `dev`, `test`, and `doc` extras.
37
+
38
+ If the `#extra:` comment is on the same line as (following) a dependency, then just that dependency belongs to that extra.
39
+ If the `#extra:` comment is on a line on its own, all dependencies below it belong to that extra, until the next `#extra:` line.
40
+
41
+ For example:
42
+
43
+ ```txt
44
+ # requirements.txt
45
+ dep1
46
+ dep2 #extra: e1
47
+
48
+ #extra: e2
49
+ dep3
50
+
51
+ #extra: e3 # you can still have freeform comments!
52
+ dep4 #extra: e4 e5
53
+ dep5
54
+ ```
55
+
56
+ would be parsed into
57
+
58
+ ```python
59
+ install_requires = ["dep1"]
60
+ extras_require = {
61
+ "e1": ["dep2"],
62
+ "e2": ["dep3"],
63
+ "e3": ["dep4", "dep5"],
64
+ "e4": ["dep4"],
65
+ "e5": ["dep4"],
66
+ }
67
+ ```
68
+
69
+ Additionally, entire files can belong to a particular extra.
70
+
71
+ Note 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.
72
+ This is a limitation of python packaging and cannot be addressed here.
73
+
74
+ In your `setup.py`:
75
+
76
+ ```python
77
+ #!/usr/bin/env python3
78
+ """setup.py"""
79
+ from pathlib import Path
80
+
81
+ from extreqs import parse_requirements_files_dict
82
+ from setuptools import setup
83
+
84
+ here = Path(__file__).resolve().parent
85
+
86
+ req_kwargs = parse_requirements_files_dict(
87
+ # files without an extra context are in *args
88
+ here / "requirements.txt",
89
+ # files with an extra context are in **kwargs
90
+ optional=here / "requirements-optional.txt",
91
+ )
92
+
93
+ setup(
94
+ name="my_package",
95
+ ...
96
+ **req_kwargs,
97
+ ...
98
+ )
99
+ ```
100
+
101
+ `extreqs` is an install-time dependency, and so must be added to your `pyproject.toml`:
102
+
103
+ ```toml
104
+ # pyproject.toml
105
+ [build-system]
106
+ requires = ["setuptools", "extreqs"]
107
+ build-backend = "setuptools.build_meta"
108
+ ```
109
+
110
+ Look 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`).
111
+
112
+ ## Development
113
+
114
+ Contributions are welcome, although any broadening of extreqs' scope is unlikely to be accepted - raise an issue first!
115
+
116
+ Releases are made like this
117
+
118
+ ```sh
119
+ # commit all your changes, push, and ensure that CI passes
120
+ git add .
121
+ git commit -m "Prepare for a new version"
122
+ git push
123
+
124
+ # bump the version
125
+ uv version --bump minor
126
+
127
+ # commit the version bump
128
+ git add .
129
+ git commit -m "Bump to version $(uv version --short)"
130
+
131
+ # tag the commit
132
+ git tag -a "v$(uv version --short)" -m "New feature X"
133
+
134
+ # push to CI, which will do the releasing
135
+ git push --follow-tags
136
+ ```
@@ -0,0 +1,31 @@
1
+ [project]
2
+ name = "extreqs"
3
+ version = "1.3.0"
4
+ description = "Parse python requirements.txt files into setuptools extras"
5
+ requires-python = ">=3.10,<4.0"
6
+ readme = "README.md"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "License :: OSI Approved :: MIT License",
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.11",
14
+ "Programming Language :: Python :: 3.12",
15
+ "Programming Language :: Python :: 3.13",
16
+ "Programming Language :: Python :: 3.14",
17
+ "Programming Language :: Python :: 3.15",
18
+ ]
19
+ dependencies = ["requirements-parser>=0.13.1"]
20
+
21
+ [build-system]
22
+ requires = ["uv_build>=0.13.4,<0.14"]
23
+ build-backend = "uv_build"
24
+
25
+ [dependency-groups]
26
+ dev = [
27
+ "mypy>=2.4",
28
+ "pdoc>=16",
29
+ "pytest>=9.1",
30
+ "ruff>=0.17.1",
31
+ ]
@@ -1,31 +1,34 @@
1
1
  [project]
2
2
  name = "extreqs"
3
- version = "1.2.0"
3
+ version = "1.3.0"
4
4
  description = "Parse python requirements.txt files into setuptools extras"
5
5
  requires-python = ">=3.10,<4.0"
6
+ readme = "README.md"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
6
9
  classifiers = [
7
10
  "Development Status :: 3 - Alpha",
8
11
  "License :: OSI Approved :: MIT License",
9
12
  "Programming Language :: Python :: 3",
10
- "Programming Language :: Python :: 3.10",
11
13
  "Programming Language :: Python :: 3.11",
12
14
  "Programming Language :: Python :: 3.12",
13
15
  "Programming Language :: Python :: 3.13",
14
16
  "Programming Language :: Python :: 3.14",
17
+ "Programming Language :: Python :: 3.15",
15
18
  ]
16
19
 
17
20
  dependencies = [
18
- "requirements-parser>=0.13.0",
21
+ "requirements-parser>=0.13.1",
19
22
  ]
20
23
 
21
24
  [build-system]
22
- requires = ["uv_build>=0.10.0,<0.11.0"]
25
+ requires = ["uv_build>=0.13.4,<0.14"]
23
26
  build-backend = "uv_build"
24
27
 
25
28
  [dependency-groups]
26
29
  dev = [
27
- "mypy>=1.19.1",
28
- "pdoc3>=0.11.6",
29
- "pytest>=9.0.2",
30
- "ruff>=0.15.0",
30
+ "mypy>=2.4",
31
+ "pdoc>=16",
32
+ "pytest>=9.1",
33
+ "ruff>=0.17.1",
31
34
  ]
@@ -2,9 +2,10 @@
2
2
  # extreqs package
3
3
  """
4
4
 
5
- from .main import parse_requirement_files, parse_requirement_files_dict
6
5
  from importlib.metadata import version as _version
7
6
 
7
+ from .main import parse_requirement_files, parse_requirement_files_dict
8
+
8
9
  __version__ = _version("extreqs")
9
10
 
10
11
  __all__ = ["parse_requirement_files", "parse_requirement_files_dict"]
@@ -1,5 +1,4 @@
1
1
  import logging
2
- import sys
3
2
  import typing as tp
4
3
  from collections import defaultdict
5
4
  from pathlib import Path
@@ -9,7 +8,7 @@ from requirements.requirement import Requirement
9
8
  logger = logging.getLogger(__name__)
10
9
 
11
10
 
12
- def str_as_list(s: tp.Optional[tp.Union[str, tp.List[str]]]) -> tp.List[str]:
11
+ def str_as_list(s: str | list[str] | None) -> list[str]:
13
12
  if s is None:
14
13
  return []
15
14
  if isinstance(s, str):
@@ -23,7 +22,7 @@ UNSUPPORTED_VCS = {"git", "hg", "svn", "bzr"}
23
22
  class Parser:
24
23
  def __init__(self, fpath, file_context=None) -> None:
25
24
  self.file_context = str_as_list(file_context)
26
- self.block_context: tp.List[str] = []
25
+ self.block_context: list[str] = []
27
26
  self.fpath = fpath
28
27
  self.line_num = -1
29
28
 
@@ -117,7 +116,7 @@ def merge_install_extras(*install_extras):
117
116
  def parse_requirement_files(
118
117
  *req_files: Path,
119
118
  **extra_req_files: Path,
120
- ) -> tp.Tuple[tp.List[str], tp.Dict[str, tp.List[str]]]:
119
+ ) -> tuple[list[str], dict[str, list[str]]]:
121
120
  """Parse requirements files into setuptools requirements.
122
121
 
123
122
  Requirements files whose listed dependencies all belong to
@@ -144,13 +143,9 @@ def parse_requirement_files(
144
143
  return (d["install_requires"], d["extras_require"])
145
144
 
146
145
 
147
- if sys.version_info < (3, 8):
148
- ParsedFiles = dict
149
- else:
150
-
151
- class ParsedFiles(tp.TypedDict):
152
- install_requires: tp.List[str]
153
- extras_require: tp.Dict[str, tp.List[str]]
146
+ class ParsedFiles(tp.TypedDict):
147
+ install_requires: list[str]
148
+ extras_require: dict[str, list[str]]
154
149
 
155
150
 
156
151
  def parse_requirement_files_dict(
extreqs-1.2.0/PKG-INFO DELETED
@@ -1,14 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: extreqs
3
- Version: 1.2.0
4
- Summary: Parse python requirements.txt files into setuptools extras
5
- Classifier: Development Status :: 3 - Alpha
6
- Classifier: License :: OSI Approved :: MIT License
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: Programming Language :: Python :: 3.10
9
- Classifier: Programming Language :: Python :: 3.11
10
- Classifier: Programming Language :: Python :: 3.12
11
- Classifier: Programming Language :: Python :: 3.13
12
- Classifier: Programming Language :: Python :: 3.14
13
- Requires-Dist: requirements-parser>=0.13.0
14
- Requires-Python: >=3.10, <4.0