pystand 2.24__tar.gz → 2.26__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.24
3
+ Version: 2.26
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
@@ -335,7 +335,7 @@ options:
335
335
  ### Command `cache`
336
336
 
337
337
  ```
338
- usage: pystand cache [-h] [-T] [-H] [-r] [release ...]
338
+ usage: pystand cache [-h] [-T] [-H] [-r | -R] [release ...]
339
339
 
340
340
  Show size of release download caches.
341
341
 
@@ -348,6 +348,9 @@ options:
348
348
  -H, --no-human-readable
349
349
  show sizes in bytes, not human readable format
350
350
  -r, --remove remove download cache[s] instead of showing size
351
+ -R, --remove-all-unused
352
+ remove caches for all currently unused releases
353
+ instead of showing size
351
354
  ```
352
355
 
353
356
  ## Installation and Upgrade
@@ -315,7 +315,7 @@ options:
315
315
  ### Command `cache`
316
316
 
317
317
  ```
318
- usage: pystand cache [-h] [-T] [-H] [-r] [release ...]
318
+ usage: pystand cache [-h] [-T] [-H] [-r | -R] [release ...]
319
319
 
320
320
  Show size of release download caches.
321
321
 
@@ -328,6 +328,9 @@ options:
328
328
  -H, --no-human-readable
329
329
  show sizes in bytes, not human readable format
330
330
  -r, --remove remove download cache[s] instead of showing size
331
+ -R, --remove-all-unused
332
+ remove caches for all currently unused releases
333
+ instead of showing size
331
334
  ```
332
335
 
333
336
  ## Installation and Upgrade
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pystand
3
- Version: 2.24
3
+ Version: 2.26
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
@@ -335,7 +335,7 @@ options:
335
335
  ### Command `cache`
336
336
 
337
337
  ```
338
- usage: pystand cache [-h] [-T] [-H] [-r] [release ...]
338
+ usage: pystand cache [-h] [-T] [-H] [-r | -R] [release ...]
339
339
 
340
340
  Show size of release download caches.
341
341
 
@@ -348,6 +348,9 @@ options:
348
348
  -H, --no-human-readable
349
349
  show sizes in bytes, not human readable format
350
350
  -r, --remove remove download cache[s] instead of showing size
351
+ -R, --remove-all-unused
352
+ remove caches for all currently unused releases
353
+ instead of showing size
351
354
  ```
352
355
 
353
356
  ## Installation and Upgrade
@@ -45,6 +45,7 @@ PROG = Path(__file__).stem
45
45
  DISTRIBUTIONS = {
46
46
  ('Linux', 'x86_64'): 'x86_64_v3-unknown-linux-gnu-install_only_stripped',
47
47
  ('Linux', 'aarch64'): 'aarch64-unknown-linux-gnu-install_only_stripped',
48
+ ('Linux', 'arm64'): 'aarch64-unknown-linux-gnu-install_only_stripped',
48
49
  ('Linux', 'armv7l'): 'armv7-unknown-linux-gnueabihf-install_only_stripped',
49
50
  ('Linux', 'armv8l'): 'armv7-unknown-linux-gnueabihf-install_only_stripped',
50
51
  ('Darwin', 'x86_64'): 'x86_64-apple-darwin-install_only_stripped',
@@ -52,6 +53,8 @@ DISTRIBUTIONS = {
52
53
  ('Darwin', 'arm64'): 'aarch64-apple-darwin-install_only_stripped',
53
54
  ('Windows', 'x86_64'): 'x86_64-pc-windows-msvc-shared-install_only_stripped',
54
55
  ('Windows', 'i686'): 'i686-pc-windows-msvc-shared-install_only_stripped',
56
+ ('Windows', 'aarch64'): 'aarch64-pc-windows-msvc-install_only_stripped',
57
+ ('Windows', 'arm64'): 'aarch64-pc-windows-msvc-install_only_stripped',
55
58
  }
56
59
 
57
60
  CERTS = ('system', 'certifi', 'none')
@@ -180,11 +183,11 @@ def get_gh(args: Namespace) -> Any:
180
183
  # Save this handle globally for future use
181
184
  from github import Github
182
185
 
183
- get_gh_handle = Github(auth=auth) # type: ignore
186
+ get_gh_handle = Github(auth=auth)
184
187
  return get_gh_handle
185
188
 
186
189
 
187
- def rm_path(path: Path) -> None:
190
+ def rm_path(path: Path) -> bool:
188
191
  "Remove the given path"
189
192
  if path.is_symlink():
190
193
  path.unlink()
@@ -192,6 +195,10 @@ def rm_path(path: Path) -> None:
192
195
  shutil.rmtree(path)
193
196
  elif path.exists():
194
197
  path.unlink()
198
+ else:
199
+ return False
200
+
201
+ return True
195
202
 
196
203
 
197
204
  def register_zst() -> None:
@@ -398,7 +405,11 @@ def fetch_tag_latest(args: Namespace) -> str:
398
405
 
399
406
  def get_release_tag(args: Namespace) -> str:
400
407
  "Return the release tag, or latest if not specified"
401
- if hasattr(args, 'release') and (release := args.release):
408
+ if (
409
+ hasattr(args, 'release')
410
+ and (release := args.release)
411
+ and isinstance(release, str)
412
+ ):
402
413
  if err := check_release_tag(release):
403
414
  sys.exit(err)
404
415
 
@@ -527,9 +538,8 @@ def update_version_symlinks(args: Namespace) -> None:
527
538
  (base / name).symlink_to(tgt, target_is_directory=True)
528
539
 
529
540
 
530
- def purge_unused_releases(args: Namespace) -> None:
531
- "Purge old releases that are no longer needed and have expired"
532
- # Want to keep releases for versions that we currently have installed
541
+ def keeplist(args: Namespace) -> set[str]:
542
+ "Return a set of release names to keep"
533
543
  keep = {
534
544
  r for v in iter_versions(args) if (r := get_json(v / args._data).get('release'))
535
545
  }
@@ -538,6 +548,14 @@ def purge_unused_releases(args: Namespace) -> None:
538
548
  if args._latest_release.exists():
539
549
  keep.add(args._latest_release.read_text().strip())
540
550
 
551
+ return keep
552
+
553
+
554
+ def purge_unused_releases(args: Namespace) -> None:
555
+ "Purge old releases that are no longer needed and have expired"
556
+ # Want to keep releases for versions that we currently have installed
557
+ keep = keeplist(args)
558
+
541
559
  # Purge any release lists that are no longer used and have expired
542
560
  now_secs = time.time()
543
561
  end_secs = args.purge_days * 86400
@@ -691,7 +709,9 @@ def show_cache_size(path: Path, args: Namespace) -> None:
691
709
  )
692
710
  total += size
693
711
  size_str = f'{size}B' if args.no_human_readable else to_human(size)
694
- name = str(spath) if spath.is_dir() else spath.name
712
+ name = (
713
+ str(spath) if spath.is_dir() else f'{spath.parent.name}{os.sep}{spath.name}'
714
+ )
695
715
  print(f'{size_str}\t{name}')
696
716
 
697
717
  if not args.no_total:
@@ -952,7 +972,10 @@ class install_:
952
972
  vdir = args._versions / version
953
973
 
954
974
  if vdir.exists() and not args.force:
955
- print(f'Version {version} is already installed.', file=sys.stderr)
975
+ print(
976
+ f'Version {args._fmtrel(version, release)} is already installed.',
977
+ file=sys.stderr,
978
+ )
956
979
  continue
957
980
 
958
981
  if error := install(args, vdir, release, args._distribution, files):
@@ -1317,32 +1340,59 @@ class cache_:
1317
1340
  action='store_true',
1318
1341
  help='show sizes in bytes, not human readable format',
1319
1342
  )
1320
- parser.add_argument(
1343
+ group = parser.add_mutually_exclusive_group()
1344
+ group.add_argument(
1321
1345
  '-r',
1322
1346
  '--remove',
1323
1347
  action='store_true',
1324
1348
  help='remove download cache[s] instead of showing size',
1325
1349
  )
1350
+ group.add_argument(
1351
+ '-R',
1352
+ '--remove-all-unused',
1353
+ action='store_true',
1354
+ help='remove caches for all currently unused releases instead of showing size',
1355
+ )
1326
1356
  parser.add_argument(
1327
1357
  'release', nargs='*', help='show cache size for given release[s] only'
1328
1358
  )
1329
1359
 
1330
1360
  @staticmethod
1331
1361
  def run(args: Namespace) -> str | None:
1332
- if args.remove:
1362
+ if args.remove_all_unused:
1333
1363
  if args.release:
1334
- for release in args.release:
1335
- rm_path(args._downloads / release)
1336
- else:
1337
- rm_path(args._downloads)
1364
+ args.parser.error(
1365
+ 'Can not specify --remove-all-unused with release names.'
1366
+ )
1338
1367
 
1339
- print('Cache removed.')
1368
+ keep = keeplist(args)
1369
+ for release in args._downloads.iterdir():
1370
+ if (name := release.name) not in keep and name.isdigit():
1371
+ if rm_path(release):
1372
+ print(f'Removed cache for release {name}.')
1340
1373
 
1341
1374
  elif args.release:
1342
1375
  for release in args.release:
1343
- show_cache_size(args._downloads / release, args)
1376
+ # Allow user to include cache path in release name
1377
+ path = (args._downloads / release).expanduser()
1378
+
1379
+ if err := check_release_tag(path.name):
1380
+ return err
1381
+
1382
+ if not path.exists():
1383
+ return f'No cache for release {release}.'
1384
+
1385
+ if args.remove:
1386
+ if rm_path(args._downloads / release):
1387
+ print(f'Removed cache for release {release.name}.')
1388
+ else:
1389
+ show_cache_size(path, args)
1344
1390
  else:
1345
- show_cache_size(args._downloads, args)
1391
+ if args.remove:
1392
+ if rm_path(args._downloads):
1393
+ print('Removed download cache.')
1394
+ else:
1395
+ show_cache_size(args._downloads, args)
1346
1396
 
1347
1397
 
1348
1398
  if __name__ == '__main__':
File without changes
File without changes
File without changes
File without changes