pyforge-init 0.1.0__tar.gz → 0.1.1__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.
Files changed (42) hide show
  1. pyforge_init-0.1.1/PKG-INFO +423 -0
  2. pyforge_init-0.1.1/README.md +406 -0
  3. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/pyproject.toml +1 -1
  4. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/cli.py +21 -17
  5. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/config.py +3 -4
  6. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/generator.py +13 -0
  7. pyforge_init-0.1.1/src/pyforge/prompts.py +304 -0
  8. pyforge_init-0.1.1/src/pyforge/template_catalog.py +64 -0
  9. pyforge_init-0.1.1/src/pyforge/templates/basic/src/package/__main__.py.jinja +5 -0
  10. pyforge_init-0.1.1/src/pyforge/templates/basic/src/package/main.py.jinja +6 -0
  11. pyforge_init-0.1.1/src/pyforge/templates/basic/tests/test_main.py.jinja +7 -0
  12. pyforge_init-0.1.1/src/pyforge/templates/fastapi/src/package/main.py.jinja +19 -0
  13. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/shared/Justfile.jinja +5 -0
  14. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/shared/Makefile.jinja +12 -1
  15. pyforge_init-0.1.1/src/pyforge/templates/shared/README.md.jinja +52 -0
  16. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/tests/test_cli.py +25 -0
  17. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/tests/test_generator.py +2 -0
  18. pyforge_init-0.1.1/tests/test_prompts.py +12 -0
  19. pyforge_init-0.1.0/PKG-INFO +0 -221
  20. pyforge_init-0.1.0/README.md +0 -204
  21. pyforge_init-0.1.0/src/pyforge/prompts.py +0 -167
  22. pyforge_init-0.1.0/src/pyforge/templates/basic/tests/test_main.py.jinja +0 -3
  23. pyforge_init-0.1.0/src/pyforge/templates/fastapi/src/package/main.py.jinja +0 -7
  24. pyforge_init-0.1.0/src/pyforge/templates/shared/README.md.jinja +0 -28
  25. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/.github/workflows/release.yml +0 -0
  26. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/.gitignore +0 -0
  27. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/__init__.py +0 -0
  28. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/remote.py +0 -0
  29. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/cli/src/package/__main__.py.jinja +0 -0
  30. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/cli/src/package/cli.py.jinja +0 -0
  31. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/cli/tests/test_cli.py.jinja +0 -0
  32. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/fastapi/tests/test_main.py.jinja +0 -0
  33. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/flask/src/package/app.py.jinja +0 -0
  34. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/flask/tests/test_app.py.jinja +0 -0
  35. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/shared/env.example.jinja +0 -0
  36. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/shared/gitignore.jinja +0 -0
  37. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/shared/pre-commit-config.yaml.jinja +0 -0
  38. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/shared/pyproject.toml.jinja +0 -0
  39. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/shared/requirements.txt.jinja +0 -0
  40. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/templates/shared/src/package/__init__.py.jinja +0 -0
  41. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/src/pyforge/utils.py +0 -0
  42. {pyforge_init-0.1.0 → pyforge_init-0.1.1}/tests/test_config.py +0 -0
@@ -0,0 +1,423 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyforge-init
3
+ Version: 0.1.1
4
+ Summary: A CLI tool to scaffold new Python projects, similar to create-react-app.
5
+ Author-email: Your Name <your.email@example.com>
6
+ Requires-Python: >=3.9
7
+ Requires-Dist: click>=8.0.0
8
+ Requires-Dist: httpx>=0.27.0
9
+ Requires-Dist: jinja2>=3.0.0
10
+ Requires-Dist: questionary>=2.0.0
11
+ Requires-Dist: rich>=13.0.0
12
+ Requires-Dist: tomli>=2.0.0; python_version < '3.11'
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest-mock>=3.0.0; extra == 'dev'
15
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
16
+ Description-Content-Type: text/markdown
17
+
18
+ # pyforge
19
+
20
+ `pyforge` is a lightweight command-line tool for scaffolding Python projects in seconds. It creates a working project layout, starter tests, basic tooling config, and a template-specific entry point so you can start coding immediately.
21
+
22
+ ---
23
+
24
+ ## Key Features
25
+
26
+ - **Terminal-native TUI**: A Rich-powered wizard with a visual template menu and styled prompts.
27
+ - **Multiple Built-in Templates**: Native templates for `basic` packages, `cli` tools, `fastapi` services, and `flask` applications.
28
+ - **Remote Templates**: Pull custom project layouts directly from public GitHub repositories using the `gh:owner/repo` syntax.
29
+ - **Configurable Defaults**: Save persistent author, license, template, and tool choices in a `~/.newpythonrc` configuration file.
30
+ - **Standards-Compliant**: Generates PEP 621-compliant `pyproject.toml` using `hatchling` as the build backend.
31
+ - **Tooling Configuration**: Preconfigured integration with `pytest`, `ruff`, and optional `pre-commit` hooks.
32
+ - **Task Automation**: Optional virtual environment creation, Git repository initialization, and generation of a template-aware `Makefile` or `Justfile`.
33
+
34
+ ---
35
+
36
+ ## Installation
37
+
38
+ Install `pyforge-init` globally via PyPI:
39
+
40
+ ```bash
41
+ pip install pyforge-init
42
+ ```
43
+
44
+ Or install it in an isolated environment using `pipx`:
45
+
46
+ ```bash
47
+ pipx install pyforge-init
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Quick Start
53
+
54
+ Initialize a new project by running:
55
+
56
+ ```bash
57
+ newpython myproject
58
+ ```
59
+
60
+ In an interactive terminal, `pyforge` opens a template picker first and then asks for project details. The template menu includes:
61
+
62
+ ```text
63
+ 1. Basic package - Minimal package with a real entry point and starter test.
64
+ 2. Click CLI - Console application with a click command and script entry point.
65
+ 3. FastAPI service - API scaffold with a health endpoint.
66
+ 4. Flask app - Factory-style web app.
67
+ 5. Custom GitHub template - gh:owner/repo[@ref]
68
+ ```
69
+
70
+ If you pass `--yes`, `pyforge` skips prompts and uses defaults. You can also pass `--template` directly to bypass the picker.
71
+
72
+ Once the wizard completes, your project directory is created and populated. Typical next steps are:
73
+
74
+ ```bash
75
+ cd myproject
76
+ source .venv/bin/activate # On Windows use: .venv\Scripts\activate
77
+ make install # Installs the package and all dev dependencies
78
+ make run # Runs the application or command
79
+ ```
80
+
81
+ ---
82
+
83
+ ## CLI Reference
84
+
85
+ ```text
86
+ Usage: newpython [OPTIONS] PROJECT_NAME
87
+
88
+ Scaffold a new Python project.
89
+
90
+ Arguments:
91
+ PROJECT_NAME Name of the project (must be a valid Python identifier)
92
+
93
+ Options:
94
+ --template TEXT Built-in template or remote GitHub template.
95
+ Built-ins: basic, cli, fastapi, flask.
96
+ Remote: gh:owner/repo or gh:owner/repo@ref.
97
+ If omitted, an interactive template picker is shown.
98
+ --no-pre-commit Skip generating .pre-commit-config.yaml
99
+ --justfile Generate a Justfile instead of a Makefile
100
+ -y, --yes Skip interactive prompts and accept defaults
101
+ --help Show this message and exit.
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Built-in Templates
107
+
108
+ ### Basic
109
+
110
+ Minimal package scaffold with an executable module layout.
111
+
112
+ - `src/<project>/main.py`
113
+ - `src/<project>/__main__.py`
114
+ - `tests/test_main.py`
115
+
116
+ ### CLI
117
+
118
+ Click-based command-line application with a console script entry point.
119
+
120
+ - `src/<project>/cli.py`
121
+ - `src/<project>/__main__.py`
122
+ - `tests/test_cli.py`
123
+
124
+ ### FastAPI
125
+
126
+ API scaffold with a root route and a `/health` endpoint.
127
+
128
+ - `src/<project>/main.py`
129
+ - `tests/test_main.py`
130
+
131
+ ### Flask
132
+
133
+ Factory-style Flask application with a test client setup.
134
+
135
+ - `src/<project>/app.py`
136
+ - `tests/test_app.py`
137
+
138
+ ---
139
+
140
+ ## Project Structure
141
+
142
+ The default `basic` template generates the following directory structure:
143
+
144
+ ```text
145
+ myproject/
146
+ ├── src/
147
+ │ └── myproject/
148
+ │ ├── __init__.py # Package initialization
149
+ │ ├── __main__.py # Module entry point
150
+ │ └── main.py # Console entry point
151
+ --help Show this message and exit.
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Project Structure (Basic Template)
157
+
158
+ The default template (`basic`) generates the following directory structure:
159
+
160
+ ```
161
+ myproject/
162
+ ├── src/
163
+ │ └── myproject/
164
+ │ └── __init__.py # Package initialization
165
+ ├── tests/
166
+ │ └── test_main.py # Starter unit test
167
+ ├── .env.example # Example environment variables
168
+ ├── .gitignore # Standard Python git ignore rules
169
+ ├── .pre-commit-config.yaml # Pre-configured linting/formatting hooks
170
+ ├── Makefile # Task runner
171
+ ├── README.md # Generated project documentation
172
+ ├── pyproject.toml # Metadata, dependencies, and tool settings
173
+ └── requirements.txt # Project dependencies
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Templates
179
+
180
+ ### Remote Templates
181
+
182
+ `pyforge` is a lightweight command-line tool for scaffolding Python projects in seconds. It creates a working project layout, starter tests, basic tooling config, and a template-specific entry point so you can start coding immediately.
183
+
184
+ ---
185
+
186
+ ## Key Features
187
+
188
+ - **Terminal-native TUI**: A Rich-powered wizard with a visual template menu and styled prompts.
189
+ - **Multiple Built-in Templates**: Native templates for `basic` packages, `cli` tools, `fastapi` services, and `flask` applications.
190
+ - **Remote Templates**: Pull custom project layouts directly from public GitHub repositories using the `gh:owner/repo` syntax.
191
+ - **Configurable Defaults**: Save persistent author, license, template, and tool choices in a `~/.newpythonrc` configuration file.
192
+ - **Standards-Compliant**: Generates PEP 621-compliant `pyproject.toml` using `hatchling` as the build backend.
193
+ - **Tooling Configuration**: Preconfigured integration with `pytest`, `ruff`, and optional `pre-commit` hooks.
194
+ - **Task Automation**: Optional virtual environment creation, Git repository initialization, and generation of a template-aware `Makefile` or `Justfile`.
195
+
196
+ ---
197
+
198
+ ## Installation
199
+
200
+ Install `pyforge-init` globally via PyPI:
201
+
202
+ ```bash
203
+ pip install pyforge-init
204
+ ```
205
+
206
+ Or install it in an isolated environment using `pipx`:
207
+
208
+ ```bash
209
+ pipx install pyforge-init
210
+ ```
211
+
212
+ ---
213
+
214
+ ## Quick Start
215
+
216
+ Initialize a new project by running:
217
+
218
+ ```bash
219
+ newpython myproject
220
+ ```
221
+
222
+ In an interactive terminal, `pyforge` opens a template picker first and then asks for project details. The template menu includes:
223
+
224
+ ```text
225
+ 1. Basic package - Minimal package with a real entry point and starter test.
226
+ 2. Click CLI - Console application with a click command and script entry point.
227
+ 3. FastAPI service - API scaffold with a health endpoint.
228
+ 4. Flask app - Factory-style web app.
229
+ 5. Custom GitHub template - gh:owner/repo[@ref]
230
+ ```
231
+
232
+ If you pass `--yes`, `pyforge` skips prompts and uses defaults. You can also pass `--template` directly to bypass the picker.
233
+
234
+ Once the wizard completes, your project directory is created and populated. Typical next steps are:
235
+
236
+ ```bash
237
+ cd myproject
238
+ source .venv/bin/activate # On Windows use: .venv\Scripts\activate
239
+ make install # Installs the package and all dev dependencies
240
+ make run # Runs the application or command
241
+ ```
242
+
243
+ ---
244
+
245
+ ## CLI Reference
246
+
247
+ ```text
248
+ Usage: newpython [OPTIONS] PROJECT_NAME
249
+
250
+ Scaffold a new Python project.
251
+
252
+ Arguments:
253
+ PROJECT_NAME Name of the project (must be a valid Python identifier)
254
+
255
+ Options:
256
+ --template TEXT Built-in template or remote GitHub template.
257
+ Built-ins: basic, cli, fastapi, flask.
258
+ Remote: gh:owner/repo or gh:owner/repo@ref.
259
+ If omitted, an interactive template picker is shown.
260
+ --no-pre-commit Skip generating .pre-commit-config.yaml
261
+ --justfile Generate a Justfile instead of a Makefile
262
+ -y, --yes Skip interactive prompts and accept defaults
263
+ --help Show this message and exit.
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Built-in Templates
269
+
270
+ ### Basic
271
+
272
+ Minimal package scaffold with an executable module layout.
273
+
274
+ - `src/<project>/main.py`
275
+ - `src/<project>/__main__.py`
276
+ - `tests/test_main.py`
277
+
278
+ ### CLI
279
+
280
+ Click-based command-line application with a console script entry point.
281
+
282
+ - `src/<project>/cli.py`
283
+ - `src/<project>/__main__.py`
284
+ - `tests/test_cli.py`
285
+
286
+ ### FastAPI
287
+
288
+ API scaffold with a root route and a `/health` endpoint.
289
+
290
+ - `src/<project>/main.py`
291
+ - `tests/test_main.py`
292
+
293
+ ### Flask
294
+
295
+ Factory-style Flask application with a test client setup.
296
+
297
+ - `src/<project>/app.py`
298
+ - `tests/test_app.py`
299
+
300
+ ---
301
+
302
+ ## Project Structure
303
+
304
+ The default `basic` template generates the following directory structure:
305
+
306
+ ```text
307
+ myproject/
308
+ ├── src/
309
+ │ └── myproject/
310
+ │ ├── __init__.py # Package initialization
311
+ │ ├── __main__.py # Module entry point
312
+ │ └── main.py # Console entry point
313
+ ├── tests/
314
+ │ └── test_main.py # Starter unit test
315
+ ├── .env.example # Example environment variables
316
+ ├── .gitignore # Standard Python git ignore rules
317
+ ├── .pre-commit-config.yaml # Pre-configured linting/formatting hooks
318
+ ├── Makefile # Task runner
319
+ ├── README.md # Generated project documentation
320
+ ├── pyproject.toml # Metadata, dependencies, and tool settings
321
+ └── requirements.txt # Project dependencies
322
+ ```
323
+
324
+ ---
325
+
326
+ ## Remote Templates
327
+
328
+ You can import any public GitHub repository to use as a project template:
329
+
330
+ ```bash
331
+ # Uses the main/master branch
332
+ newpython myproject --template gh:username/repo-name
333
+
334
+ # Pin to a specific branch, tag, or commit hash
335
+ newpython myproject --template gh:username/repo-name@v1.0.0
336
+ ```
337
+
338
+ ### Remote Repository Requirements
339
+
340
+ Remote templates are fetched and copied as-is, so no Jinja rendering is performed on remote files.
341
+
342
+ - If the remote repository has a top-level `template/` directory, only the contents of that folder are copied to the destination.
343
+ - If no `template/` directory is present, the entire contents of the repository root are copied.
344
+
345
+ ---
346
+
347
+ ## Configuration File (`~/.newpythonrc`)
348
+
349
+ You can persist configuration defaults in a `~/.newpythonrc` (TOML format) file to pre-fill prompt values and skip entering them on every run.
350
+
351
+ ```toml
352
+ # ~/.newpythonrc
353
+ author = "Jane Doe"
354
+ license = "MIT"
355
+ template = "basic"
356
+ pre_commit = true
357
+ justfile = false
358
+ ```
359
+
360
+ ### Precedence Order
361
+
362
+ When resolving configurations, `pyforge` applies overrides in the following order, from highest to lowest:
363
+
364
+ 1. CLI flags, such as `--template` and `--justfile`
365
+ 2. Configuration file, `~/.newpythonrc`
366
+ 3. Interactive prompt defaults
367
+
368
+ To override the default config location, set the `NEWPYTHON_CONFIG` environment variable:
369
+
370
+ ```bash
371
+ export NEWPYTHON_CONFIG="/path/to/custom/config.toml"
372
+ ```
373
+
374
+ ---
375
+
376
+ ## Automated Task Runner
377
+
378
+ The generated `Makefile` or `Justfile` exposes standard commands for project maintenance:
379
+
380
+ - `install`: Install the project locally in editable mode alongside all development dependencies.
381
+ - `test`: Execute the test suite using `pytest`.
382
+ - `lint`: Perform static analysis with `ruff`.
383
+ - `format`: Auto-format code styles using `ruff format`.
384
+ - `run`: Start the application server or CLI script, depending on the selected template.
385
+ - `clean`: Remove local cache and build directories such as `__pycache__`, `.pytest_cache`, `.ruff_cache`, `build`, and `dist`.
386
+
387
+ ---
388
+
389
+ ## Publishing to PyPI
390
+
391
+ Projects generated by `pyforge` use `hatchling` as the build system and are ready to be built and uploaded to PyPI:
392
+
393
+ 1. Install build and publication dependencies:
394
+ ```bash
395
+ pip install build twine
396
+ ```
397
+ 2. Build the project distribution packages, source archive and wheel:
398
+ ```bash
399
+ python -m build
400
+ ```
401
+ 3. Upload to PyPI, or TestPyPI first:
402
+ ```bash
403
+ python -m twine upload dist/*
404
+ ```
405
+
406
+ ---
407
+
408
+ ## Development
409
+
410
+ To work on `pyforge` locally:
411
+
412
+ ```bash
413
+ git clone https://github.com/your-name/pyforge.git
414
+ cd pyforge
415
+ pip install -e ".[dev]"
416
+ python -m pytest -v
417
+ ```
418
+
419
+ ---
420
+
421
+ ## Contributing
422
+
423
+ Contributions are welcome. Open an issue or pull request if you find a bug or want to propose an improvement.