reqbuild 0.1.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.
reqbuild-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 reqbuild contributors
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.
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.4
2
+ Name: reqbuild
3
+ Version: 0.1.0
4
+ Summary: Automatically generate requirements.txt from your Python project using AST analysis.
5
+ License: MIT
6
+ Keywords: requirements,dependencies,pip,packaging,ast
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Environment :: Console
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Build Tools
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: Utilities
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7.0; extra == "dev"
25
+ Requires-Dist: pytest-cov; extra == "dev"
26
+ Requires-Dist: hatch; extra == "dev"
27
+ Requires-Dist: twine; extra == "dev"
28
+ Requires-Dist: build; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # reqbuild
32
+
33
+ > Automatically generate `requirements.txt` from your Python project using AST analysis — no imports, no installation needed at scan time.
34
+
35
+ [![PyPI version](https://badge.fury.io/py/reqbuild.svg)](https://pypi.org/project/reqbuild/)
36
+ [![Python](https://img.shields.io/pypi/pyversions/reqbuild.svg)](https://pypi.org/project/reqbuild/)
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
38
+
39
+ ---
40
+
41
+ ## Features
42
+
43
+ - 🔍 **AST-based** — parses your source files without running them
44
+ - 🌐 **Smart resolution** — uses the [pipreqs](https://github.com/bndr/pipreqs) mapping + live PyPI fallback
45
+ - 🚫 **Zero dependencies** — only the Python standard library
46
+ - 🔘 **Optional import detection** — spots imports inside `try/except ImportError` blocks
47
+ - 🎛️ **Flexible CLI** — control scope, exclusions, output format, and more
48
+
49
+ ---
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install reqbuild
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Quick Start
60
+
61
+ ```bash
62
+ # Scan only the current folder
63
+ reqbuild generate
64
+
65
+ # Scan everything recursively
66
+ reqbuild generate -a
67
+
68
+ # Preview without writing a file
69
+ reqbuild generate -a --print
70
+ ```
71
+
72
+ ---
73
+
74
+ ## CLI Reference
75
+
76
+ ### `reqbuild generate` (alias: `gen`)
77
+
78
+ Scan Python files and generate a requirements file.
79
+
80
+ | Flag | Description |
81
+ |------|-------------|
82
+ | `-a`, `--all` | Scan the current folder **and all subdirectories** recursively |
83
+ | `-e DIR` | Exclude a directory name (repeatable: `-e tests -e docs`) |
84
+ | `-ef FILE` | Exclude a specific filename (repeatable: `-ef conftest.py`) |
85
+ | `-o FILENAME` | Output filename (default: `requirements.txt`). Use `.in` for pip-compile |
86
+ | `--print` | Print resolved dependencies to stdout instead of writing a file |
87
+ | `--optional` | Detect imports inside `try/except ImportError` and list them as comments |
88
+ | `--no-network` | Offline mode — skip pipreqs download and PyPI checks |
89
+ | `-h`, `--help` | Show help for this command |
90
+
91
+ ### Global flags
92
+
93
+ | Flag | Description |
94
+ |------|-------------|
95
+ | `-V`, `--version` | Show the installed version |
96
+
97
+ ---
98
+
99
+ ## Examples
100
+
101
+ ```bash
102
+ # Generate requirements.in (pip-compile compatible)
103
+ reqbuild generate -a -o requirements.in
104
+
105
+ # Exclude test and docs directories
106
+ reqbuild generate -a -e tests -e docs
107
+
108
+ # Exclude a specific file
109
+ reqbuild generate -a -ef setup.py
110
+
111
+ # Detect optional imports (try/except ImportError)
112
+ reqbuild generate -a --optional
113
+
114
+ # Offline mode (no network calls)
115
+ reqbuild generate -a --no-network
116
+
117
+ # Preview all dependencies without writing
118
+ reqbuild generate -a --print
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Optional import detection
124
+
125
+ With `--optional`, reqbuild will detect imports wrapped in `try/except ImportError`:
126
+
127
+ ```python
128
+ import requests # required — goes to requirements.txt
129
+
130
+ try:
131
+ import ujson # optional — listed as a comment
132
+ except ImportError:
133
+ import json as ujson
134
+ ```
135
+
136
+ Output (`requirements.txt`):
137
+ ```
138
+ requests
139
+
140
+ # ─── Optional dependencies (detected inside try/except ImportError) ───
141
+ # ujson
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Default ignored directories
147
+
148
+ reqbuild automatically ignores:
149
+
150
+ `.venv`, `venv`, `.env`, `env`, `__pycache__`, `.git`, `.hg`, `.svn`,
151
+ `.tox`, `.nox`, `dist`, `build`, `site-packages`, `.mypy_cache`,
152
+ `.pytest_cache`, `.ruff_cache`, `node_modules`, `.eggs`
153
+
154
+ Add more with `-e`:
155
+
156
+ ```bash
157
+ reqbuild generate -a -e migrations -e fixtures
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Python API
163
+
164
+ reqbuild can also be used as a library:
165
+
166
+ ```python
167
+ from reqbuild import scan, resolve, write_file
168
+
169
+ scan_result = scan(root=".", recursive=True, detect_optional=True)
170
+ external_names = [r.name for r in scan_result.imports]
171
+
172
+ resolve_result = resolve(external_names)
173
+ write_file(resolve_result, "requirements.txt")
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Publishing to PyPI
179
+
180
+ ```bash
181
+ pip install build twine
182
+
183
+ # Build
184
+ python -m build
185
+
186
+ # Upload to TestPyPI first
187
+ twine upload --repository testpypi dist/*
188
+
189
+ # Upload to PyPI
190
+ twine upload dist/*
191
+ ```
192
+
193
+ ---
194
+
195
+ ## License
196
+
197
+ [MIT](LICENSE)
@@ -0,0 +1,167 @@
1
+ # reqbuild
2
+
3
+ > Automatically generate `requirements.txt` from your Python project using AST analysis — no imports, no installation needed at scan time.
4
+
5
+ [![PyPI version](https://badge.fury.io/py/reqbuild.svg)](https://pypi.org/project/reqbuild/)
6
+ [![Python](https://img.shields.io/pypi/pyversions/reqbuild.svg)](https://pypi.org/project/reqbuild/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
+
9
+ ---
10
+
11
+ ## Features
12
+
13
+ - 🔍 **AST-based** — parses your source files without running them
14
+ - 🌐 **Smart resolution** — uses the [pipreqs](https://github.com/bndr/pipreqs) mapping + live PyPI fallback
15
+ - 🚫 **Zero dependencies** — only the Python standard library
16
+ - 🔘 **Optional import detection** — spots imports inside `try/except ImportError` blocks
17
+ - 🎛️ **Flexible CLI** — control scope, exclusions, output format, and more
18
+
19
+ ---
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install reqbuild
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Quick Start
30
+
31
+ ```bash
32
+ # Scan only the current folder
33
+ reqbuild generate
34
+
35
+ # Scan everything recursively
36
+ reqbuild generate -a
37
+
38
+ # Preview without writing a file
39
+ reqbuild generate -a --print
40
+ ```
41
+
42
+ ---
43
+
44
+ ## CLI Reference
45
+
46
+ ### `reqbuild generate` (alias: `gen`)
47
+
48
+ Scan Python files and generate a requirements file.
49
+
50
+ | Flag | Description |
51
+ |------|-------------|
52
+ | `-a`, `--all` | Scan the current folder **and all subdirectories** recursively |
53
+ | `-e DIR` | Exclude a directory name (repeatable: `-e tests -e docs`) |
54
+ | `-ef FILE` | Exclude a specific filename (repeatable: `-ef conftest.py`) |
55
+ | `-o FILENAME` | Output filename (default: `requirements.txt`). Use `.in` for pip-compile |
56
+ | `--print` | Print resolved dependencies to stdout instead of writing a file |
57
+ | `--optional` | Detect imports inside `try/except ImportError` and list them as comments |
58
+ | `--no-network` | Offline mode — skip pipreqs download and PyPI checks |
59
+ | `-h`, `--help` | Show help for this command |
60
+
61
+ ### Global flags
62
+
63
+ | Flag | Description |
64
+ |------|-------------|
65
+ | `-V`, `--version` | Show the installed version |
66
+
67
+ ---
68
+
69
+ ## Examples
70
+
71
+ ```bash
72
+ # Generate requirements.in (pip-compile compatible)
73
+ reqbuild generate -a -o requirements.in
74
+
75
+ # Exclude test and docs directories
76
+ reqbuild generate -a -e tests -e docs
77
+
78
+ # Exclude a specific file
79
+ reqbuild generate -a -ef setup.py
80
+
81
+ # Detect optional imports (try/except ImportError)
82
+ reqbuild generate -a --optional
83
+
84
+ # Offline mode (no network calls)
85
+ reqbuild generate -a --no-network
86
+
87
+ # Preview all dependencies without writing
88
+ reqbuild generate -a --print
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Optional import detection
94
+
95
+ With `--optional`, reqbuild will detect imports wrapped in `try/except ImportError`:
96
+
97
+ ```python
98
+ import requests # required — goes to requirements.txt
99
+
100
+ try:
101
+ import ujson # optional — listed as a comment
102
+ except ImportError:
103
+ import json as ujson
104
+ ```
105
+
106
+ Output (`requirements.txt`):
107
+ ```
108
+ requests
109
+
110
+ # ─── Optional dependencies (detected inside try/except ImportError) ───
111
+ # ujson
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Default ignored directories
117
+
118
+ reqbuild automatically ignores:
119
+
120
+ `.venv`, `venv`, `.env`, `env`, `__pycache__`, `.git`, `.hg`, `.svn`,
121
+ `.tox`, `.nox`, `dist`, `build`, `site-packages`, `.mypy_cache`,
122
+ `.pytest_cache`, `.ruff_cache`, `node_modules`, `.eggs`
123
+
124
+ Add more with `-e`:
125
+
126
+ ```bash
127
+ reqbuild generate -a -e migrations -e fixtures
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Python API
133
+
134
+ reqbuild can also be used as a library:
135
+
136
+ ```python
137
+ from reqbuild import scan, resolve, write_file
138
+
139
+ scan_result = scan(root=".", recursive=True, detect_optional=True)
140
+ external_names = [r.name for r in scan_result.imports]
141
+
142
+ resolve_result = resolve(external_names)
143
+ write_file(resolve_result, "requirements.txt")
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Publishing to PyPI
149
+
150
+ ```bash
151
+ pip install build twine
152
+
153
+ # Build
154
+ python -m build
155
+
156
+ # Upload to TestPyPI first
157
+ twine upload --repository testpypi dist/*
158
+
159
+ # Upload to PyPI
160
+ twine upload dist/*
161
+ ```
162
+
163
+ ---
164
+
165
+ ## License
166
+
167
+ [MIT](LICENSE)
@@ -0,0 +1,55 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "reqbuild"
7
+ version = "0.1.0"
8
+ description = "Automatically generate requirements.txt from your Python project using AST analysis."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.10"
12
+ keywords = ["requirements", "dependencies", "pip", "packaging", "ast"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Environment :: Console",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: Software Development :: Build Tools",
25
+ "Topic :: Software Development :: Libraries :: Python Modules",
26
+ "Topic :: Utilities",
27
+ ]
28
+
29
+ # reqbuild has zero runtime dependencies – everything it needs is in the stdlib.
30
+ dependencies = []
31
+
32
+ [project.scripts]
33
+ reqbuild = "reqbuild.cli:main"
34
+
35
+ # ─── Optional dev dependencies ────────────────────────────────────────────────
36
+ [project.optional-dependencies]
37
+ dev = [
38
+ "pytest>=7.0",
39
+ "pytest-cov",
40
+ "hatch",
41
+ "twine",
42
+ "build",
43
+ ]
44
+
45
+ # ─── Tool config ─────────────────────────────────────────────────────────────
46
+ [tool.pytest.ini_options]
47
+ testpaths = ["tests"]
48
+ addopts = "-v"
49
+
50
+ [tool.ruff]
51
+ line-length = 100
52
+ target-version = "py310"
53
+
54
+ [tool.ruff.lint]
55
+ select = ["E", "F", "I", "UP"]
@@ -0,0 +1,23 @@
1
+ """
2
+ reqbuild – Automatically generate requirements.txt from your Python project.
3
+ """
4
+
5
+ __version__ = "0.1.0"
6
+ __author__ = "reqbuild contributors"
7
+ __license__ = "MIT"
8
+
9
+ from .scanner import scan, ScanResult, ImportRecord, DEFAULT_IGNORE_DIRS
10
+ from .resolver import resolve, ResolveResult
11
+ from .writer import write_file, print_output
12
+
13
+ __all__ = [
14
+ "scan",
15
+ "resolve",
16
+ "write_file",
17
+ "print_output",
18
+ "ScanResult",
19
+ "ImportRecord",
20
+ "ResolveResult",
21
+ "DEFAULT_IGNORE_DIRS",
22
+ "__version__",
23
+ ]
@@ -0,0 +1,5 @@
1
+ """Allow running as: python -m reqbuild"""
2
+ import sys
3
+ from .cli import main
4
+
5
+ sys.exit(main())