pip-ui-tkinter 0.1.0__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.
pip_ui/__about__.py ADDED
@@ -0,0 +1,25 @@
1
+ """Metadata for pip-ui-tkinter."""
2
+
3
+ __all__ = [
4
+ "__credits__",
5
+ "__dependencies__",
6
+ "__description__",
7
+ "__keywords__",
8
+ "__license__",
9
+ "__readme__",
10
+ "__requires_python__",
11
+ "__status__",
12
+ "__title__",
13
+ "__version__",
14
+ ]
15
+
16
+ __title__ = "pip-ui-tkinter"
17
+ __version__ = "0.1.0"
18
+ __description__ = "A pip UI tool"
19
+ __readme__ = "README.md"
20
+ __credits__ = [{"name": "Matthew Martin", "email": "matthewdeanmartin@gmail.com"}]
21
+ __keywords__ = ["pip-ui-tkinter", "pip"]
22
+ __license__ = "MIT"
23
+ __requires_python__ = ">=3.10"
24
+ __status__ = "3 - Alpha"
25
+ __dependencies__: list[str] = []
pip_ui/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """A pip UI tool."""
2
+
3
+ from pip_ui.__about__ import __version__
4
+
5
+ __all__ = ["__version__"]
pip_ui/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ """Allows `python -m pip_ui` invocation."""
2
+
3
+ from pip_ui.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
pip_ui/cli.py ADDED
@@ -0,0 +1,117 @@
1
+ """Command-line entry point for pip_ui."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import importlib.util
7
+ import sys
8
+
9
+ from pip_ui.__about__ import __version__
10
+ from pip_ui.encoding import configure_utf8_stdio
11
+
12
+
13
+ def main() -> None:
14
+ """Parse CLI arguments and launch the GUI or diagnostics mode."""
15
+ configure_utf8_stdio()
16
+ parser = argparse.ArgumentParser(
17
+ prog="pip-ui",
18
+ description="A Tkinter GUI for pip. Runs commands via: python -m pip",
19
+ )
20
+ parser.add_argument(
21
+ "--version",
22
+ action="version",
23
+ version=f"%(prog)s {__version__}",
24
+ )
25
+ parser.add_argument(
26
+ "--interpreter",
27
+ metavar="PATH",
28
+ help="Path to the Python interpreter to use.",
29
+ default=None,
30
+ )
31
+ parser.add_argument(
32
+ "--working-directory",
33
+ metavar="PATH",
34
+ help="Working directory for pip commands.",
35
+ default=None,
36
+ )
37
+ parser.add_argument(
38
+ "--diagnostics",
39
+ action="store_true",
40
+ help="Print a diagnostics report and exit without launching the GUI.",
41
+ )
42
+ parser.add_argument(
43
+ "--no-history",
44
+ action="store_true",
45
+ help="Do not record command history.",
46
+ )
47
+ parser.add_argument(
48
+ "--safe-mode",
49
+ action="store_true",
50
+ help="Prompt for confirmation before any potentially destructive command.",
51
+ )
52
+
53
+ args = parser.parse_args()
54
+
55
+ if args.diagnostics:
56
+ run_diagnostics(args.interpreter)
57
+ return
58
+
59
+ if importlib.util.find_spec("tkinter") is None:
60
+ print(
61
+ "Error: Tkinter is not available in this Python installation.\n"
62
+ "On Debian/Ubuntu: sudo apt-get install python3-tk\n"
63
+ "On Fedora: sudo dnf install python3-tkinter\n"
64
+ "On macOS: install Python from python.org (includes Tk)\n"
65
+ "On Windows: re-run the Python installer and ensure 'tcl/tk' is checked.",
66
+ file=sys.stderr,
67
+ )
68
+ sys.exit(1)
69
+
70
+ from pip_ui.ui.main_window import MainWindow # pylint: disable=import-outside-toplevel
71
+
72
+ app = MainWindow(
73
+ no_history=args.no_history,
74
+ safe_mode=args.safe_mode,
75
+ )
76
+
77
+ if args.interpreter:
78
+ app.after(200, lambda: app.interpreter_picker.set_from_path(args.interpreter))
79
+
80
+ if args.working_directory:
81
+ app.workdir_var.set(args.working_directory)
82
+ app.status_workdir_var.set(args.working_directory)
83
+
84
+ try:
85
+ app.mainloop()
86
+ except KeyboardInterrupt:
87
+ app.on_close()
88
+
89
+
90
+ def run_diagnostics(interpreter_path: str | None) -> None:
91
+ """Print a diagnostics report for the selected or default interpreter."""
92
+ from pip_ui.environment import InterpreterDiscovery # pylint: disable=import-outside-toplevel
93
+
94
+ discovery = InterpreterDiscovery()
95
+ interpreters = discovery.discover()
96
+
97
+ if interpreter_path:
98
+ target = discovery.validate(interpreter_path)
99
+ if target is None:
100
+ print(f"Warning: Could not validate interpreter at: {interpreter_path}", file=sys.stderr)
101
+ target = interpreters[0] if interpreters else None
102
+ else:
103
+ target = interpreters[0] if interpreters else None
104
+
105
+ if target is None:
106
+ print("No Python interpreters found.", file=sys.stderr)
107
+ sys.exit(1)
108
+
109
+ from pip_ui.config_inspector import ConfigInspector # pylint: disable=import-outside-toplevel
110
+
111
+ inspector = ConfigInspector(target.path)
112
+ report = inspector.build_diagnostics_report("markdown")
113
+ print(report)
114
+
115
+
116
+ if __name__ == "__main__":
117
+ main()