pystand 2.15__py3-none-any.whl → 2.16__py3-none-any.whl

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.15
3
+ Version: 2.16
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
@@ -41,7 +41,7 @@ required
41
41
  for your machine architecture is normally auto-detected. By default, the
42
42
  _`install_only_stripped`_ build of the distribution is installed but you
43
43
  can choose to [install any other
44
- build/distribution](#installing-other-builds/distributions) instead, or
44
+ build/distribution](#installing-other-buildsdistributions) instead, or
45
45
  in parallel.
46
46
 
47
47
  Some simple usage examples are:
@@ -131,7 +131,7 @@ usage: pystand [-h] [-D DISTRIBUTION] [-P PREFIX_DIR] [-C CACHE_DIR]
131
131
  [-M CACHE_MINUTES] [--purge-days PURGE_DAYS]
132
132
  [--github-access-token GITHUB_ACCESS_TOKEN] [--no-strip]
133
133
  [-V]
134
- {install,update,upgrade,remove,uninstall,list,show,path} ...
134
+ {install,update,upgrade,remove,uninstall,list,show,path,cache} ...
135
135
 
136
136
  Command line tool to download, install, and update pre-built Python versions
137
137
  from the python-build-standalone project at https://github.com/astral-
@@ -141,8 +141,9 @@ options:
141
141
  -h, --help show this help message and exit
142
142
  -D, --distribution DISTRIBUTION
143
143
  python-build-standalone distribution. Default is
144
- "x86_64_v3-unknown-linux-gnu-install_only_stripped for
145
- this host
144
+ "x86_64_v3-unknown-linux-gnu-install_only_stripped"
145
+ for this host. Run "pystand show -a" to see all
146
+ distributions.
146
147
  -P, --prefix-dir PREFIX_DIR
147
148
  specify prefix dir for storing versions. Default is
148
149
  "$HOME/.local/share/pystand"
@@ -164,7 +165,7 @@ options:
164
165
  -V, --version just show pystand version
165
166
 
166
167
  Commands:
167
- {install,update,upgrade,remove,uninstall,list,show,path}
168
+ {install,update,upgrade,remove,uninstall,list,show,path,cache}
168
169
  install Install one or more versions from a python-build-
169
170
  standalone release.
170
171
  update (upgrade) Update one, more, or all versions to another release.
@@ -173,6 +174,7 @@ Commands:
173
174
  available.
174
175
  show Show versions available from a release.
175
176
  path Show path prefix to installed version base directory.
177
+ cache Show release cache sizes.
176
178
 
177
179
  Some commands offer aliases as shown in parentheses above. Note you can set
178
180
  default starting global options in $HOME/.config/pystand-flags.conf.
@@ -307,6 +309,23 @@ options:
307
309
  -c, --cache-path just show path to cache dir
308
310
  ```
309
311
 
312
+ ### Command `cache`
313
+
314
+ ```
315
+ usage: pystand cache [-h] [-T] [-H] [release ...]
316
+
317
+ Show release cache sizes.
318
+
319
+ positional arguments:
320
+ release show cache size for given release[s] only
321
+
322
+ options:
323
+ -h, --help show this help message and exit
324
+ -T, --no-total do not show total cache size
325
+ -H, --no-human-readable
326
+ show sizes in bytes, not human readable format
327
+ ```
328
+
310
329
  ## Installation and Upgrade
311
330
 
312
331
  Python 3.8 or later is required. Arch Linux users can install [`pystand`
@@ -0,0 +1,6 @@
1
+ pystand.py,sha256=sTLUk0IwUHh0e4UC0l8V1SyoDnC8WR-n-Ny_jjNjxSU,38681
2
+ pystand-2.16.dist-info/METADATA,sha256=oXreTd3Md066sjMLwKdib9L-xyKw0lITfi7hWflTwvE,25371
3
+ pystand-2.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
4
+ pystand-2.16.dist-info/entry_points.txt,sha256=DG4ps3I3nni1bubV1tXs6u8FARgkdbAYaEAzZD4RAo8,41
5
+ pystand-2.16.dist-info/top_level.txt,sha256=NoWUh19UQymAJLHTCdxMnVwV6Teftef5fzyF3OWLyNY,8
6
+ pystand-2.16.dist-info/RECORD,,
pystand.py CHANGED
@@ -610,6 +610,36 @@ def install(
610
610
  return error
611
611
 
612
612
 
613
+ def to_human(num, prec: int | None = None) -> str:
614
+ "Convert a number of bytes to a human-readable format"
615
+ units = ('B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
616
+ for unit in units:
617
+ if abs(num) < 1024.0 or unit == units[-1]:
618
+ return f'{round(num, prec)}{unit}'
619
+ num /= 1024.0
620
+
621
+ return ''
622
+
623
+
624
+ def show_cache_size(path: Path, args: Namespace) -> None:
625
+ "Show the size of the cache directory"
626
+ total = 0
627
+ for spath in sorted(path.iterdir()):
628
+ size = (
629
+ sum(p.stat().st_size for p in spath.iterdir())
630
+ if spath.is_dir()
631
+ else spath.stat().st_size
632
+ )
633
+ total += size
634
+ size_str = f'{size}B' if args.no_human_readable else to_human(size)
635
+ name = str(spath) if spath.is_dir() else spath.name
636
+ print(f'{size_str}\t{name}')
637
+
638
+ if not args.no_total:
639
+ size_str = f'{total}B' if args.no_human_readable else to_human(total, 2)
640
+ print(f'{size_str}\tTOTAL')
641
+
642
+
613
643
  def main() -> str | None:
614
644
  "Main code"
615
645
  distro_default = DISTRIBUTIONS.get((platform.system(), platform.machine()))
@@ -631,7 +661,8 @@ def main() -> str | None:
631
661
  opt.add_argument(
632
662
  '-D',
633
663
  '--distribution',
634
- help=f'{REPO} distribution. Default is "{distro_help} for this host',
664
+ help=f'{REPO} distribution. Default is "{distro_help}" for this host. '
665
+ f'Run "{PROG} show -a" to see all distributions.',
635
666
  )
636
667
  opt.add_argument(
637
668
  '-P',
@@ -1143,5 +1174,33 @@ class path_:
1143
1174
  print(path)
1144
1175
 
1145
1176
 
1177
+ # COMMAND
1178
+ class cache_:
1179
+ "Show release cache sizes."
1180
+
1181
+ @staticmethod
1182
+ def init(parser: ArgumentParser) -> None:
1183
+ parser.add_argument(
1184
+ '-T', '--no-total', action='store_true', help='do not show total cache size'
1185
+ )
1186
+ parser.add_argument(
1187
+ '-H',
1188
+ '--no-human-readable',
1189
+ action='store_true',
1190
+ help='show sizes in bytes, not human readable format',
1191
+ )
1192
+ parser.add_argument(
1193
+ 'release', nargs='*', help='show cache size for given release[s] only'
1194
+ )
1195
+
1196
+ @staticmethod
1197
+ def run(args: Namespace) -> str | None:
1198
+ if args.release:
1199
+ for release in args.release:
1200
+ show_cache_size(args._downloads / release, args)
1201
+ else:
1202
+ show_cache_size(args._downloads, args)
1203
+
1204
+
1146
1205
  if __name__ == '__main__':
1147
1206
  sys.exit(main())
@@ -1,6 +0,0 @@
1
- pystand.py,sha256=YdgoQlLi4iHbZ90ecupVwu8TEJ6yzvFYytSs7IdHrYk,36817
2
- pystand-2.15.dist-info/METADATA,sha256=ocaigth4pZqZRftG54e00VRKR5v9FAk7DId1oIeSGTw,24824
3
- pystand-2.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
4
- pystand-2.15.dist-info/entry_points.txt,sha256=DG4ps3I3nni1bubV1tXs6u8FARgkdbAYaEAzZD4RAo8,41
5
- pystand-2.15.dist-info/top_level.txt,sha256=NoWUh19UQymAJLHTCdxMnVwV6Teftef5fzyF3OWLyNY,8
6
- pystand-2.15.dist-info/RECORD,,
File without changes