Skip to content

Commit 0a5acd1

Browse files
committed
remove online search from __main__
1 parent f2110a4 commit 0a5acd1

1 file changed

Lines changed: 3 additions & 91 deletions

File tree

src/ducktools/pythonfinder/__main__.py

Lines changed: 3 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444
ModuleImport("subprocess"),
4545
ModuleImport("sysconfig"),
4646
ModuleImport("platform"),
47-
FromImport(".pythonorg_search", "PythonOrgSearch"),
4847
FromImport("packaging.specifiers", "SpecifierSet"),
49-
FromImport("urllib.error", "URLError"),
5048
],
5149
globs=globals()
5250
)
@@ -137,39 +135,9 @@ def get_parser() -> argparse.ArgumentParser:
137135
help="Clear the cache of Python install details"
138136
)
139137

140-
online = subparsers.add_parser(
141-
"online",
142-
help="Get links to binaries from python.org"
143-
)
144-
145-
# Shared arguments
146-
for p in [parser, online]:
147-
p.add_argument("--min", help="Specify minimum Python version")
148-
p.add_argument("--max", help="Specify maximum Python version")
149-
p.add_argument("--compatible", help="Specify compatible Python version")
150-
151-
online.add_argument(
152-
"--all-binaries",
153-
action="store_true",
154-
help="Provide *all* matching binaries and "
155-
"not just the latest minor versions"
156-
)
157-
online.add_argument(
158-
"--system",
159-
action="store",
160-
help="Get python installers for a different system (eg: Windows, Darwin, Linux)"
161-
)
162-
online.add_argument(
163-
"--machine",
164-
action="store",
165-
help="Get python installers for a different architecture (eg: AMD64, ARM64, x86)"
166-
)
167-
168-
online.add_argument(
169-
"--prerelease",
170-
action="store_true",
171-
help="Include prerelease versions"
172-
)
138+
parser.add_argument("--min", help="Specify minimum Python version")
139+
parser.add_argument("--max", help="Specify maximum Python version")
140+
parser.add_argument("--compatible", help="Specify compatible Python version")
173141

174142
return parser
175143

@@ -263,47 +231,6 @@ def display_local_installs(
263231
print(f"| {version_str:>{max_version_len}s} | {executable:<{max_executable_len}s} |")
264232

265233

266-
def display_remote_binaries(
267-
min_ver: str,
268-
max_ver: str,
269-
compatible: str,
270-
all_binaries: bool,
271-
system: str,
272-
machine: str,
273-
prerelease: bool,
274-
) -> None:
275-
specs = []
276-
if min_ver:
277-
specs.append(f">={min_ver}")
278-
if max_ver:
279-
specs.append(f"<{max_ver}")
280-
if compatible:
281-
specs.append(f"~={compatible}")
282-
283-
spec = _laz.SpecifierSet(",".join(specs))
284-
285-
searcher = _laz.PythonOrgSearch(system=system, machine=machine)
286-
if all_binaries:
287-
releases = searcher.all_matching_binaries(spec, prereleases=prerelease)
288-
else:
289-
releases = searcher.latest_minor_binaries(spec, prereleases=prerelease)
290-
291-
headings = ["Python Version", "URL"]
292-
293-
if releases:
294-
max_url_len = max(
295-
len(headings[1]), max(len(release.url) for release in releases)
296-
)
297-
headings_str = f"| {headings[0]} | {headings[1]:<{max_url_len}s} |"
298-
299-
print(headings_str)
300-
print(f"| {'-' * len(headings[0])} | {'-' * max_url_len} |")
301-
302-
for release in releases:
303-
print(f"| {release.version:>14s} | {release.url:<{max_url_len}s} |")
304-
else:
305-
print("No Python releases found matching specification")
306-
307234

308235
def main() -> int:
309236
if sys.version_info < (3, 10):
@@ -319,21 +246,6 @@ def main() -> int:
319246

320247
if vals.command == "clear-cache":
321248
purge_caches()
322-
elif vals.command == "online":
323-
system = vals.system if vals.system else _laz.platform.system()
324-
machine = vals.machine if vals.machine else _laz.platform.machine()
325-
try:
326-
display_remote_binaries(
327-
vals.min,
328-
vals.max,
329-
vals.compatible,
330-
vals.all_binaries,
331-
system,
332-
machine,
333-
vals.prerelease,
334-
)
335-
except _laz.URLError:
336-
print("Could not connect to python.org")
337249
else:
338250
display_local_installs(
339251
min_ver=vals.min,

0 commit comments

Comments
 (0)