pystand 2.26__tar.gz → 2.27__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pystand
3
- Version: 2.26
3
+ Version: 2.27
4
4
  Summary: Install Python versions from python-build-standalone project
5
5
  Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
6
6
  License-Expression: GPL-3.0-or-later
@@ -35,6 +35,9 @@ provided:
35
35
  |`list`|List installed versions and show which have an update available.|
36
36
  |`show`|Show versions available from a release.|
37
37
  |`path`|Show path prefix to installed version base directory.|
38
+ |`cache`|Show size of release download caches.|
39
+ |`uv`|Run a uv command using a version of python installed by pystand.|
40
+ |`uvx`|Run a program using uvx and a version of python installed by pystand.|
38
41
 
39
42
  By default, Python versions are sourced from the latest
40
43
  `python-build-standalone` [release][pbs-rel] available (e.g.
@@ -102,11 +105,11 @@ Version 3.12.3 is already installed.
102
105
  Here are some examples showing how to use an installed version ..
103
106
 
104
107
  ```sh
105
- # Use uv to create a virtual environment to be run with latest pystand
108
+ # Use uv to create a virtual environment to be run with pystand
106
109
  # installed python 3.12:
107
110
  $ uv venv -p $(pystand path 3.12) myenv
108
111
 
109
- # Create a regular virtual environment to be run with latest pystand
112
+ # Create a regular virtual environment to be run with pystand
110
113
  # installed python 3.12:
111
114
  $ $(pystand path -p 3.12) -m venv myenv
112
115
 
@@ -142,7 +145,7 @@ usage: pystand [-h] [-D DISTRIBUTION] [-P PREFIX_DIR] [-C CACHE_DIR]
142
145
  [-M CACHE_MINUTES] [--purge-days PURGE_DAYS]
143
146
  [--github-access-token GITHUB_ACCESS_TOKEN] [--no-strip]
144
147
  [--no-color] [--cert {system,certifi,none}] [-V]
145
- {install,update,upgrade,remove,uninstall,list,show,path,cache} ...
148
+ {install,update,upgrade,remove,uninstall,list,show,path,cache,uv,uvx} ...
146
149
 
147
150
  Command line tool to download, install, and update pre-built Python versions
148
151
  from the python-build-standalone project at https://github.com/astral-
@@ -182,7 +185,7 @@ options:
182
185
  -V, --version just show pystand version
183
186
 
184
187
  Commands:
185
- {install,update,upgrade,remove,uninstall,list,show,path,cache}
188
+ {install,update,upgrade,remove,uninstall,list,show,path,cache,uv,uvx}
186
189
  install Install one, more, or all versions from a python-
187
190
  build-standalone release.
188
191
  update (upgrade) Update one, more, or all versions to another release.
@@ -192,6 +195,10 @@ Commands:
192
195
  show Show versions available from a release.
193
196
  path Show path prefix to installed version base directory.
194
197
  cache Show size of release download caches.
198
+ uv Run a uv command using a version of python installed
199
+ by pystand.
200
+ uvx Run a program using uvx and a version of python
201
+ installed by pystand.
195
202
 
196
203
  Some commands offer aliases as shown in parentheses above. Note you can set
197
204
  default starting global options in ~/.config/pystand-flags.conf.
@@ -353,6 +360,44 @@ options:
353
360
  instead of showing size
354
361
  ```
355
362
 
363
+ ### Command `uv`
364
+
365
+ ```
366
+ usage: pystand uv [-h] [-p PYTHON]
367
+ command [subcommand] [uv_args_for_command ...]
368
+
369
+ Run a uv command using a version of python installed by pystand.
370
+
371
+ positional arguments:
372
+ command uv command to run
373
+ subcommand optional uv sub-command
374
+ uv_args_for_command optional extra arguments to pass to uv command [sub-
375
+ command], start any options with "-- "
376
+
377
+ options:
378
+ -h, --help show this help message and exit
379
+ -p, --python PYTHON version of python to use, e.g. "3.12", default is
380
+ latest release version
381
+ ```
382
+
383
+ ### Command `uvx`
384
+
385
+ ```
386
+ usage: pystand uvx [-h] [-p PYTHON] program [uvx_args_for_program ...]
387
+
388
+ Run a program using uvx and a version of python installed by pystand.
389
+
390
+ positional arguments:
391
+ program uvx program to run
392
+ uvx_args_for_program optional extra arguments to pass to uvx program, start
393
+ any options with "-- "
394
+
395
+ options:
396
+ -h, --help show this help message and exit
397
+ -p, --python PYTHON version of python to use, e.g. "3.12", default is
398
+ latest release version
399
+ ```
400
+
356
401
  ## Installation and Upgrade
357
402
 
358
403
  Python 3.8 or later is required. Arch Linux users can install [`pystand`
@@ -623,13 +668,61 @@ The available options are:
623
668
  Specify the option on the command line with `--cert`, or set that as a [default
624
669
  option](#command-default-options).
625
670
 
671
+ ## Direct Usage with UV Tool
672
+
673
+ Many [`uv`][uv] commands accept a `-p/--python` option to specify a Python
674
+ version or path. To use a `pystand` installed Python version, instead of the
675
+ `uv` maintained or system python, you can use one of the following approaches:
676
+
677
+ E.g. To create a `uv venv` using `pystand` installed 3.12, just hard code the
678
+ path directly, e.g. for a Linux platform:
679
+
680
+ ```sh
681
+ uv venv -p ~/.local/share/pystand/3.12
682
+ ```
683
+
684
+ Or, specify the path using pystand itself:
685
+
686
+ ```sh
687
+ uv venv -p $(pystand path 3.12)
688
+ ```
689
+
690
+ Or, use the `pystand uv` wrapper command:
691
+
692
+ ```sh
693
+ pystand uv venv -p 3.12
694
+ ```
695
+
696
+ For the common case where you simply want to use the latest `pystand` Python
697
+ release you can omit the `-p` option (and `pystand` will specify it to `uv`
698
+ under the hood): :
699
+
700
+ ```sh
701
+ pystand uv venv
702
+ ```
703
+
704
+ Note if you use the `pystand uv` wrapper, and want to specify switches to the
705
+ `uv` command, you must use `--` to separate `uv` arguments from `pystand uv`
706
+ arguments. E.g.:
707
+
708
+ ```sh
709
+ pystand uv tool install -p 3.12 cowsay -- --verbose
710
+ ```
711
+
712
+ `pystand` also provides a similar wrapper command `pystand uvx` for [`uvx`][uvx]
713
+ commands.
714
+
715
+ An example where this functionality may be handy is to conveniently test
716
+ various tools against free-threaded or other Python builds from Python Build
717
+ Standalone releases.
718
+
626
719
  ## Command Line Tab Completion
627
720
 
628
721
  Command line shell [tab
629
722
  completion](https://en.wikipedia.org/wiki/Command-line_completion) is
630
723
  automatically enabled on `pystand` commands and options using
631
- [`argcomplete`](https://github.com/kislyuk/argcomplete). You may need to
632
- first (once-only) [activate argcomplete global
724
+ [`argcomplete`](https://github.com/kislyuk/argcomplete). You may need to first
725
+ (once-only) [activate argcomplete global
633
726
  completion](https://github.com/kislyuk/argcomplete#global-completion).
634
727
 
635
728
  ## License
@@ -649,6 +742,8 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
649
742
  [pbs-rel]: https://github.com/astral-sh/python-build-standalone/releases
650
743
  [pipx]: https://github.com/pypa/pipx
651
744
  [pipxu]: https://github.com/bulletmark/pipxu
745
+ [uv]: https://docs.astral.sh/uv
746
+ [uvx]: https://docs.astral.sh/uv/guides/tools/#running-tools
652
747
  [uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
653
748
  [pyenv]: https://github.com/pyenv/pyenv
654
749
  [pdm]: https://pdm-project.org/
@@ -15,6 +15,9 @@ provided:
15
15
  |`list`|List installed versions and show which have an update available.|
16
16
  |`show`|Show versions available from a release.|
17
17
  |`path`|Show path prefix to installed version base directory.|
18
+ |`cache`|Show size of release download caches.|
19
+ |`uv`|Run a uv command using a version of python installed by pystand.|
20
+ |`uvx`|Run a program using uvx and a version of python installed by pystand.|
18
21
 
19
22
  By default, Python versions are sourced from the latest
20
23
  `python-build-standalone` [release][pbs-rel] available (e.g.
@@ -82,11 +85,11 @@ Version 3.12.3 is already installed.
82
85
  Here are some examples showing how to use an installed version ..
83
86
 
84
87
  ```sh
85
- # Use uv to create a virtual environment to be run with latest pystand
88
+ # Use uv to create a virtual environment to be run with pystand
86
89
  # installed python 3.12:
87
90
  $ uv venv -p $(pystand path 3.12) myenv
88
91
 
89
- # Create a regular virtual environment to be run with latest pystand
92
+ # Create a regular virtual environment to be run with pystand
90
93
  # installed python 3.12:
91
94
  $ $(pystand path -p 3.12) -m venv myenv
92
95
 
@@ -122,7 +125,7 @@ usage: pystand [-h] [-D DISTRIBUTION] [-P PREFIX_DIR] [-C CACHE_DIR]
122
125
  [-M CACHE_MINUTES] [--purge-days PURGE_DAYS]
123
126
  [--github-access-token GITHUB_ACCESS_TOKEN] [--no-strip]
124
127
  [--no-color] [--cert {system,certifi,none}] [-V]
125
- {install,update,upgrade,remove,uninstall,list,show,path,cache} ...
128
+ {install,update,upgrade,remove,uninstall,list,show,path,cache,uv,uvx} ...
126
129
 
127
130
  Command line tool to download, install, and update pre-built Python versions
128
131
  from the python-build-standalone project at https://github.com/astral-
@@ -162,7 +165,7 @@ options:
162
165
  -V, --version just show pystand version
163
166
 
164
167
  Commands:
165
- {install,update,upgrade,remove,uninstall,list,show,path,cache}
168
+ {install,update,upgrade,remove,uninstall,list,show,path,cache,uv,uvx}
166
169
  install Install one, more, or all versions from a python-
167
170
  build-standalone release.
168
171
  update (upgrade) Update one, more, or all versions to another release.
@@ -172,6 +175,10 @@ Commands:
172
175
  show Show versions available from a release.
173
176
  path Show path prefix to installed version base directory.
174
177
  cache Show size of release download caches.
178
+ uv Run a uv command using a version of python installed
179
+ by pystand.
180
+ uvx Run a program using uvx and a version of python
181
+ installed by pystand.
175
182
 
176
183
  Some commands offer aliases as shown in parentheses above. Note you can set
177
184
  default starting global options in ~/.config/pystand-flags.conf.
@@ -333,6 +340,44 @@ options:
333
340
  instead of showing size
334
341
  ```
335
342
 
343
+ ### Command `uv`
344
+
345
+ ```
346
+ usage: pystand uv [-h] [-p PYTHON]
347
+ command [subcommand] [uv_args_for_command ...]
348
+
349
+ Run a uv command using a version of python installed by pystand.
350
+
351
+ positional arguments:
352
+ command uv command to run
353
+ subcommand optional uv sub-command
354
+ uv_args_for_command optional extra arguments to pass to uv command [sub-
355
+ command], start any options with "-- "
356
+
357
+ options:
358
+ -h, --help show this help message and exit
359
+ -p, --python PYTHON version of python to use, e.g. "3.12", default is
360
+ latest release version
361
+ ```
362
+
363
+ ### Command `uvx`
364
+
365
+ ```
366
+ usage: pystand uvx [-h] [-p PYTHON] program [uvx_args_for_program ...]
367
+
368
+ Run a program using uvx and a version of python installed by pystand.
369
+
370
+ positional arguments:
371
+ program uvx program to run
372
+ uvx_args_for_program optional extra arguments to pass to uvx program, start
373
+ any options with "-- "
374
+
375
+ options:
376
+ -h, --help show this help message and exit
377
+ -p, --python PYTHON version of python to use, e.g. "3.12", default is
378
+ latest release version
379
+ ```
380
+
336
381
  ## Installation and Upgrade
337
382
 
338
383
  Python 3.8 or later is required. Arch Linux users can install [`pystand`
@@ -603,13 +648,61 @@ The available options are:
603
648
  Specify the option on the command line with `--cert`, or set that as a [default
604
649
  option](#command-default-options).
605
650
 
651
+ ## Direct Usage with UV Tool
652
+
653
+ Many [`uv`][uv] commands accept a `-p/--python` option to specify a Python
654
+ version or path. To use a `pystand` installed Python version, instead of the
655
+ `uv` maintained or system python, you can use one of the following approaches:
656
+
657
+ E.g. To create a `uv venv` using `pystand` installed 3.12, just hard code the
658
+ path directly, e.g. for a Linux platform:
659
+
660
+ ```sh
661
+ uv venv -p ~/.local/share/pystand/3.12
662
+ ```
663
+
664
+ Or, specify the path using pystand itself:
665
+
666
+ ```sh
667
+ uv venv -p $(pystand path 3.12)
668
+ ```
669
+
670
+ Or, use the `pystand uv` wrapper command:
671
+
672
+ ```sh
673
+ pystand uv venv -p 3.12
674
+ ```
675
+
676
+ For the common case where you simply want to use the latest `pystand` Python
677
+ release you can omit the `-p` option (and `pystand` will specify it to `uv`
678
+ under the hood): :
679
+
680
+ ```sh
681
+ pystand uv venv
682
+ ```
683
+
684
+ Note if you use the `pystand uv` wrapper, and want to specify switches to the
685
+ `uv` command, you must use `--` to separate `uv` arguments from `pystand uv`
686
+ arguments. E.g.:
687
+
688
+ ```sh
689
+ pystand uv tool install -p 3.12 cowsay -- --verbose
690
+ ```
691
+
692
+ `pystand` also provides a similar wrapper command `pystand uvx` for [`uvx`][uvx]
693
+ commands.
694
+
695
+ An example where this functionality may be handy is to conveniently test
696
+ various tools against free-threaded or other Python builds from Python Build
697
+ Standalone releases.
698
+
606
699
  ## Command Line Tab Completion
607
700
 
608
701
  Command line shell [tab
609
702
  completion](https://en.wikipedia.org/wiki/Command-line_completion) is
610
703
  automatically enabled on `pystand` commands and options using
611
- [`argcomplete`](https://github.com/kislyuk/argcomplete). You may need to
612
- first (once-only) [activate argcomplete global
704
+ [`argcomplete`](https://github.com/kislyuk/argcomplete). You may need to first
705
+ (once-only) [activate argcomplete global
613
706
  completion](https://github.com/kislyuk/argcomplete#global-completion).
614
707
 
615
708
  ## License
@@ -629,6 +722,8 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
629
722
  [pbs-rel]: https://github.com/astral-sh/python-build-standalone/releases
630
723
  [pipx]: https://github.com/pypa/pipx
631
724
  [pipxu]: https://github.com/bulletmark/pipxu
725
+ [uv]: https://docs.astral.sh/uv
726
+ [uvx]: https://docs.astral.sh/uv/guides/tools/#running-tools
632
727
  [uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
633
728
  [pyenv]: https://github.com/pyenv/pyenv
634
729
  [pdm]: https://pdm-project.org/
@@ -1,4 +1,4 @@
1
- PYFILES := file_name(justfile_dir()) + '.py'
1
+ PYFILES := file_name(justfile_directory()) + '.py'
2
2
 
3
3
  check:
4
4
  ruff check {{PYFILES}}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pystand
3
- Version: 2.26
3
+ Version: 2.27
4
4
  Summary: Install Python versions from python-build-standalone project
5
5
  Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
6
6
  License-Expression: GPL-3.0-or-later
@@ -35,6 +35,9 @@ provided:
35
35
  |`list`|List installed versions and show which have an update available.|
36
36
  |`show`|Show versions available from a release.|
37
37
  |`path`|Show path prefix to installed version base directory.|
38
+ |`cache`|Show size of release download caches.|
39
+ |`uv`|Run a uv command using a version of python installed by pystand.|
40
+ |`uvx`|Run a program using uvx and a version of python installed by pystand.|
38
41
 
39
42
  By default, Python versions are sourced from the latest
40
43
  `python-build-standalone` [release][pbs-rel] available (e.g.
@@ -102,11 +105,11 @@ Version 3.12.3 is already installed.
102
105
  Here are some examples showing how to use an installed version ..
103
106
 
104
107
  ```sh
105
- # Use uv to create a virtual environment to be run with latest pystand
108
+ # Use uv to create a virtual environment to be run with pystand
106
109
  # installed python 3.12:
107
110
  $ uv venv -p $(pystand path 3.12) myenv
108
111
 
109
- # Create a regular virtual environment to be run with latest pystand
112
+ # Create a regular virtual environment to be run with pystand
110
113
  # installed python 3.12:
111
114
  $ $(pystand path -p 3.12) -m venv myenv
112
115
 
@@ -142,7 +145,7 @@ usage: pystand [-h] [-D DISTRIBUTION] [-P PREFIX_DIR] [-C CACHE_DIR]
142
145
  [-M CACHE_MINUTES] [--purge-days PURGE_DAYS]
143
146
  [--github-access-token GITHUB_ACCESS_TOKEN] [--no-strip]
144
147
  [--no-color] [--cert {system,certifi,none}] [-V]
145
- {install,update,upgrade,remove,uninstall,list,show,path,cache} ...
148
+ {install,update,upgrade,remove,uninstall,list,show,path,cache,uv,uvx} ...
146
149
 
147
150
  Command line tool to download, install, and update pre-built Python versions
148
151
  from the python-build-standalone project at https://github.com/astral-
@@ -182,7 +185,7 @@ options:
182
185
  -V, --version just show pystand version
183
186
 
184
187
  Commands:
185
- {install,update,upgrade,remove,uninstall,list,show,path,cache}
188
+ {install,update,upgrade,remove,uninstall,list,show,path,cache,uv,uvx}
186
189
  install Install one, more, or all versions from a python-
187
190
  build-standalone release.
188
191
  update (upgrade) Update one, more, or all versions to another release.
@@ -192,6 +195,10 @@ Commands:
192
195
  show Show versions available from a release.
193
196
  path Show path prefix to installed version base directory.
194
197
  cache Show size of release download caches.
198
+ uv Run a uv command using a version of python installed
199
+ by pystand.
200
+ uvx Run a program using uvx and a version of python
201
+ installed by pystand.
195
202
 
196
203
  Some commands offer aliases as shown in parentheses above. Note you can set
197
204
  default starting global options in ~/.config/pystand-flags.conf.
@@ -353,6 +360,44 @@ options:
353
360
  instead of showing size
354
361
  ```
355
362
 
363
+ ### Command `uv`
364
+
365
+ ```
366
+ usage: pystand uv [-h] [-p PYTHON]
367
+ command [subcommand] [uv_args_for_command ...]
368
+
369
+ Run a uv command using a version of python installed by pystand.
370
+
371
+ positional arguments:
372
+ command uv command to run
373
+ subcommand optional uv sub-command
374
+ uv_args_for_command optional extra arguments to pass to uv command [sub-
375
+ command], start any options with "-- "
376
+
377
+ options:
378
+ -h, --help show this help message and exit
379
+ -p, --python PYTHON version of python to use, e.g. "3.12", default is
380
+ latest release version
381
+ ```
382
+
383
+ ### Command `uvx`
384
+
385
+ ```
386
+ usage: pystand uvx [-h] [-p PYTHON] program [uvx_args_for_program ...]
387
+
388
+ Run a program using uvx and a version of python installed by pystand.
389
+
390
+ positional arguments:
391
+ program uvx program to run
392
+ uvx_args_for_program optional extra arguments to pass to uvx program, start
393
+ any options with "-- "
394
+
395
+ options:
396
+ -h, --help show this help message and exit
397
+ -p, --python PYTHON version of python to use, e.g. "3.12", default is
398
+ latest release version
399
+ ```
400
+
356
401
  ## Installation and Upgrade
357
402
 
358
403
  Python 3.8 or later is required. Arch Linux users can install [`pystand`
@@ -623,13 +668,61 @@ The available options are:
623
668
  Specify the option on the command line with `--cert`, or set that as a [default
624
669
  option](#command-default-options).
625
670
 
671
+ ## Direct Usage with UV Tool
672
+
673
+ Many [`uv`][uv] commands accept a `-p/--python` option to specify a Python
674
+ version or path. To use a `pystand` installed Python version, instead of the
675
+ `uv` maintained or system python, you can use one of the following approaches:
676
+
677
+ E.g. To create a `uv venv` using `pystand` installed 3.12, just hard code the
678
+ path directly, e.g. for a Linux platform:
679
+
680
+ ```sh
681
+ uv venv -p ~/.local/share/pystand/3.12
682
+ ```
683
+
684
+ Or, specify the path using pystand itself:
685
+
686
+ ```sh
687
+ uv venv -p $(pystand path 3.12)
688
+ ```
689
+
690
+ Or, use the `pystand uv` wrapper command:
691
+
692
+ ```sh
693
+ pystand uv venv -p 3.12
694
+ ```
695
+
696
+ For the common case where you simply want to use the latest `pystand` Python
697
+ release you can omit the `-p` option (and `pystand` will specify it to `uv`
698
+ under the hood): :
699
+
700
+ ```sh
701
+ pystand uv venv
702
+ ```
703
+
704
+ Note if you use the `pystand uv` wrapper, and want to specify switches to the
705
+ `uv` command, you must use `--` to separate `uv` arguments from `pystand uv`
706
+ arguments. E.g.:
707
+
708
+ ```sh
709
+ pystand uv tool install -p 3.12 cowsay -- --verbose
710
+ ```
711
+
712
+ `pystand` also provides a similar wrapper command `pystand uvx` for [`uvx`][uvx]
713
+ commands.
714
+
715
+ An example where this functionality may be handy is to conveniently test
716
+ various tools against free-threaded or other Python builds from Python Build
717
+ Standalone releases.
718
+
626
719
  ## Command Line Tab Completion
627
720
 
628
721
  Command line shell [tab
629
722
  completion](https://en.wikipedia.org/wiki/Command-line_completion) is
630
723
  automatically enabled on `pystand` commands and options using
631
- [`argcomplete`](https://github.com/kislyuk/argcomplete). You may need to
632
- first (once-only) [activate argcomplete global
724
+ [`argcomplete`](https://github.com/kislyuk/argcomplete). You may need to first
725
+ (once-only) [activate argcomplete global
633
726
  completion](https://github.com/kislyuk/argcomplete#global-completion).
634
727
 
635
728
  ## License
@@ -649,6 +742,8 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
649
742
  [pbs-rel]: https://github.com/astral-sh/python-build-standalone/releases
650
743
  [pipx]: https://github.com/pypa/pipx
651
744
  [pipxu]: https://github.com/bulletmark/pipxu
745
+ [uv]: https://docs.astral.sh/uv
746
+ [uvx]: https://docs.astral.sh/uv/guides/tools/#running-tools
652
747
  [uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
653
748
  [pyenv]: https://github.com/pyenv/pyenv
654
749
  [pdm]: https://pdm-project.org/
@@ -14,6 +14,7 @@ import platform
14
14
  import re
15
15
  import shutil
16
16
  import ssl
17
+ import subprocess
17
18
  import sys
18
19
  import time
19
20
  from collections import defaultdict
@@ -136,6 +137,12 @@ def get_version() -> str:
136
137
  return ver
137
138
 
138
139
 
140
+ def get_major_version(args: Namespace) -> str | None:
141
+ '"Return the latest major version installed"'
142
+ vers = sorted(f.name for f in args._versions.glob('[3-9]'))
143
+ return vers[-1] if vers else None
144
+
145
+
139
146
  def get_json(file: Path) -> dict[str, Any]:
140
147
  from json import load
141
148
 
@@ -631,7 +638,6 @@ def remove(args: Namespace, version: str) -> None:
631
638
 
632
639
  def strip_binaries(vdir: Path, distribution: str) -> bool:
633
640
  "Strip binaries from files in a version directory"
634
- from subprocess import DEVNULL, run
635
641
 
636
642
  # Only run the strip command on Linux hosts and for Linux distributions
637
643
  was_stripped = False
@@ -645,7 +651,7 @@ def strip_binaries(vdir: Path, distribution: str) -> bool:
645
651
  if not file.is_symlink() and file.is_file():
646
652
  cmd = f'strip -p --strip-unneeded {file}'.split()
647
653
  try:
648
- run(cmd, stderr=DEVNULL)
654
+ subprocess.run(cmd, stderr=subprocess.DEVNULL)
649
655
  except Exception:
650
656
  pass
651
657
  else:
@@ -734,6 +740,23 @@ def create_cert(option: str) -> ssl.SSLContext | None:
734
740
  return ssl._create_unverified_context()
735
741
 
736
742
 
743
+ def run_uv(args: Namespace, cmd: list[str], cmdopts: list[str]) -> str | None:
744
+ "Run a uv command with the specified or latest installed python version"
745
+ if not (vers := (args.python or get_major_version(args))):
746
+ return 'No installed python version found.'
747
+
748
+ py = args._versions / vers
749
+ if not py.is_dir():
750
+ return f'No installed python {py.name} version found.'
751
+
752
+ # Resolve to at least minor version if only major version specified
753
+ if '.' not in py.name:
754
+ py = py.resolve()
755
+ py = py.with_name(py.stem)
756
+
757
+ subprocess.run(cmd + ['-p', py] + cmdopts)
758
+
759
+
737
760
  def main() -> str | None:
738
761
  "Main code"
739
762
  distro_default = DISTRIBUTIONS.get((platform.system(), platform.machine()))
@@ -1395,5 +1418,59 @@ class cache_:
1395
1418
  show_cache_size(args._downloads, args)
1396
1419
 
1397
1420
 
1421
+ # COMMAND
1422
+ class uv_:
1423
+ __doc__ = f'Run a uv command using a version of python installed by {PROG}.'
1424
+
1425
+ @staticmethod
1426
+ def init(parser: ArgumentParser) -> None:
1427
+ parser.add_argument(
1428
+ '-p',
1429
+ '--python',
1430
+ help='version of python to use, e.g. "3.12", default is latest release version',
1431
+ )
1432
+
1433
+ parser.add_argument('command', help='uv command to run')
1434
+ parser.add_argument('subcommand', nargs='?', help='optional uv sub-command')
1435
+
1436
+ parser.add_argument(
1437
+ 'uv_args_for_command',
1438
+ nargs='*',
1439
+ help='optional extra arguments to pass to uv command [sub-command], start any options with "-- "',
1440
+ )
1441
+
1442
+ @staticmethod
1443
+ def run(args: Namespace) -> str | None:
1444
+ cmd = ['uv', args.command]
1445
+ if args.subcommand:
1446
+ cmd.append(args.subcommand)
1447
+
1448
+ return run_uv(args, cmd, args.uv_args_for_command)
1449
+
1450
+
1451
+ # COMMAND
1452
+ class uvx_:
1453
+ __doc__ = f'Run a program using uvx and a version of python installed by {PROG}.'
1454
+
1455
+ @staticmethod
1456
+ def init(parser: ArgumentParser) -> None:
1457
+ parser.add_argument(
1458
+ '-p',
1459
+ '--python',
1460
+ help='version of python to use, e.g. "3.12", default is latest release version',
1461
+ )
1462
+
1463
+ parser.add_argument('program', help='uvx program to run')
1464
+ parser.add_argument(
1465
+ 'uvx_args_for_program',
1466
+ nargs='*',
1467
+ help='optional extra arguments to pass to uvx program, start any options with "-- "',
1468
+ )
1469
+
1470
+ @staticmethod
1471
+ def run(args: Namespace) -> str | None:
1472
+ return run_uv(args, ['uvx'], [args.program] + args.uvx_args_for_program)
1473
+
1474
+
1398
1475
  if __name__ == '__main__':
1399
1476
  sys.exit(main())
File without changes
File without changes
File without changes