pystand 2.9__tar.gz → 2.10__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.
@@ -10,7 +10,7 @@ build:
10
10
  python3 -m build
11
11
 
12
12
  upload: build
13
- twine3 upload dist/*
13
+ uv-publish
14
14
 
15
15
  doc:
16
16
  update-readme-usage -A
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pystand
3
- Version: 2.9
3
+ Version: 2.10
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: GPLv3
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pystand
3
- Version: 2.9
3
+ Version: 2.10
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: GPLv3
@@ -7,18 +7,13 @@ https://github.com/astral-sh/python-build-standalone.
7
7
  '''
8
8
  from __future__ import annotations
9
9
 
10
- import json
11
10
  import os
12
11
  import platform
13
12
  import re
14
13
  import shlex
15
14
  import shutil
16
- import subprocess
17
15
  import sys
18
- import tarfile
19
16
  import time
20
- import urllib.parse
21
- import urllib.request
22
17
  from argparse import SUPPRESS, ArgumentParser, Namespace
23
18
  from collections import defaultdict
24
19
  from datetime import date, datetime, timedelta
@@ -26,9 +21,7 @@ from pathlib import Path
26
21
  from typing import Any, Iterable, Iterator
27
22
 
28
23
  import argcomplete
29
- import github
30
24
  import platformdirs
31
- import zstandard
32
25
  from packaging.version import parse as parse_version
33
26
 
34
27
  REPO = 'python-build-standalone'
@@ -78,10 +71,11 @@ def fmt(version, release) -> str:
78
71
  return f'{version} @ {release}'
79
72
 
80
73
  def get_json(file: Path) -> dict:
74
+ from json import load
81
75
  'Get JSON data from given file'
82
76
  try:
83
77
  with file.open() as fp:
84
- return json.load(fp)
78
+ return load(fp)
85
79
  except Exception:
86
80
  pass
87
81
 
@@ -89,9 +83,10 @@ def get_json(file: Path) -> dict:
89
83
 
90
84
  def set_json(file: Path, data: dict) -> str | None:
91
85
  'Set JSON data to given file'
86
+ from json import dump
92
87
  try:
93
88
  with file.open('w') as fp:
94
- json.dump(data, fp, indent=2)
89
+ dump(data, fp, indent=2)
95
90
  except Exception as e:
96
91
  return str(e)
97
92
 
@@ -108,12 +103,14 @@ def get_gh(args: Namespace) -> Any:
108
103
  return get_gh_handle
109
104
 
110
105
  if args.github_access_token:
111
- auth = github.Auth.Token(args.github_access_token)
106
+ from github.Auth import Token
107
+ auth = Token(args.github_access_token)
112
108
  else:
113
109
  auth = None
114
110
 
115
111
  # Save this handle globally for future use
116
- get_gh_handle = github.Github(auth=auth) # type: ignore
112
+ from github import Github
113
+ get_gh_handle = Github(auth=auth) # type: ignore
117
114
  return get_gh_handle
118
115
 
119
116
  def rm_path(path: Path) -> None:
@@ -127,6 +124,9 @@ def rm_path(path: Path) -> None:
127
124
 
128
125
  def unpack_zst(filename: str, extract_dir: str) -> None:
129
126
  'Unpack a zstandard compressed tar'
127
+ import tarfile
128
+
129
+ import zstandard
130
130
  with open(filename, 'rb') as compressed:
131
131
  dctx = zstandard.ZstdDecompressor()
132
132
  with dctx.stream_reader(compressed) as reader:
@@ -135,19 +135,21 @@ def unpack_zst(filename: str, extract_dir: str) -> None:
135
135
 
136
136
  def fetch(args: Namespace, release: str, url: str, tdir: Path) -> str | None:
137
137
  'Fetch and unpack a release file'
138
+ from urllib.parse import unquote, urlparse
139
+ from urllib.request import urlretrieve
138
140
  error = None
139
141
  tmpdir = tdir.with_name(f'{tdir.name}-tmp')
140
142
  rm_path(tmpdir)
141
143
  tmpdir.mkdir(parents=True)
142
144
 
143
- filename_q = Path(urllib.parse.urlparse(url).path).name
144
- filename = urllib.parse.unquote(filename_q)
145
+ filename_q = Path(urlparse(url).path).name
146
+ filename = unquote(filename_q)
145
147
  cache_file = args._downloads / release / filename
146
148
  cache_file.parent.mkdir(parents=True, exist_ok=True)
147
149
 
148
150
  if not cache_file.exists():
149
151
  try:
150
- urllib.request.urlretrieve(url, cache_file)
152
+ urlretrieve(url, cache_file)
151
153
  except Exception as e:
152
154
  error = f'Failed to fetch "{url}": {e}'
153
155
 
@@ -279,8 +281,9 @@ def check_release_tag(release: str) -> str | None:
279
281
  def fetch_tags() -> Iterator[tuple[str, str]]:
280
282
  'Fetch the latest release tag from the GitHub release atom feed'
281
283
  import xml.etree.ElementTree as et
284
+ from urllib.request import urlopen
282
285
  try:
283
- with urllib.request.urlopen(LATEST_RELEASE) as url:
286
+ with urlopen(LATEST_RELEASE) as url:
284
287
  data = et.parse(url).getroot()
285
288
  except Exception:
286
289
  sys.exit('Failed to fetch latest YYYYMMDD release atom file.')
@@ -349,7 +352,6 @@ def add_file(files: dict, tag: str, name: str, url: str) -> None:
349
352
 
350
353
  def get_release_files(args, tag, implementation: str | None = None) -> dict:
351
354
  'Return the release files for the given tag'
352
- from github.GithubException import UnknownObjectException
353
355
  # Look for tag data in our release cache
354
356
  jfile = args._releases / tag
355
357
  if not (files := get_json(jfile)):
@@ -359,6 +361,7 @@ def get_release_files(args, tag, implementation: str | None = None) -> dict:
359
361
  return {}
360
362
 
361
363
  # Not in cache so fetch it (and also store in cache)
364
+ from github.GithubException import UnknownObjectException
362
365
  gh = get_gh(args)
363
366
  try:
364
367
  release = gh.get_repo(GITHUB_REPO).get_release(tag)
@@ -489,6 +492,8 @@ def remove(args: Namespace, version: str) -> None:
489
492
 
490
493
  def strip_binaries(vdir: Path, distribution: str) -> bool:
491
494
  'Strip binaries from files in a version directory'
495
+ from subprocess import DEVNULL, run
496
+
492
497
  # Only run the strip command on Linux hosts and for Linux distributions
493
498
  was_stripped = False
494
499
  if platform.system() == 'Linux' and '-linux-' in distribution:
@@ -501,7 +506,7 @@ def strip_binaries(vdir: Path, distribution: str) -> bool:
501
506
  if not file.is_symlink() and file.is_file():
502
507
  cmd = f'strip -p --strip-unneeded {file}'.split()
503
508
  try:
504
- subprocess.run(cmd, stderr=subprocess.DEVNULL)
509
+ run(cmd, stderr=DEVNULL)
505
510
  except Exception:
506
511
  pass
507
512
  else:
File without changes
File without changes
File without changes
File without changes
File without changes