venv-bat-gen 3.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.
- venv_bat_gen-3.3.0/.gitignore +40 -0
- venv_bat_gen-3.3.0/LICENSE +21 -0
- venv_bat_gen-3.3.0/PKG-INFO +254 -0
- venv_bat_gen-3.3.0/README.md +223 -0
- venv_bat_gen-3.3.0/pyproject.toml +77 -0
- venv_bat_gen-3.3.0/venv_bat_gen/__init__.py +13 -0
- venv_bat_gen-3.3.0/venv_bat_gen/__main__.py +13 -0
- venv_bat_gen-3.3.0/venv_bat_gen/cli.py +406 -0
- venv_bat_gen-3.3.0/venv_bat_gen/core.py +1753 -0
- venv_bat_gen-3.3.0/venv_bat_gen/gui.py +1141 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
*.pyd
|
|
6
|
+
.Python
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.eggs/
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# uv
|
|
18
|
+
uv.lock
|
|
19
|
+
.uv/
|
|
20
|
+
|
|
21
|
+
# IDE
|
|
22
|
+
.vscode/
|
|
23
|
+
.idea/
|
|
24
|
+
*.swp
|
|
25
|
+
*.swo
|
|
26
|
+
|
|
27
|
+
# OS
|
|
28
|
+
.DS_Store
|
|
29
|
+
Thumbs.db
|
|
30
|
+
desktop.ini
|
|
31
|
+
|
|
32
|
+
# Testing
|
|
33
|
+
.pytest_cache/
|
|
34
|
+
.coverage
|
|
35
|
+
htmlcov/
|
|
36
|
+
.tox/
|
|
37
|
+
|
|
38
|
+
# Distribution
|
|
39
|
+
*.whl
|
|
40
|
+
*.tar.gz
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 KeystoneAI
|
|
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,254 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: venv-bat-gen
|
|
3
|
+
Version: 3.3.0
|
|
4
|
+
Summary: Generate project-local venv helper scripts (.bat + .sh) for Windows, WSL, macOS, and Linux.
|
|
5
|
+
Project-URL: Homepage, https://github.com/keystoneai/venv-bat-gen
|
|
6
|
+
Project-URL: Repository, https://github.com/keystoneai/venv-bat-gen
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/keystoneai/venv-bat-gen/issues
|
|
8
|
+
Author-email: KeystoneAI <hello@keystoneai.dev>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: batch,developer-tools,python-tooling,uv,venv,virtualenv,windows
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Environment :: Win32 (MS Windows)
|
|
15
|
+
Classifier: Environment :: X11 Applications :: Qt
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Requires-Dist: pyqt6>=6.4
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest-qt>=4.2; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# venv-bat-gen
|
|
33
|
+
|
|
34
|
+
**Generate project-local venv helper scripts for Python projects — Windows, WSL, macOS, and Linux.**
|
|
35
|
+
|
|
36
|
+
`venv-bat-gen` solves a specific Windows pain point: activating a virtual environment manually is annoying, error-prone, and breaks in scripts. The correct approach is to call `.venv\Scripts\python.exe` directly — but writing those helper scripts by hand every time is tedious.
|
|
37
|
+
|
|
38
|
+
This tool generates a complete set of project-local helper scripts in seconds, from a polished GUI or a single CLI command.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## What it generates
|
|
43
|
+
|
|
44
|
+
For every project, `venv-bat-gen` writes up to **12 scripts** (`.bat` for Windows, `.sh` for POSIX):
|
|
45
|
+
|
|
46
|
+
| Script | Purpose |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `run.bat` / `run.sh` | Run your project — file, module, or runner mode |
|
|
49
|
+
| `pip.bat` / `pip.sh` | Project-local pip (or uv pip) wrapper |
|
|
50
|
+
| `shell.bat` / `shell.sh` | Open an activated shell session |
|
|
51
|
+
| `sync.bat` / `sync.sh` | Install / sync dependencies |
|
|
52
|
+
| `doctor.bat` / `doctor.sh` | Environment health check |
|
|
53
|
+
| `test.bat` / `test.sh` | Run pytest via the local venv |
|
|
54
|
+
|
|
55
|
+
Every script calls `.venv\Scripts\python.exe` (or `.venv/bin/python`) directly — **no manual activation required**, and no PATH pollution.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
**Via pip:**
|
|
62
|
+
```bash
|
|
63
|
+
pip install venv-bat-gen
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Via uv (recommended):**
|
|
67
|
+
```bash
|
|
68
|
+
uv pip install venv-bat-gen
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Via uv tool (globally, isolated):**
|
|
72
|
+
```bash
|
|
73
|
+
uv tool install venv-bat-gen
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**From source:**
|
|
77
|
+
```bash
|
|
78
|
+
git clone https://github.com/keystoneai/venv-bat-gen
|
|
79
|
+
cd venv-bat-gen
|
|
80
|
+
pip install -e .
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
> **Note:** The GUI requires PyQt6. If you only need the CLI, PyQt6 is still installed as a dependency — a headless CLI-only mode may be added in a future release.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
### GUI
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Launch the GUI
|
|
93
|
+
venv-bat-gen-gui
|
|
94
|
+
|
|
95
|
+
# Or
|
|
96
|
+
python -m venv_bat_gen
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The GUI provides:
|
|
100
|
+
- **Presets** — built-in templates for FastAPI, PyQt6, CLI scripts, Streamlit, and uv projects. Save your own.
|
|
101
|
+
- **Folder auto-detect** — browse to a project folder and the scanner reads `pyproject.toml`, `uv.lock`, `requirements.txt`, and common entry files to suggest settings automatically.
|
|
102
|
+
- **Live preview** — see the generated scripts before writing them, with syntax highlighting.
|
|
103
|
+
- **Configure / Log tabs** — settings scroll freely on any screen size; the activity log switches automatically on generate.
|
|
104
|
+
|
|
105
|
+
### CLI
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Basic usage
|
|
109
|
+
venv-bat-gen generate C:\projects\myapi --runner --entry uvicorn \
|
|
110
|
+
--runner-args "app.main:app --host 0.0.0.0 --port 8000 --reload"
|
|
111
|
+
|
|
112
|
+
# Load a preset as defaults, then override
|
|
113
|
+
venv-bat-gen generate C:\projects\myapp --preset "FastAPI / Uvicorn" --name MyApp
|
|
114
|
+
|
|
115
|
+
# Use uv + generate POSIX .sh scripts too
|
|
116
|
+
venv-bat-gen generate ~/projects/mytool --module --entry mytool --uv --posix
|
|
117
|
+
|
|
118
|
+
# Dry run — see what would be written
|
|
119
|
+
venv-bat-gen generate C:\projects\myapp --preset "PyQt6 Desktop App" --dry-run
|
|
120
|
+
|
|
121
|
+
# Scan a folder for auto-detection hints
|
|
122
|
+
venv-bat-gen scan C:\projects\existing
|
|
123
|
+
|
|
124
|
+
# List available presets
|
|
125
|
+
venv-bat-gen presets
|
|
126
|
+
venv-bat-gen presets --detail
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Entry modes
|
|
130
|
+
|
|
131
|
+
| Flag | Generated command | Use when |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| `--file` | `python main.py` | Single entry file |
|
|
134
|
+
| `--module` | `python -m mypackage` | Proper package with `__main__.py` |
|
|
135
|
+
| `--runner` | `python -m uvicorn app.main:app ...` | Tools like uvicorn, streamlit, flask |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## uv support
|
|
140
|
+
|
|
141
|
+
Pass `--uv` (CLI) or check "Use uv" (GUI) to generate uv-native scripts:
|
|
142
|
+
|
|
143
|
+
- `sync.bat/sh` — runs `uv sync` (with `uv.lock` / `pyproject.toml` detection) or falls back to `uv pip install -r requirements.txt`
|
|
144
|
+
- `pip.bat/sh` — wraps `uv pip --python .venv/...`
|
|
145
|
+
- `doctor.bat/sh` — checks `uv` is on PATH and shows its version
|
|
146
|
+
- `create_venv` — runs `uv venv` instead of `python -m venv`, with graceful fallback if uv isn't installed
|
|
147
|
+
|
|
148
|
+
The **"uv Project"** built-in preset configures all of this automatically.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Cross-platform (POSIX) scripts
|
|
153
|
+
|
|
154
|
+
Pass `--posix` (CLI) or check "Generate POSIX .sh scripts" (GUI) to also write `.sh` equivalents of every script. Shell scripts are written with:
|
|
155
|
+
- Unix LF line endings
|
|
156
|
+
- `#!/usr/bin/env bash` shebang
|
|
157
|
+
- `chmod +x` set automatically on generate
|
|
158
|
+
- `.venv/bin/python` instead of `.venv\Scripts\python.exe`
|
|
159
|
+
|
|
160
|
+
The **"CLI Script (Cross-Platform)"** preset generates both `.bat` and `.sh` by default.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Presets
|
|
165
|
+
|
|
166
|
+
Built-in presets (read-only):
|
|
167
|
+
|
|
168
|
+
| Preset | Mode | Entry | uv | POSIX |
|
|
169
|
+
|---|---|---|---|---|
|
|
170
|
+
| FastAPI / Uvicorn | runner | uvicorn | — | — |
|
|
171
|
+
| PyQt6 Desktop App | file | main.py | — | — |
|
|
172
|
+
| CLI Script | module | app | — | — |
|
|
173
|
+
| CLI Script (Cross-Platform) | module | app | — | ✔ |
|
|
174
|
+
| Streamlit App | runner | streamlit | — | — |
|
|
175
|
+
| uv Project | module | app | ✔ | — |
|
|
176
|
+
|
|
177
|
+
User presets are saved to `~/.keystoneai/venv_generator_presets.json` and persist across sessions.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Project structure
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
venv_bat_gen/
|
|
185
|
+
├── __init__.py # version
|
|
186
|
+
├── __main__.py # python -m venv_bat_gen entry point
|
|
187
|
+
├── core.py # GeneratorConfig, all template generators, scanner, presets
|
|
188
|
+
├── cli.py # argparse CLI — no Qt dependency
|
|
189
|
+
└── gui.py # PyQt6 GUI — imports from core
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`core.py` has zero Qt imports and is safe to use headlessly from scripts or other tools:
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
from venv_bat_gen.core import GeneratorConfig, generate_files
|
|
196
|
+
|
|
197
|
+
cfg = GeneratorConfig(
|
|
198
|
+
project_dir=Path("C:/projects/myapi"),
|
|
199
|
+
project_name="MyAPI",
|
|
200
|
+
venv_dir=".venv",
|
|
201
|
+
entry_mode="runner",
|
|
202
|
+
app_entry="uvicorn",
|
|
203
|
+
runner_args="app.main:app --host 0.0.0.0 --port 8000 --reload",
|
|
204
|
+
overwrite_existing=False,
|
|
205
|
+
create_requirements=True,
|
|
206
|
+
include_webengine_check=False,
|
|
207
|
+
pause_on_exit=False,
|
|
208
|
+
create_venv_now=False,
|
|
209
|
+
include_test_bat=True,
|
|
210
|
+
use_uv=False,
|
|
211
|
+
include_posix=False,
|
|
212
|
+
)
|
|
213
|
+
written = generate_files(cfg)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Requirements
|
|
219
|
+
|
|
220
|
+
- Python 3.11+
|
|
221
|
+
- PyQt6 6.4+ (GUI)
|
|
222
|
+
- uv (optional — only needed if using `--uv` / "Use uv" mode)
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Why not just activate the venv?
|
|
227
|
+
|
|
228
|
+
Activation works fine interactively. It breaks when:
|
|
229
|
+
- You run scripts from task schedulers, CI, or other tools that don't inherit your shell state
|
|
230
|
+
- You have multiple projects open and activation leaks across terminals
|
|
231
|
+
- You want a double-clickable launcher that just works
|
|
232
|
+
|
|
233
|
+
Calling `.venv\Scripts\python.exe` directly avoids all of this. The generated scripts are readable, editable, and self-documenting — they're not magic wrappers.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Contributing
|
|
238
|
+
|
|
239
|
+
Issues and PRs welcome. The codebase is intentionally simple:
|
|
240
|
+
|
|
241
|
+
- Add a new template → add `make_<name>_bat()` and `make_<name>_sh()` to `core.py`, register in `build_previews()`
|
|
242
|
+
- Add a new preset → add an entry to `_BUILTIN_PRESETS` in `core.py`
|
|
243
|
+
- Add a CLI flag → `_build_generate_parser()` in `cli.py`, wire through `_cmd_generate()`
|
|
244
|
+
- Add a GUI option → `_build_options_group()` in `gui.py`, wire through `_read_config()`
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## License
|
|
249
|
+
|
|
250
|
+
MIT — see [LICENSE](LICENSE).
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
*Built by [KeystoneAI](https://github.com/keystoneai) · Iterated with the help of Claude (Anthropic)*
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# venv-bat-gen
|
|
2
|
+
|
|
3
|
+
**Generate project-local venv helper scripts for Python projects — Windows, WSL, macOS, and Linux.**
|
|
4
|
+
|
|
5
|
+
`venv-bat-gen` solves a specific Windows pain point: activating a virtual environment manually is annoying, error-prone, and breaks in scripts. The correct approach is to call `.venv\Scripts\python.exe` directly — but writing those helper scripts by hand every time is tedious.
|
|
6
|
+
|
|
7
|
+
This tool generates a complete set of project-local helper scripts in seconds, from a polished GUI or a single CLI command.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What it generates
|
|
12
|
+
|
|
13
|
+
For every project, `venv-bat-gen` writes up to **12 scripts** (`.bat` for Windows, `.sh` for POSIX):
|
|
14
|
+
|
|
15
|
+
| Script | Purpose |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `run.bat` / `run.sh` | Run your project — file, module, or runner mode |
|
|
18
|
+
| `pip.bat` / `pip.sh` | Project-local pip (or uv pip) wrapper |
|
|
19
|
+
| `shell.bat` / `shell.sh` | Open an activated shell session |
|
|
20
|
+
| `sync.bat` / `sync.sh` | Install / sync dependencies |
|
|
21
|
+
| `doctor.bat` / `doctor.sh` | Environment health check |
|
|
22
|
+
| `test.bat` / `test.sh` | Run pytest via the local venv |
|
|
23
|
+
|
|
24
|
+
Every script calls `.venv\Scripts\python.exe` (or `.venv/bin/python`) directly — **no manual activation required**, and no PATH pollution.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
**Via pip:**
|
|
31
|
+
```bash
|
|
32
|
+
pip install venv-bat-gen
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Via uv (recommended):**
|
|
36
|
+
```bash
|
|
37
|
+
uv pip install venv-bat-gen
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Via uv tool (globally, isolated):**
|
|
41
|
+
```bash
|
|
42
|
+
uv tool install venv-bat-gen
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**From source:**
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/keystoneai/venv-bat-gen
|
|
48
|
+
cd venv-bat-gen
|
|
49
|
+
pip install -e .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> **Note:** The GUI requires PyQt6. If you only need the CLI, PyQt6 is still installed as a dependency — a headless CLI-only mode may be added in a future release.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
### GUI
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Launch the GUI
|
|
62
|
+
venv-bat-gen-gui
|
|
63
|
+
|
|
64
|
+
# Or
|
|
65
|
+
python -m venv_bat_gen
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The GUI provides:
|
|
69
|
+
- **Presets** — built-in templates for FastAPI, PyQt6, CLI scripts, Streamlit, and uv projects. Save your own.
|
|
70
|
+
- **Folder auto-detect** — browse to a project folder and the scanner reads `pyproject.toml`, `uv.lock`, `requirements.txt`, and common entry files to suggest settings automatically.
|
|
71
|
+
- **Live preview** — see the generated scripts before writing them, with syntax highlighting.
|
|
72
|
+
- **Configure / Log tabs** — settings scroll freely on any screen size; the activity log switches automatically on generate.
|
|
73
|
+
|
|
74
|
+
### CLI
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Basic usage
|
|
78
|
+
venv-bat-gen generate C:\projects\myapi --runner --entry uvicorn \
|
|
79
|
+
--runner-args "app.main:app --host 0.0.0.0 --port 8000 --reload"
|
|
80
|
+
|
|
81
|
+
# Load a preset as defaults, then override
|
|
82
|
+
venv-bat-gen generate C:\projects\myapp --preset "FastAPI / Uvicorn" --name MyApp
|
|
83
|
+
|
|
84
|
+
# Use uv + generate POSIX .sh scripts too
|
|
85
|
+
venv-bat-gen generate ~/projects/mytool --module --entry mytool --uv --posix
|
|
86
|
+
|
|
87
|
+
# Dry run — see what would be written
|
|
88
|
+
venv-bat-gen generate C:\projects\myapp --preset "PyQt6 Desktop App" --dry-run
|
|
89
|
+
|
|
90
|
+
# Scan a folder for auto-detection hints
|
|
91
|
+
venv-bat-gen scan C:\projects\existing
|
|
92
|
+
|
|
93
|
+
# List available presets
|
|
94
|
+
venv-bat-gen presets
|
|
95
|
+
venv-bat-gen presets --detail
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Entry modes
|
|
99
|
+
|
|
100
|
+
| Flag | Generated command | Use when |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `--file` | `python main.py` | Single entry file |
|
|
103
|
+
| `--module` | `python -m mypackage` | Proper package with `__main__.py` |
|
|
104
|
+
| `--runner` | `python -m uvicorn app.main:app ...` | Tools like uvicorn, streamlit, flask |
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## uv support
|
|
109
|
+
|
|
110
|
+
Pass `--uv` (CLI) or check "Use uv" (GUI) to generate uv-native scripts:
|
|
111
|
+
|
|
112
|
+
- `sync.bat/sh` — runs `uv sync` (with `uv.lock` / `pyproject.toml` detection) or falls back to `uv pip install -r requirements.txt`
|
|
113
|
+
- `pip.bat/sh` — wraps `uv pip --python .venv/...`
|
|
114
|
+
- `doctor.bat/sh` — checks `uv` is on PATH and shows its version
|
|
115
|
+
- `create_venv` — runs `uv venv` instead of `python -m venv`, with graceful fallback if uv isn't installed
|
|
116
|
+
|
|
117
|
+
The **"uv Project"** built-in preset configures all of this automatically.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Cross-platform (POSIX) scripts
|
|
122
|
+
|
|
123
|
+
Pass `--posix` (CLI) or check "Generate POSIX .sh scripts" (GUI) to also write `.sh` equivalents of every script. Shell scripts are written with:
|
|
124
|
+
- Unix LF line endings
|
|
125
|
+
- `#!/usr/bin/env bash` shebang
|
|
126
|
+
- `chmod +x` set automatically on generate
|
|
127
|
+
- `.venv/bin/python` instead of `.venv\Scripts\python.exe`
|
|
128
|
+
|
|
129
|
+
The **"CLI Script (Cross-Platform)"** preset generates both `.bat` and `.sh` by default.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Presets
|
|
134
|
+
|
|
135
|
+
Built-in presets (read-only):
|
|
136
|
+
|
|
137
|
+
| Preset | Mode | Entry | uv | POSIX |
|
|
138
|
+
|---|---|---|---|---|
|
|
139
|
+
| FastAPI / Uvicorn | runner | uvicorn | — | — |
|
|
140
|
+
| PyQt6 Desktop App | file | main.py | — | — |
|
|
141
|
+
| CLI Script | module | app | — | — |
|
|
142
|
+
| CLI Script (Cross-Platform) | module | app | — | ✔ |
|
|
143
|
+
| Streamlit App | runner | streamlit | — | — |
|
|
144
|
+
| uv Project | module | app | ✔ | — |
|
|
145
|
+
|
|
146
|
+
User presets are saved to `~/.keystoneai/venv_generator_presets.json` and persist across sessions.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Project structure
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
venv_bat_gen/
|
|
154
|
+
├── __init__.py # version
|
|
155
|
+
├── __main__.py # python -m venv_bat_gen entry point
|
|
156
|
+
├── core.py # GeneratorConfig, all template generators, scanner, presets
|
|
157
|
+
├── cli.py # argparse CLI — no Qt dependency
|
|
158
|
+
└── gui.py # PyQt6 GUI — imports from core
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`core.py` has zero Qt imports and is safe to use headlessly from scripts or other tools:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from venv_bat_gen.core import GeneratorConfig, generate_files
|
|
165
|
+
|
|
166
|
+
cfg = GeneratorConfig(
|
|
167
|
+
project_dir=Path("C:/projects/myapi"),
|
|
168
|
+
project_name="MyAPI",
|
|
169
|
+
venv_dir=".venv",
|
|
170
|
+
entry_mode="runner",
|
|
171
|
+
app_entry="uvicorn",
|
|
172
|
+
runner_args="app.main:app --host 0.0.0.0 --port 8000 --reload",
|
|
173
|
+
overwrite_existing=False,
|
|
174
|
+
create_requirements=True,
|
|
175
|
+
include_webengine_check=False,
|
|
176
|
+
pause_on_exit=False,
|
|
177
|
+
create_venv_now=False,
|
|
178
|
+
include_test_bat=True,
|
|
179
|
+
use_uv=False,
|
|
180
|
+
include_posix=False,
|
|
181
|
+
)
|
|
182
|
+
written = generate_files(cfg)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Requirements
|
|
188
|
+
|
|
189
|
+
- Python 3.11+
|
|
190
|
+
- PyQt6 6.4+ (GUI)
|
|
191
|
+
- uv (optional — only needed if using `--uv` / "Use uv" mode)
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Why not just activate the venv?
|
|
196
|
+
|
|
197
|
+
Activation works fine interactively. It breaks when:
|
|
198
|
+
- You run scripts from task schedulers, CI, or other tools that don't inherit your shell state
|
|
199
|
+
- You have multiple projects open and activation leaks across terminals
|
|
200
|
+
- You want a double-clickable launcher that just works
|
|
201
|
+
|
|
202
|
+
Calling `.venv\Scripts\python.exe` directly avoids all of this. The generated scripts are readable, editable, and self-documenting — they're not magic wrappers.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Contributing
|
|
207
|
+
|
|
208
|
+
Issues and PRs welcome. The codebase is intentionally simple:
|
|
209
|
+
|
|
210
|
+
- Add a new template → add `make_<name>_bat()` and `make_<name>_sh()` to `core.py`, register in `build_previews()`
|
|
211
|
+
- Add a new preset → add an entry to `_BUILTIN_PRESETS` in `core.py`
|
|
212
|
+
- Add a CLI flag → `_build_generate_parser()` in `cli.py`, wire through `_cmd_generate()`
|
|
213
|
+
- Add a GUI option → `_build_options_group()` in `gui.py`, wire through `_read_config()`
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
MIT — see [LICENSE](LICENSE).
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
*Built by [KeystoneAI](https://github.com/keystoneai) · Iterated with the help of Claude (Anthropic)*
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "venv-bat-gen"
|
|
7
|
+
version = "3.3.0"
|
|
8
|
+
description = "Generate project-local venv helper scripts (.bat + .sh) for Windows, WSL, macOS, and Linux."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "KeystoneAI", email = "hello@keystoneai.dev" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"venv",
|
|
17
|
+
"virtualenv",
|
|
18
|
+
"batch",
|
|
19
|
+
"windows",
|
|
20
|
+
"developer-tools",
|
|
21
|
+
"uv",
|
|
22
|
+
"python-tooling",
|
|
23
|
+
]
|
|
24
|
+
classifiers = [
|
|
25
|
+
"Development Status :: 5 - Production/Stable",
|
|
26
|
+
"Environment :: Win32 (MS Windows)",
|
|
27
|
+
"Environment :: Console",
|
|
28
|
+
"Environment :: X11 Applications :: Qt",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"License :: OSI Approved :: MIT License",
|
|
31
|
+
"Operating System :: OS Independent",
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
"Programming Language :: Python :: 3.13",
|
|
36
|
+
"Topic :: Software Development :: Build Tools",
|
|
37
|
+
"Topic :: Utilities",
|
|
38
|
+
]
|
|
39
|
+
dependencies = [
|
|
40
|
+
"PyQt6>=6.4",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest>=7.0",
|
|
46
|
+
"pytest-qt>=4.2",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.scripts]
|
|
50
|
+
venv-bat-gen = "venv_bat_gen.cli:main"
|
|
51
|
+
|
|
52
|
+
[project.gui-scripts]
|
|
53
|
+
venv-bat-gen-gui = "venv_bat_gen.gui:main"
|
|
54
|
+
|
|
55
|
+
[project.urls]
|
|
56
|
+
Homepage = "https://github.com/keystoneai/venv-bat-gen"
|
|
57
|
+
Repository = "https://github.com/keystoneai/venv-bat-gen"
|
|
58
|
+
"Bug Tracker" = "https://github.com/keystoneai/venv-bat-gen/issues"
|
|
59
|
+
|
|
60
|
+
[tool.hatch.build.targets.wheel]
|
|
61
|
+
packages = ["venv_bat_gen"]
|
|
62
|
+
|
|
63
|
+
[tool.hatch.build.targets.sdist]
|
|
64
|
+
include = [
|
|
65
|
+
"venv_bat_gen/",
|
|
66
|
+
"README.md",
|
|
67
|
+
"LICENSE",
|
|
68
|
+
"pyproject.toml",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[tool.pytest.ini_options]
|
|
72
|
+
testpaths = ["tests"]
|
|
73
|
+
python_files = ["test_*.py"]
|
|
74
|
+
|
|
75
|
+
[tool.ruff]
|
|
76
|
+
line-length = 100
|
|
77
|
+
target-version = "py311"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
venv_bat_gen
|
|
3
|
+
============
|
|
4
|
+
Venv Batch Template Generator — KeystoneAI
|
|
5
|
+
|
|
6
|
+
Public API:
|
|
7
|
+
from venv_bat_gen.core import GeneratorConfig, generate_files, scan_project_folder
|
|
8
|
+
from venv_bat_gen.cli import main as cli_main
|
|
9
|
+
from venv_bat_gen.gui import main as gui_main
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
__version__ = "3.3.0"
|
|
13
|
+
__author__ = "KeystoneAI"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Enable `python -m venv_bat_gen` entry point.
|
|
2
|
+
|
|
3
|
+
With no arguments: launches the GUI.
|
|
4
|
+
With arguments: runs the CLI.
|
|
5
|
+
"""
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
if len(sys.argv) > 1:
|
|
9
|
+
from venv_bat_gen.cli import main
|
|
10
|
+
else:
|
|
11
|
+
from venv_bat_gen.gui import main
|
|
12
|
+
|
|
13
|
+
main()
|