tn-venv 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.
- tn_venv-0.1.0/License.txt +31 -0
- tn_venv-0.1.0/PKG-INFO +282 -0
- tn_venv-0.1.0/README.md +225 -0
- tn_venv-0.1.0/pyproject.toml +53 -0
- tn_venv-0.1.0/setup.cfg +4 -0
- tn_venv-0.1.0/tests/test_cli.py +195 -0
- tn_venv-0.1.0/tests/test_config_loader.py +171 -0
- tn_venv-0.1.0/tests/test_config_spec.py +134 -0
- tn_venv-0.1.0/tests/test_create_activators.py +191 -0
- tn_venv-0.1.0/tests/test_create_context.py +98 -0
- tn_venv-0.1.0/tests/test_create_creator.py +173 -0
- tn_venv-0.1.0/tests/test_create_venv.py +124 -0
- tn_venv-0.1.0/tests/test_discovery.py +104 -0
- tn_venv-0.1.0/tests/test_discovery_providers.py +156 -0
- tn_venv-0.1.0/tests/test_discovery_python_info.py +192 -0
- tn_venv-0.1.0/tests/test_errors.py +82 -0
- tn_venv-0.1.0/tests/test_package.py +57 -0
- tn_venv-0.1.0/tests/test_report.py +173 -0
- tn_venv-0.1.0/tests/test_seed.py +162 -0
- tn_venv-0.1.0/tests/test_session_options.py +113 -0
- tn_venv-0.1.0/tests/test_util_lock.py +107 -0
- tn_venv-0.1.0/tests/test_util_path.py +157 -0
- tn_venv-0.1.0/tests/test_util_process.py +97 -0
- tn_venv-0.1.0/tn_venv/__init__.py +50 -0
- tn_venv-0.1.0/tn_venv/__main__.py +8 -0
- tn_venv-0.1.0/tn_venv/cli.py +237 -0
- tn_venv-0.1.0/tn_venv/config/__init__.py +15 -0
- tn_venv-0.1.0/tn_venv/config/loader.py +150 -0
- tn_venv-0.1.0/tn_venv/config/spec.py +298 -0
- tn_venv-0.1.0/tn_venv/create/__init__.py +14 -0
- tn_venv-0.1.0/tn_venv/create/activators/__init__.py +68 -0
- tn_venv-0.1.0/tn_venv/create/activators/base.py +90 -0
- tn_venv-0.1.0/tn_venv/create/activators/bash.py +80 -0
- tn_venv-0.1.0/tn_venv/create/activators/batch.py +78 -0
- tn_venv-0.1.0/tn_venv/create/activators/csh.py +68 -0
- tn_venv-0.1.0/tn_venv/create/activators/fish.py +76 -0
- tn_venv-0.1.0/tn_venv/create/activators/nushell.py +50 -0
- tn_venv-0.1.0/tn_venv/create/activators/powershell.py +75 -0
- tn_venv-0.1.0/tn_venv/create/activators/python_activate.py +58 -0
- tn_venv-0.1.0/tn_venv/create/context.py +70 -0
- tn_venv-0.1.0/tn_venv/create/creator.py +410 -0
- tn_venv-0.1.0/tn_venv/discovery/__init__.py +137 -0
- tn_venv-0.1.0/tn_venv/discovery/providers.py +138 -0
- tn_venv-0.1.0/tn_venv/discovery/py_launcher.py +49 -0
- tn_venv-0.1.0/tn_venv/discovery/python_info.py +252 -0
- tn_venv-0.1.0/tn_venv/discovery/query.py +82 -0
- tn_venv-0.1.0/tn_venv/discovery/windows_registry.py +69 -0
- tn_venv-0.1.0/tn_venv/errors.py +74 -0
- tn_venv-0.1.0/tn_venv/py.typed +0 -0
- tn_venv-0.1.0/tn_venv/report.py +135 -0
- tn_venv-0.1.0/tn_venv/seed/__init__.py +7 -0
- tn_venv-0.1.0/tn_venv/seed/seeder.py +197 -0
- tn_venv-0.1.0/tn_venv/session.py +282 -0
- tn_venv-0.1.0/tn_venv/util/__init__.py +29 -0
- tn_venv-0.1.0/tn_venv/util/lock.py +141 -0
- tn_venv-0.1.0/tn_venv/util/path.py +86 -0
- tn_venv-0.1.0/tn_venv/util/process.py +65 -0
- tn_venv-0.1.0/tn_venv/version.py +24 -0
- tn_venv-0.1.0/tn_venv.egg-info/PKG-INFO +282 -0
- tn_venv-0.1.0/tn_venv.egg-info/SOURCES.txt +61 -0
- tn_venv-0.1.0/tn_venv.egg-info/dependency_links.txt +1 -0
- tn_venv-0.1.0/tn_venv.egg-info/entry_points.txt +3 -0
- tn_venv-0.1.0/tn_venv.egg-info/top_level.txt +2 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Tokenoodle-Everything License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tokenoodle-Everything Organization
|
|
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, and sublicense the Software,
|
|
9
|
+
subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
1. The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
2. THE SOFTWARE MAY NOT BE USED FOR ANY COMMERCIAL PURPOSE.
|
|
15
|
+
Commercial purposes include, but are not limited to: selling the Software,
|
|
16
|
+
using the Software within a paid service, monetizing products built upon the Software,
|
|
17
|
+
using the Software for business revenue-generating activities, and integrating the Software
|
|
18
|
+
into commercial products.
|
|
19
|
+
|
|
20
|
+
3. This license is non-transferable. Any distribution of modified copies of the Software
|
|
21
|
+
must use this exact license and retain this notice; you may not relicense the Software
|
|
22
|
+
or modified derivatives under a different license.
|
|
23
|
+
|
|
24
|
+
4. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
25
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
26
|
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
27
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
28
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
29
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
30
|
+
|
|
31
|
+
This is NOT an OSI-approved open source license.
|
tn_venv-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tn-venv
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Create Python virtual environments with one command — a batteries-included virtualenv alternative
|
|
5
|
+
Author: Tokenoodle-Everything Organization
|
|
6
|
+
License: Tokenoodle-Everything License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Tokenoodle-Everything Organization
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, and sublicense the Software,
|
|
14
|
+
subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
1. The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
2. THE SOFTWARE MAY NOT BE USED FOR ANY COMMERCIAL PURPOSE.
|
|
20
|
+
Commercial purposes include, but are not limited to: selling the Software,
|
|
21
|
+
using the Software within a paid service, monetizing products built upon the Software,
|
|
22
|
+
using the Software for business revenue-generating activities, and integrating the Software
|
|
23
|
+
into commercial products.
|
|
24
|
+
|
|
25
|
+
3. This license is non-transferable. Any distribution of modified copies of the Software
|
|
26
|
+
must use this exact license and retain this notice; you may not relicense the Software
|
|
27
|
+
or modified derivatives under a different license.
|
|
28
|
+
|
|
29
|
+
4. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
30
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
31
|
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
32
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
33
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
34
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
35
|
+
|
|
36
|
+
This is NOT an OSI-approved open source license.
|
|
37
|
+
Project-URL: Homepage, https://github.com/tokenoodle-everything/tn-venv
|
|
38
|
+
Project-URL: Documentation, https://github.com/tokenoodle-everything/tn-venv#readme
|
|
39
|
+
Project-URL: Source, https://github.com/tokenoodle-everything/tn-venv
|
|
40
|
+
Keywords: virtualenv,venv,environment,isolation,packaging
|
|
41
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
42
|
+
Classifier: Environment :: Console
|
|
43
|
+
Classifier: Intended Audience :: Developers
|
|
44
|
+
Classifier: Operating System :: OS Independent
|
|
45
|
+
Classifier: Programming Language :: Python :: 3
|
|
46
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
47
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
48
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
49
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
50
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
51
|
+
Classifier: Topic :: System :: Systems Administration
|
|
52
|
+
Classifier: Topic :: Utilities
|
|
53
|
+
Requires-Python: >=3.11
|
|
54
|
+
Description-Content-Type: text/markdown
|
|
55
|
+
License-File: License.txt
|
|
56
|
+
Dynamic: license-file
|
|
57
|
+
|
|
58
|
+
# TnVenv
|
|
59
|
+
|
|
60
|
+
> Create a Python virtual environment — **batteries included**.
|
|
61
|
+
|
|
62
|
+
`tn-venv` is a zero-dependency, batteries-included replacement for `python -m venv`
|
|
63
|
+
that picks sensible defaults out of the box: running bare `tn-venv` creates `./.venv`
|
|
64
|
+
with the current interpreter and `pip` already installed.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
$ tn-venv
|
|
68
|
+
==> creating virtual environment at ./.venv
|
|
69
|
+
==> installing pip (ensurepip)
|
|
70
|
+
interpreter: cpython 3.14.7 (64-bit) from C:\Python314\python.exe
|
|
71
|
+
==> python binaries installed to ./.venv\Scripts
|
|
72
|
+
environment ready: .\.venv\Scripts\python.exe
|
|
73
|
+
activate with: .\.venv\Scripts\Activate.ps1 (PowerShell) | .\.venv\Scripts\activate.bat (cmd)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Why tn-venv?
|
|
79
|
+
|
|
80
|
+
| | `tn-venv` | stdlib `venv` | `virtualenv` |
|
|
81
|
+
|---|---|---|---|
|
|
82
|
+
| Zero runtime dependencies | ✅ | ✅ | ❌ |
|
|
83
|
+
| Ships `pip`, `setuptools`, `wheel` after creation | ✅ | ❌ (3.12+) | ✅ |
|
|
84
|
+
| Generates activation scripts for **bash / zsh / fish / csh / Nushell / PowerShell / cmd** | ✅ | bash + PowerShell | 5 shells |
|
|
85
|
+
| Discovers interpreters from PATH, registry, `py` launcher, `uv`, `pyenv` | ✅ | ❌ | partial |
|
|
86
|
+
| Pin or upgrade pip from the index | ✅ | ❌ | ✅ |
|
|
87
|
+
| Offline mode / extra wheel dirs | ✅ | ❌ | ✅ |
|
|
88
|
+
| Pure-Python, no compiled extensions | ✅ | ✅ | ❌ |
|
|
89
|
+
| Ships `activate_this.py` | ✅ | ❌ | ✅ |
|
|
90
|
+
| Locking against concurrent creation | ✅ | ❌ | ❌ |
|
|
91
|
+
| One command, sensible defaults | ✅ | ❌ | ✅ |
|
|
92
|
+
|
|
93
|
+
Requires **Python 3.11+**.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Installation
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pip install tn-venv
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Or directly from the repo:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pip install git+https://github.com/tokenoodle-everything/tn-venv.git
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
This installs two console scripts:
|
|
110
|
+
|
|
111
|
+
- `tn-venv`
|
|
112
|
+
- `tn_venv` (alias)
|
|
113
|
+
|
|
114
|
+
You can also invoke the CLI without installing anything:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
python -m tn_venv .venv
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Quick start
|
|
123
|
+
```bash
|
|
124
|
+
tn-venv --list-pythons
|
|
125
|
+
|
|
126
|
+
# Print the resolved configuration without creating anything
|
|
127
|
+
tn-venv --dry-run
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## CLI reference
|
|
133
|
+
|
|
134
|
+
### Interpreter selection
|
|
135
|
+
|
|
136
|
+
| Flag | Description |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `-p SPEC` / `--python SPEC` | Python to build from — a path, a version (`3`, `3.12`, `3.12.1`), a name (`python3.12`, `pypy3.10`) or a PEP 514-ish tag. Repeatable; first match wins. Default: the interpreter running `tn-venv`. |
|
|
139
|
+
| `--list-pythons` | List every discoverable interpreter and exit. |
|
|
140
|
+
|
|
141
|
+
### Creator options
|
|
142
|
+
|
|
143
|
+
| Flag | Description |
|
|
144
|
+
|---|---|
|
|
145
|
+
| `--clear` | Delete the destination directory before creating. |
|
|
146
|
+
| `--upgrade` | Upgrade an existing environment in place (keep installed packages). |
|
|
147
|
+
| `--system-site-packages` | Give the environment access to the system site-packages. |
|
|
148
|
+
| `--symlinks` / `--no-symlinks` | Symlink the interpreter binaries (default on POSIX). |
|
|
149
|
+
| `--copies` / `--no-copies` | Copy the interpreter binaries (default on Windows). |
|
|
150
|
+
| `--scm-ignore {git,none}` | Write a source-control ignore file (default: `git`). |
|
|
151
|
+
|
|
152
|
+
### Seeder options
|
|
153
|
+
|
|
154
|
+
| Flag | Description |
|
|
155
|
+
|---|---|
|
|
156
|
+
| `--seeder {pip,none}` | Package installer to seed the environment with (default: `pip`). |
|
|
157
|
+
| `--no-pip` / `--without-pip` | Skip pip installation. |
|
|
158
|
+
| `--pip [VERSION]` | Pip version to install. Omit value for the latest release (`--pip` ≡ `--pip latest`), pass a version to pin (`--pip 24.0`). |
|
|
159
|
+
| `--upgrade-pip` | Upgrade pip to the latest release from the package index. |
|
|
160
|
+
| `--setuptools [VERSION]` | Install setuptools (optionally pinned). Not bundled on Python ≥ 3.12. |
|
|
161
|
+
| `--wheel [VERSION]` | Install wheel (optionally pinned). |
|
|
162
|
+
| `--extra-search-dir DIR` | Additional directory to search for wheels/sdists (`PIP_FIND_LINKS`). Repeatable. |
|
|
163
|
+
| `--offline` | Don't reach the network; use only bundled wheels and `--extra-search-dir` (`PIP_NO_INDEX`). |
|
|
164
|
+
| `--with PKG` / `--seed-package PKG` | Install extra packages after seeding. Repeatable. |
|
|
165
|
+
| `-r FILE` / `--requirements FILE` | Install from a requirements file. Repeatable. |
|
|
166
|
+
|
|
167
|
+
### Activation options
|
|
168
|
+
|
|
169
|
+
| Flag | Description |
|
|
170
|
+
|---|---|
|
|
171
|
+
| `--activators NAMES` | Comma-separated activation scripts to generate. Names: `bash`, `batch`, `powershell`, `fish`, `csh`, `nushell`, `python`, plus `all` and `default`. Prefix with `-` to exclude (e.g. `-fish`). |
|
|
172
|
+
| `--prompt NAME` | Custom prompt shown when the environment is active (default: the environment folder name). |
|
|
173
|
+
|
|
174
|
+
### Miscellaneous
|
|
175
|
+
|
|
176
|
+
| Flag | Description |
|
|
177
|
+
|---|---|
|
|
178
|
+
| `-q` / `--quiet` | Reduce verbosity (repeatable). |
|
|
179
|
+
| `-v` / `--verbose` | Increase verbosity (repeatable). |
|
|
180
|
+
| `--color` / `--no-color` | Force colored output on or off. Honors `NO_COLOR` and `FORCE_COLOR`. |
|
|
181
|
+
| `--dry-run` | Print the resolved configuration without creating anything. |
|
|
182
|
+
| `--config FILE` | Explicit path to a config file (overrides discovery). |
|
|
183
|
+
| `--no-config` | Ignore config files and environment variables. |
|
|
184
|
+
| `--version` | Print `tn-venv` version and exit. |
|
|
185
|
+
| `-h` / `--help` | Show help and exit. |
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# One command: create ./.venv with pip and the current interpreter
|
|
191
|
+
tn-venv
|
|
192
|
+
|
|
193
|
+
# Pick a destination and a specific interpreter version
|
|
194
|
+
tn-venv .venv -p 3.12
|
|
195
|
+
|
|
196
|
+
# Let the environment see globally-installed packages
|
|
197
|
+
tn-venv /tmp/x --system-site-packages
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Configuration
|
|
201
|
+
|
|
202
|
+
Configuration precedence (highest first):
|
|
203
|
+
|
|
204
|
+
1. **CLI flags** — e.g. `tn-venv --clear`
|
|
205
|
+
2. **`TN_VENV_*` environment variables** — e.g. `TN_VENV_CLEAR=1`
|
|
206
|
+
3. **Config file** — discovered automatically, or via `--config FILE` / `TN_VENV_CONFIG_FILE`
|
|
207
|
+
4. **Built-in defaults**
|
|
208
|
+
|
|
209
|
+
### Config file discovery
|
|
210
|
+
|
|
211
|
+
`tn-venv` walks the current directory and its parents (stopping at `.git`) looking for the first match:
|
|
212
|
+
|
|
213
|
+
1. `pyproject.toml` — only counts when it contains a `[tool.tn-venv]` or `[tool.tn_venv]` section
|
|
214
|
+
2. `tn-venv.ini`
|
|
215
|
+
3. `tn_venv.ini`
|
|
216
|
+
4. `.tn-venv.toml` — top-level keys
|
|
217
|
+
5. `setup.cfg` — only when it has a `[tn_venv]` section
|
|
218
|
+
|
|
219
|
+
### `pyproject.toml`
|
|
220
|
+
|
|
221
|
+
```toml
|
|
222
|
+
[tool.tn-venv]
|
|
223
|
+
python = ["3.12"]
|
|
224
|
+
prompt = "my-project"
|
|
225
|
+
system-site-packages = false
|
|
226
|
+
activators = "powershell,batch,-nushell"
|
|
227
|
+
with = ["requests", "click"]
|
|
228
|
+
upgrade-pip = true
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### `tn-venv.ini`
|
|
232
|
+
|
|
233
|
+
```ini
|
|
234
|
+
[tn-venv]
|
|
235
|
+
python = 3.12, 3.13
|
|
236
|
+
prompt = my-project
|
|
237
|
+
clear = yes
|
|
238
|
+
extra-search-dir = /srv/wheels
|
|
239
|
+
requirements = dev-requirements.txt
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Environment variables
|
|
243
|
+
|
|
244
|
+
Every option has a `TN_VENV_<NAME>` env var (uppercased destination):
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
export TN_VENV_PYTHON=3.12
|
|
248
|
+
export TN_VENV_PROMPT=my-project
|
|
249
|
+
export TN_VENV_CLEAR=1
|
|
250
|
+
export TN_VENV_NO_PIP=0
|
|
251
|
+
export TN_VENV_ACTIVATORS=powershell,batch
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Python API
|
|
255
|
+
|
|
256
|
+
Use `tn_venv.create_venv` programmatically:
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
from tn_venv import create_venv
|
|
260
|
+
|
|
261
|
+
result = create_venv(
|
|
262
|
+
".venv",
|
|
263
|
+
python="3.12",
|
|
264
|
+
with_pip=True,
|
|
265
|
+
pip="24.0",
|
|
266
|
+
setuptools=True,
|
|
267
|
+
wheel=True,
|
|
268
|
+
packages=["requests", "click"],
|
|
269
|
+
requirements=["dev-requirements.txt"],
|
|
270
|
+
activators=["bash", "powershell"],
|
|
271
|
+
prompt="my-project",
|
|
272
|
+
quiet=True,
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
print(result.env_dir) # PosixPath('.venv')
|
|
276
|
+
print(result.exe) # PosixPath('.venv/bin/python')
|
|
277
|
+
print(result.bin_path) # PosixPath('.venv/bin')
|
|
278
|
+
print(result.site_packages) # PosixPath('.venv/lib/python3.12/site-packages')
|
|
279
|
+
print(result.prompt) # 'my-project'
|
|
280
|
+
print(result.activation_scripts)
|
|
281
|
+
print(result.seed.pip) # '24.0'
|
|
282
|
+
```
|
tn_venv-0.1.0/README.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# TnVenv
|
|
2
|
+
|
|
3
|
+
> Create a Python virtual environment — **batteries included**.
|
|
4
|
+
|
|
5
|
+
`tn-venv` is a zero-dependency, batteries-included replacement for `python -m venv`
|
|
6
|
+
that picks sensible defaults out of the box: running bare `tn-venv` creates `./.venv`
|
|
7
|
+
with the current interpreter and `pip` already installed.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ tn-venv
|
|
11
|
+
==> creating virtual environment at ./.venv
|
|
12
|
+
==> installing pip (ensurepip)
|
|
13
|
+
interpreter: cpython 3.14.7 (64-bit) from C:\Python314\python.exe
|
|
14
|
+
==> python binaries installed to ./.venv\Scripts
|
|
15
|
+
environment ready: .\.venv\Scripts\python.exe
|
|
16
|
+
activate with: .\.venv\Scripts\Activate.ps1 (PowerShell) | .\.venv\Scripts\activate.bat (cmd)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Why tn-venv?
|
|
22
|
+
|
|
23
|
+
| | `tn-venv` | stdlib `venv` | `virtualenv` |
|
|
24
|
+
|---|---|---|---|
|
|
25
|
+
| Zero runtime dependencies | ✅ | ✅ | ❌ |
|
|
26
|
+
| Ships `pip`, `setuptools`, `wheel` after creation | ✅ | ❌ (3.12+) | ✅ |
|
|
27
|
+
| Generates activation scripts for **bash / zsh / fish / csh / Nushell / PowerShell / cmd** | ✅ | bash + PowerShell | 5 shells |
|
|
28
|
+
| Discovers interpreters from PATH, registry, `py` launcher, `uv`, `pyenv` | ✅ | ❌ | partial |
|
|
29
|
+
| Pin or upgrade pip from the index | ✅ | ❌ | ✅ |
|
|
30
|
+
| Offline mode / extra wheel dirs | ✅ | ❌ | ✅ |
|
|
31
|
+
| Pure-Python, no compiled extensions | ✅ | ✅ | ❌ |
|
|
32
|
+
| Ships `activate_this.py` | ✅ | ❌ | ✅ |
|
|
33
|
+
| Locking against concurrent creation | ✅ | ❌ | ❌ |
|
|
34
|
+
| One command, sensible defaults | ✅ | ❌ | ✅ |
|
|
35
|
+
|
|
36
|
+
Requires **Python 3.11+**.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install tn-venv
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or directly from the repo:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install git+https://github.com/tokenoodle-everything/tn-venv.git
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This installs two console scripts:
|
|
53
|
+
|
|
54
|
+
- `tn-venv`
|
|
55
|
+
- `tn_venv` (alias)
|
|
56
|
+
|
|
57
|
+
You can also invoke the CLI without installing anything:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
python -m tn_venv .venv
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Quick start
|
|
66
|
+
```bash
|
|
67
|
+
tn-venv --list-pythons
|
|
68
|
+
|
|
69
|
+
# Print the resolved configuration without creating anything
|
|
70
|
+
tn-venv --dry-run
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## CLI reference
|
|
76
|
+
|
|
77
|
+
### Interpreter selection
|
|
78
|
+
|
|
79
|
+
| Flag | Description |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `-p SPEC` / `--python SPEC` | Python to build from — a path, a version (`3`, `3.12`, `3.12.1`), a name (`python3.12`, `pypy3.10`) or a PEP 514-ish tag. Repeatable; first match wins. Default: the interpreter running `tn-venv`. |
|
|
82
|
+
| `--list-pythons` | List every discoverable interpreter and exit. |
|
|
83
|
+
|
|
84
|
+
### Creator options
|
|
85
|
+
|
|
86
|
+
| Flag | Description |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `--clear` | Delete the destination directory before creating. |
|
|
89
|
+
| `--upgrade` | Upgrade an existing environment in place (keep installed packages). |
|
|
90
|
+
| `--system-site-packages` | Give the environment access to the system site-packages. |
|
|
91
|
+
| `--symlinks` / `--no-symlinks` | Symlink the interpreter binaries (default on POSIX). |
|
|
92
|
+
| `--copies` / `--no-copies` | Copy the interpreter binaries (default on Windows). |
|
|
93
|
+
| `--scm-ignore {git,none}` | Write a source-control ignore file (default: `git`). |
|
|
94
|
+
|
|
95
|
+
### Seeder options
|
|
96
|
+
|
|
97
|
+
| Flag | Description |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `--seeder {pip,none}` | Package installer to seed the environment with (default: `pip`). |
|
|
100
|
+
| `--no-pip` / `--without-pip` | Skip pip installation. |
|
|
101
|
+
| `--pip [VERSION]` | Pip version to install. Omit value for the latest release (`--pip` ≡ `--pip latest`), pass a version to pin (`--pip 24.0`). |
|
|
102
|
+
| `--upgrade-pip` | Upgrade pip to the latest release from the package index. |
|
|
103
|
+
| `--setuptools [VERSION]` | Install setuptools (optionally pinned). Not bundled on Python ≥ 3.12. |
|
|
104
|
+
| `--wheel [VERSION]` | Install wheel (optionally pinned). |
|
|
105
|
+
| `--extra-search-dir DIR` | Additional directory to search for wheels/sdists (`PIP_FIND_LINKS`). Repeatable. |
|
|
106
|
+
| `--offline` | Don't reach the network; use only bundled wheels and `--extra-search-dir` (`PIP_NO_INDEX`). |
|
|
107
|
+
| `--with PKG` / `--seed-package PKG` | Install extra packages after seeding. Repeatable. |
|
|
108
|
+
| `-r FILE` / `--requirements FILE` | Install from a requirements file. Repeatable. |
|
|
109
|
+
|
|
110
|
+
### Activation options
|
|
111
|
+
|
|
112
|
+
| Flag | Description |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `--activators NAMES` | Comma-separated activation scripts to generate. Names: `bash`, `batch`, `powershell`, `fish`, `csh`, `nushell`, `python`, plus `all` and `default`. Prefix with `-` to exclude (e.g. `-fish`). |
|
|
115
|
+
| `--prompt NAME` | Custom prompt shown when the environment is active (default: the environment folder name). |
|
|
116
|
+
|
|
117
|
+
### Miscellaneous
|
|
118
|
+
|
|
119
|
+
| Flag | Description |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `-q` / `--quiet` | Reduce verbosity (repeatable). |
|
|
122
|
+
| `-v` / `--verbose` | Increase verbosity (repeatable). |
|
|
123
|
+
| `--color` / `--no-color` | Force colored output on or off. Honors `NO_COLOR` and `FORCE_COLOR`. |
|
|
124
|
+
| `--dry-run` | Print the resolved configuration without creating anything. |
|
|
125
|
+
| `--config FILE` | Explicit path to a config file (overrides discovery). |
|
|
126
|
+
| `--no-config` | Ignore config files and environment variables. |
|
|
127
|
+
| `--version` | Print `tn-venv` version and exit. |
|
|
128
|
+
| `-h` / `--help` | Show help and exit. |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# One command: create ./.venv with pip and the current interpreter
|
|
134
|
+
tn-venv
|
|
135
|
+
|
|
136
|
+
# Pick a destination and a specific interpreter version
|
|
137
|
+
tn-venv .venv -p 3.12
|
|
138
|
+
|
|
139
|
+
# Let the environment see globally-installed packages
|
|
140
|
+
tn-venv /tmp/x --system-site-packages
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Configuration
|
|
144
|
+
|
|
145
|
+
Configuration precedence (highest first):
|
|
146
|
+
|
|
147
|
+
1. **CLI flags** — e.g. `tn-venv --clear`
|
|
148
|
+
2. **`TN_VENV_*` environment variables** — e.g. `TN_VENV_CLEAR=1`
|
|
149
|
+
3. **Config file** — discovered automatically, or via `--config FILE` / `TN_VENV_CONFIG_FILE`
|
|
150
|
+
4. **Built-in defaults**
|
|
151
|
+
|
|
152
|
+
### Config file discovery
|
|
153
|
+
|
|
154
|
+
`tn-venv` walks the current directory and its parents (stopping at `.git`) looking for the first match:
|
|
155
|
+
|
|
156
|
+
1. `pyproject.toml` — only counts when it contains a `[tool.tn-venv]` or `[tool.tn_venv]` section
|
|
157
|
+
2. `tn-venv.ini`
|
|
158
|
+
3. `tn_venv.ini`
|
|
159
|
+
4. `.tn-venv.toml` — top-level keys
|
|
160
|
+
5. `setup.cfg` — only when it has a `[tn_venv]` section
|
|
161
|
+
|
|
162
|
+
### `pyproject.toml`
|
|
163
|
+
|
|
164
|
+
```toml
|
|
165
|
+
[tool.tn-venv]
|
|
166
|
+
python = ["3.12"]
|
|
167
|
+
prompt = "my-project"
|
|
168
|
+
system-site-packages = false
|
|
169
|
+
activators = "powershell,batch,-nushell"
|
|
170
|
+
with = ["requests", "click"]
|
|
171
|
+
upgrade-pip = true
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### `tn-venv.ini`
|
|
175
|
+
|
|
176
|
+
```ini
|
|
177
|
+
[tn-venv]
|
|
178
|
+
python = 3.12, 3.13
|
|
179
|
+
prompt = my-project
|
|
180
|
+
clear = yes
|
|
181
|
+
extra-search-dir = /srv/wheels
|
|
182
|
+
requirements = dev-requirements.txt
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Environment variables
|
|
186
|
+
|
|
187
|
+
Every option has a `TN_VENV_<NAME>` env var (uppercased destination):
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
export TN_VENV_PYTHON=3.12
|
|
191
|
+
export TN_VENV_PROMPT=my-project
|
|
192
|
+
export TN_VENV_CLEAR=1
|
|
193
|
+
export TN_VENV_NO_PIP=0
|
|
194
|
+
export TN_VENV_ACTIVATORS=powershell,batch
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Python API
|
|
198
|
+
|
|
199
|
+
Use `tn_venv.create_venv` programmatically:
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
from tn_venv import create_venv
|
|
203
|
+
|
|
204
|
+
result = create_venv(
|
|
205
|
+
".venv",
|
|
206
|
+
python="3.12",
|
|
207
|
+
with_pip=True,
|
|
208
|
+
pip="24.0",
|
|
209
|
+
setuptools=True,
|
|
210
|
+
wheel=True,
|
|
211
|
+
packages=["requests", "click"],
|
|
212
|
+
requirements=["dev-requirements.txt"],
|
|
213
|
+
activators=["bash", "powershell"],
|
|
214
|
+
prompt="my-project",
|
|
215
|
+
quiet=True,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
print(result.env_dir) # PosixPath('.venv')
|
|
219
|
+
print(result.exe) # PosixPath('.venv/bin/python')
|
|
220
|
+
print(result.bin_path) # PosixPath('.venv/bin')
|
|
221
|
+
print(result.site_packages) # PosixPath('.venv/lib/python3.12/site-packages')
|
|
222
|
+
print(result.prompt) # 'my-project'
|
|
223
|
+
print(result.activation_scripts)
|
|
224
|
+
print(result.seed.pip) # '24.0'
|
|
225
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tn-venv"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Create Python virtual environments with one command — a batteries-included virtualenv alternative"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { file = "License.txt" }
|
|
12
|
+
authors = [{ name = "Tokenoodle-Everything Organization" }]
|
|
13
|
+
keywords = ["virtualenv", "venv", "environment", "isolation", "packaging"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
"Topic :: System :: Systems Administration",
|
|
26
|
+
"Topic :: Utilities",
|
|
27
|
+
]
|
|
28
|
+
dependencies = []
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/tokenoodle-everything/tn-venv"
|
|
32
|
+
Documentation = "https://github.com/tokenoodle-everything/tn-venv#readme"
|
|
33
|
+
Source = "https://github.com/tokenoodle-everything/tn-venv"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
tn-venv = "tn_venv.cli:main"
|
|
37
|
+
tn_venv = "tn_venv.cli:main"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["."]
|
|
41
|
+
exclude = ["tests*"]
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.package-data]
|
|
44
|
+
tn_venv = ["py.typed"]
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
testpaths = ["tests"]
|
|
48
|
+
addopts = "-ra"
|
|
49
|
+
|
|
50
|
+
# tn-venv reads this very section for its own defaults when you run it here:
|
|
51
|
+
[tool.tn-venv]
|
|
52
|
+
# prompt = "my-project"
|
|
53
|
+
# python = ["3.12"]
|
tn_venv-0.1.0/setup.cfg
ADDED