pyputil-install 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.
- pyputil_install/__init__.py +295 -0
- pyputil_install/auto_installer/__init__.py +110 -0
- pyputil_install/auto_installer/_async.py +862 -0
- pyputil_install/auto_installer/core.py +481 -0
- pyputil_install/auto_installer/sync.py +718 -0
- pyputil_install/auto_installer/utils.py +1143 -0
- pyputil_install/compiler_installer/__init__.py +296 -0
- pyputil_install/compiler_installer/installer/__init__.py +0 -0
- pyputil_install/compiler_installer/installer/activation.py +596 -0
- pyputil_install/compiler_installer/installer/environments.py +867 -0
- pyputil_install/compiler_installer/installer/install.py +800 -0
- pyputil_install/compiler_installer/installer/layouts.py +858 -0
- pyputil_install/compiler_installer/installer/manifests.py +740 -0
- pyputil_install/compiler_installer/installer/symlinks.py +875 -0
- pyputil_install/compiler_installer/installer/uninstall.py +804 -0
- pyputil_install/compiler_installer/toolchains/__init__.py +225 -0
- pyputil_install/compiler_installer/toolchains/abi.py +485 -0
- pyputil_install/compiler_installer/toolchains/android.py +421 -0
- pyputil_install/compiler_installer/toolchains/base.py +664 -0
- pyputil_install/compiler_installer/toolchains/capabilities.py +799 -0
- pyputil_install/compiler_installer/toolchains/clang.py +624 -0
- pyputil_install/compiler_installer/toolchains/detection.py +805 -0
- pyputil_install/compiler_installer/toolchains/emscripten.py +427 -0
- pyputil_install/compiler_installer/toolchains/environments.py +729 -0
- pyputil_install/compiler_installer/toolchains/gcc.py +714 -0
- pyputil_install/compiler_installer/toolchains/msvc.py +659 -0
- pyputil_install/compiler_installer/toolchains/runtimes.py +504 -0
- pyputil_install/compiler_installer/toolchains/sysroots.py +511 -0
- pyputil_install/compiler_installer/toolchains/zig.py +305 -0
- pyputil_install/compiler_installer/toolforge/__init__.py +182 -0
- pyputil_install/compiler_installer/toolforge/cache.py +522 -0
- pyputil_install/compiler_installer/toolforge/discovery.py +554 -0
- pyputil_install/compiler_installer/toolforge/models.py +142 -0
- pyputil_install/compiler_installer/toolforge/parsers.py +411 -0
- pyputil_install/compiler_installer/toolforge/scoring.py +383 -0
- pyputil_install/compiler_installer/toolforge/strategies.py +756 -0
- pyputil_install/compiler_installer/toolforge/validation.py +455 -0
- pyputil_install/compiler_installer/urls/__init__.py +106 -0
- pyputil_install/compiler_installer/urls/base.py +326 -0
- pyputil_install/compiler_installer/urls/builder.py +585 -0
- pyputil_install/compiler_installer/urls/context.py +271 -0
- pyputil_install/compiler_installer/urls/registry.py +530 -0
- pyputil_install/compiler_installer/urls/templates.py +193 -0
- pyputil_install/compiler_installer/urls/validation.py +605 -0
- pyputil_install/package_installer/__init__.py +383 -0
- pyputil_install/package_installer/cache.py +1190 -0
- pyputil_install/package_installer/cli/__init__.py +0 -0
- pyputil_install/package_installer/cli/formatters.py +563 -0
- pyputil_install/package_installer/cli/main.py +872 -0
- pyputil_install/package_installer/environment/__init__.py +0 -0
- pyputil_install/package_installer/environment/venv.py +1114 -0
- pyputil_install/package_installer/exceptions.py +688 -0
- pyputil_install/package_installer/installer.py +1301 -0
- pyputil_install/package_installer/network/__init__.py +0 -0
- pyputil_install/package_installer/network/pypi.py +1122 -0
- pyputil_install/package_installer/network/session.py +828 -0
- pyputil_install/package_installer/retry.py +696 -0
- pyputil_install/package_installer/security/__init__.py +0 -0
- pyputil_install/package_installer/security/hashes.py +845 -0
- pyputil_install/package_installer/security/verify.py +1024 -0
- pyputil_install/pip_installer/__init__.py +371 -0
- pyputil_install/pip_installer/checker.py +1327 -0
- pyputil_install/pip_installer/extractor.py +1267 -0
- pyputil_install/pip_installer/fetcher.py +1632 -0
- pyputil_install/pip_installer/installer.py +2230 -0
- pyputil_install/pip_installer/main.py +2474 -0
- pyputil_install/pip_installer/versions.py +1422 -0
- pyputil_install/pyheaders_installer/__init__.py +716 -0
- pyputil_install/pyheaders_installer/cli.py +1027 -0
- pyputil_install/pyheaders_installer/config.py +588 -0
- pyputil_install/pyheaders_installer/downloader.py +1796 -0
- pyputil_install/pyheaders_installer/exceptions.py +591 -0
- pyputil_install/pyheaders_installer/extractor.py +1131 -0
- pyputil_install/pyheaders_installer/installer.py +1246 -0
- pyputil_install/python_installer/__init__.py +263 -0
- pyputil_install/python_installer/cli.py +1122 -0
- pyputil_install/python_installer/downloader.py +1900 -0
- pyputil_install/python_installer/extractor.py +1202 -0
- pyputil_install/python_installer/installer.py +1290 -0
- pyputil_install/python_installer/manager.py +1097 -0
- pyputil_install/python_installer/platforms.py +940 -0
- pyputil_install/python_installer/runner.py +1163 -0
- pyputil_install/stdlib_installer/__init__.py +230 -0
- pyputil_install/stdlib_installer/cli.py +664 -0
- pyputil_install/stdlib_installer/downloader.py +1717 -0
- pyputil_install/stdlib_installer/exceptions.py +466 -0
- pyputil_install/stdlib_installer/installer.py +1085 -0
- pyputil_install/stdlib_installer/manifest.py +754 -0
- pyputil_install/stdlib_installer/utils.py +679 -0
- pyputil_install-0.1.0.dist-info/METADATA +264 -0
- pyputil_install-0.1.0.dist-info/RECORD +95 -0
- pyputil_install-0.1.0.dist-info/WHEEL +5 -0
- pyputil_install-0.1.0.dist-info/entry_points.txt +6 -0
- pyputil_install-0.1.0.dist-info/licenses/LICENSE +21 -0
- pyputil_install-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
PyPUtil Install - Python Package Utilities Installer
|
|
6
|
+
|
|
7
|
+
A collection of tools for managing Python installations, packages, compiler
|
|
8
|
+
toolchains, and development headers. Each subproject operates independently
|
|
9
|
+
and can be used as a standalone library or via CLI.
|
|
10
|
+
|
|
11
|
+
Author: Moamen Walid
|
|
12
|
+
License: MIT
|
|
13
|
+
Repository: https://github.com/moamen-walid-pyputil/pyputil-install
|
|
14
|
+
Issues: https://github.com/moamen-walid-pyputil/pyputil-install/issues
|
|
15
|
+
Email: pyputilframework@gmail.com
|
|
16
|
+
Version: 0.1.0
|
|
17
|
+
|
|
18
|
+
Project Structure
|
|
19
|
+
-----------------
|
|
20
|
+
pyputil_install/
|
|
21
|
+
├── auto_installer/ # Automatic package installation on import failure
|
|
22
|
+
├── stdlib_installer/ # Download stdlib modules from CPython GitHub
|
|
23
|
+
├── python_installer/ # Standalone Python version management
|
|
24
|
+
├── pyheaders_installer/ # Python C header installation
|
|
25
|
+
├── package_installer/ # Advanced package manager (pip wrapper)
|
|
26
|
+
├── pip_installer/ # Pip diagnosis, repair, and reinstallation
|
|
27
|
+
└── compiler_installer/ # C/C++ toolchain management
|
|
28
|
+
├── urls/ # URL resolution for compiler releases
|
|
29
|
+
├── installer/ # Installation, manifests, symlinks, activation
|
|
30
|
+
├── toolchains/ # Compiler implementations (GCC, Clang, Zig, etc.)
|
|
31
|
+
└── toolforge/ # System compiler discovery and scoring
|
|
32
|
+
|
|
33
|
+
Subproject Descriptions
|
|
34
|
+
-----------------------
|
|
35
|
+
auto_installer
|
|
36
|
+
Replaces builtins.__import__ to intercept ImportError and automatically
|
|
37
|
+
install missing packages via pip. Supports synchronous (immediate) and
|
|
38
|
+
asynchronous (deferred/concurrent) installation modes.
|
|
39
|
+
|
|
40
|
+
stdlib_installer
|
|
41
|
+
Downloads pure-Python standard library modules from the CPython GitHub
|
|
42
|
+
repository. Useful when system Python installations are minimal or missing
|
|
43
|
+
certain stdlib components. Installs modules locally to a configurable
|
|
44
|
+
directory and can add that directory to sys.path.
|
|
45
|
+
|
|
46
|
+
python_installer
|
|
47
|
+
Downloads and installs standalone Python builds from the
|
|
48
|
+
indygreg/python-build-standalone project. Manages multiple isolated Python
|
|
49
|
+
versions in separate directories. Supports process switching (os.execve)
|
|
50
|
+
and shell default configuration (PATH modification).
|
|
51
|
+
|
|
52
|
+
pyheaders_installer
|
|
53
|
+
Downloads CPython source archives, extracts the Include directory, and
|
|
54
|
+
installs C header files (Python.h, pyconfig.h) to system or user include
|
|
55
|
+
directories. Supports atomic installation, backup/restore, and post-
|
|
56
|
+
installation verification.
|
|
57
|
+
|
|
58
|
+
package_installer
|
|
59
|
+
A comprehensive package manager that wraps pip with additional features:
|
|
60
|
+
file-based caching with TTL and compression, retry logic with exponential
|
|
61
|
+
backoff, cryptographic hash verification (SHA256, SHA512, BLAKE2b),
|
|
62
|
+
trust verification (host allowlist, certificate pinning), automatic
|
|
63
|
+
rollback on installation failure, and virtual environment management.
|
|
64
|
+
|
|
65
|
+
pip_installer
|
|
66
|
+
A pip-specific rescue tool. Diagnoses pip's state (HEALTHY, MISSING,
|
|
67
|
+
BROKEN, OUTDATED, BLOCKED) and reinstalls using the optimal strategy:
|
|
68
|
+
ensurepip, get-pip.py, wheel installation, or manual zipimport extraction.
|
|
69
|
+
Includes version compatibility checking against Python versions.
|
|
70
|
+
|
|
71
|
+
compiler_installer
|
|
72
|
+
A complete toolchain management system for C/C++ compilers and related
|
|
73
|
+
tools. Supports GCC (xPack), Clang/LLVM, MinGW-w64, ARM GNU Toolchain,
|
|
74
|
+
RISC-V, Emscripten SDK, Zig, and Android NDK. Provides download URL
|
|
75
|
+
resolution (with validation), extraction, manifest-based installation,
|
|
76
|
+
symlink management (versioned and short), PATH activation (process stack),
|
|
77
|
+
environment management (named compiler sets), and host system discovery
|
|
78
|
+
with scoring.
|
|
79
|
+
|
|
80
|
+
Dependencies
|
|
81
|
+
------------
|
|
82
|
+
Required:
|
|
83
|
+
- Python 3.9 or higher
|
|
84
|
+
- No external dependencies for core functionality (uses only stdlib)
|
|
85
|
+
|
|
86
|
+
Optional:
|
|
87
|
+
- aiohttp >= 3.8.0 : Async HTTP for compiler_installer downloads
|
|
88
|
+
- colorama >= 0.4.6 : ANSI color output on Windows (CLI)
|
|
89
|
+
- packaging >= 23.0 : PEP 440 version parsing (fallback included)
|
|
90
|
+
|
|
91
|
+
Environment Variables
|
|
92
|
+
---------------------
|
|
93
|
+
TOOLFORGE_HOME : Compiler installation root (default: ~/.local/share/toolforge)
|
|
94
|
+
TOOLFORGE_BIN_DIR : Centralized symlink directory for compilers
|
|
95
|
+
TOOLFORGE_TEMP_DIR : Temporary staging directory for downloads
|
|
96
|
+
TOOLFORGE_GITHUB_TOKEN : GitHub API token for higher rate limits
|
|
97
|
+
TOOLFORGE_SKIP_CHECKSUM : Set "1" to skip checksum verification
|
|
98
|
+
TOOLFORGE_SKIP_VALIDATION : Set "1" to skip pre-download URL validation
|
|
99
|
+
TOOLFORGE_NO_SYMLINKS : Set "1" to skip symlink creation
|
|
100
|
+
TOOLFORGE_LINK_STYLE : "both", "short", or "versioned"
|
|
101
|
+
TOOLFORGE_LINK_FORCE : Set "1" to overwrite existing symlinks
|
|
102
|
+
TOOLFORGE_ACTIVE : Colon-separated active toolchains (internal)
|
|
103
|
+
COMPILER_EXECUTION_TIMEOUT : Subprocess timeout for compiler discovery (default: 5)
|
|
104
|
+
COMPILER_SEARCH_CANDIDATES : Colon-separated executable names to search
|
|
105
|
+
COMPILER_SEARCH_DIRS : Colon-separated extra directories to scan
|
|
106
|
+
TOOLFORGE_CACHE_DIR : Cache directory for discovery results
|
|
107
|
+
TOOLFORGE_CACHE_MAX_AGE : Cache max age in seconds (default: 3600)
|
|
108
|
+
|
|
109
|
+
CLI Entry Points
|
|
110
|
+
----------------
|
|
111
|
+
package-installer : Main package manager (install, upgrade, search, freeze, venv)
|
|
112
|
+
pip-installer : Pip diagnosis and repair
|
|
113
|
+
stdlib-installer : Stdlib module management
|
|
114
|
+
python-installer : Python version management
|
|
115
|
+
headers-installer : Python header installation
|
|
116
|
+
pt / pyputil : Aliases for package-installer
|
|
117
|
+
|
|
118
|
+
Exit Codes (package_installer CLI)
|
|
119
|
+
----------------------------------
|
|
120
|
+
0 : Success
|
|
121
|
+
1 : General error
|
|
122
|
+
2 : Argument error
|
|
123
|
+
3 : Download error
|
|
124
|
+
4 : Extraction error
|
|
125
|
+
5 : Installation error
|
|
126
|
+
6 : Verification error
|
|
127
|
+
|
|
128
|
+
Exit Codes (pip_installer CLI)
|
|
129
|
+
------------------------------
|
|
130
|
+
0 : Success
|
|
131
|
+
1 : General error
|
|
132
|
+
2 : Invalid arguments
|
|
133
|
+
3 : Network error
|
|
134
|
+
4 : Permission error
|
|
135
|
+
5 : Incompatible version
|
|
136
|
+
6 : Verification failed
|
|
137
|
+
|
|
138
|
+
Examples
|
|
139
|
+
--------
|
|
140
|
+
1. Install a Python package automatically on import:
|
|
141
|
+
|
|
142
|
+
from pyputil_install.auto_installer import auto_install_sync
|
|
143
|
+
auto_install_sync()
|
|
144
|
+
import requests # installs if missing
|
|
145
|
+
|
|
146
|
+
2. Install a missing stdlib module:
|
|
147
|
+
|
|
148
|
+
from pyputil_install.stdlib_installer import install_stdlib, add_to_sys_path
|
|
149
|
+
add_to_sys_path()
|
|
150
|
+
install_stdlib("tomllib", version="3.13")
|
|
151
|
+
import tomllib # works even on older Python
|
|
152
|
+
|
|
153
|
+
3. Install a standalone Python version:
|
|
154
|
+
|
|
155
|
+
from pyputil_install.python_installer.installer import PythonInstaller
|
|
156
|
+
installer = PythonInstaller()
|
|
157
|
+
result = installer.install("3.11.5")
|
|
158
|
+
print(result.path)
|
|
159
|
+
|
|
160
|
+
4. Install Python C headers:
|
|
161
|
+
|
|
162
|
+
from pyputil_install.pyheaders_installer import install_python_headers
|
|
163
|
+
path = install_python_headers(version="3.11.0")
|
|
164
|
+
print(path) # /usr/include/python3.11
|
|
165
|
+
|
|
166
|
+
5. Install a package with hash verification:
|
|
167
|
+
|
|
168
|
+
from pyputil_install.package_installer import PackageInstaller, InstallConfig
|
|
169
|
+
config = InstallConfig(require_hashes=True, use_cache=True)
|
|
170
|
+
installer = PackageInstaller("requests", config=config)
|
|
171
|
+
result = installer.install()
|
|
172
|
+
print(result.version_installed)
|
|
173
|
+
|
|
174
|
+
6. Repair a broken pip:
|
|
175
|
+
|
|
176
|
+
from pyputil_install.pip_installer import repair
|
|
177
|
+
result = repair(target_version="21.3.1", user_site=True)
|
|
178
|
+
print(result.success, result.version_installed)
|
|
179
|
+
|
|
180
|
+
7. Install a GCC toolchain:
|
|
181
|
+
|
|
182
|
+
import asyncio
|
|
183
|
+
from pyputil_install.compiler_installer import install_toolchain
|
|
184
|
+
result = await install_toolchain("gcc", "14.2.0-2", platform="linux", arch="x64")
|
|
185
|
+
print(result.path)
|
|
186
|
+
|
|
187
|
+
8. Discover compilers on the system:
|
|
188
|
+
|
|
189
|
+
from pyputil_install.compiler_installer.toolforge.discovery import discover_compilers
|
|
190
|
+
manager = discover_compilers()
|
|
191
|
+
best = manager.best()
|
|
192
|
+
print(best.path, best.version, best.kind)
|
|
193
|
+
|
|
194
|
+
9. Activate a compiler in the current process:
|
|
195
|
+
|
|
196
|
+
from pyputil_install.compiler_installer.activation import activate
|
|
197
|
+
activate("gcc", "14.2.0-2") # adds to PATH
|
|
198
|
+
|
|
199
|
+
10. Create and activate a named environment:
|
|
200
|
+
|
|
201
|
+
from pyputil_install.compiler_installer.environments import EnvironmentStore
|
|
202
|
+
store = EnvironmentStore()
|
|
203
|
+
store.create("cpp20", {"CC": "gcc@14.2.0-2", "CXX": "g++@14.2.0-2"})
|
|
204
|
+
store.activate("cpp20")
|
|
205
|
+
|
|
206
|
+
Module Exports
|
|
207
|
+
--------------
|
|
208
|
+
This __init__.py re-exports public APIs from all subprojects for convenience.
|
|
209
|
+
For detailed subproject APIs, import from the specific submodule.
|
|
210
|
+
|
|
211
|
+
Subproject Entry Points:
|
|
212
|
+
- auto_installer: auto_install_sync, auto_install_async, AsyncAutoInstaller, SyncAutoInstaller
|
|
213
|
+
- stdlib_installer: install_stdlib, remove_stdlib, list_installed_stdlib, add_to_sys_path
|
|
214
|
+
- python_installer: PythonInstaller, InstallResult as PythonInstallResult
|
|
215
|
+
- pyheaders_installer: install_python_headers, get_python_version, clean_cache
|
|
216
|
+
- package_installer: PackageInstaller, InstallConfig, InstallResult
|
|
217
|
+
- pip_installer: PipRescuer, repair, diagnose, check_compatibility
|
|
218
|
+
- compiler_installer: install_toolchain, activate, deactivate, discover_compilers.
|
|
219
|
+
|
|
220
|
+
Notes
|
|
221
|
+
-----
|
|
222
|
+
|
|
223
|
+
## Dependency Notice
|
|
224
|
+
|
|
225
|
+
This package is used in the second package of the PyPUtil Framework:
|
|
226
|
+
|
|
227
|
+
pyputil_cutil
|
|
228
|
+
|
|
229
|
+
So you may still need this package if you plan to install or use "pyputil_cutil".
|
|
230
|
+
Note: pyputil_cutil has not been released as a package yet, it is still under development.
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Reporting Issues
|
|
234
|
+
|
|
235
|
+
If you encounter any problems, please report them in the GitHub issues section and include:
|
|
236
|
+
|
|
237
|
+
- The error/problem you faced
|
|
238
|
+
- How the issue occurred
|
|
239
|
+
|
|
240
|
+
### GitHub Issues:
|
|
241
|
+
https://github.com/moamen-walid-pyputil/pyputil-install/issues
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Assistance & Project Ideas
|
|
246
|
+
|
|
247
|
+
If you would like:
|
|
248
|
+
|
|
249
|
+
- Special assistance
|
|
250
|
+
- Help with a project
|
|
251
|
+
- To suggest a development idea
|
|
252
|
+
|
|
253
|
+
Feel free to contact me via email:
|
|
254
|
+
|
|
255
|
+
pyputilframework@gmail.com
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Documentation
|
|
260
|
+
|
|
261
|
+
There is currently (version '0.1.0') no official documentation website for this package.
|
|
262
|
+
|
|
263
|
+
However, one may be added in the future when time allows.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Important Message
|
|
268
|
+
|
|
269
|
+
I LOVE YOU, MY USER!
|
|
270
|
+
"""
|
|
271
|
+
|
|
272
|
+
__version__ = "0.1.0"
|
|
273
|
+
__author__ = "Moamen Walid"
|
|
274
|
+
__license__ = "MIT"
|
|
275
|
+
__email__ = "pyputilframework@gmail.com"
|
|
276
|
+
__repository__ = "https://github.com/moamen-walid-pyputil/pyputil-install"
|
|
277
|
+
__issues__ = "https://github.com/moamen-walid-pyputil/pyputil-install/issues"
|
|
278
|
+
__all__ = [
|
|
279
|
+
"python_installer",
|
|
280
|
+
"pip_installer",
|
|
281
|
+
"auto_installer",
|
|
282
|
+
"pyheaders_installer",
|
|
283
|
+
"stdlib_installer",
|
|
284
|
+
"package_installer",
|
|
285
|
+
"compiler_installer",
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def get_doc() -> str:
|
|
290
|
+
"""
|
|
291
|
+
Display the package documentation to help the user.
|
|
292
|
+
"""
|
|
293
|
+
return __doc__
|
|
294
|
+
|
|
295
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Auto-Installer: Universal automatic package installation for Python.
|
|
3
|
+
|
|
4
|
+
Automatically installs missing Python packages via pip when an import
|
|
5
|
+
fails. Works with any package — no hardcoded allowlist required.
|
|
6
|
+
Supports both synchronous (blocking) and asynchronous (concurrent)
|
|
7
|
+
installation strategies.
|
|
8
|
+
|
|
9
|
+
Quick Start (Sync)
|
|
10
|
+
------------------
|
|
11
|
+
>>> from auto_installer import auto_install_sync
|
|
12
|
+
>>> auto_install_sync()
|
|
13
|
+
>>> import requests # installs immediately if missing
|
|
14
|
+
>>> import numpy as np # installs immediately if missing
|
|
15
|
+
|
|
16
|
+
Quick Start (Async — Deferred)
|
|
17
|
+
------------------------------
|
|
18
|
+
>>> from auto_installer import auto_install_async
|
|
19
|
+
>>> installer = await auto_install_async()
|
|
20
|
+
>>> import aiohttp # queued
|
|
21
|
+
>>> import httpx # queued
|
|
22
|
+
>>> await installer.install_all_pending() # installs both concurrently
|
|
23
|
+
|
|
24
|
+
Quick Start (Async — Immediate)
|
|
25
|
+
-------------------------------
|
|
26
|
+
>>> installer = await auto_install_async(immediate_mode=True)
|
|
27
|
+
>>> import aiohttp # async install starts immediately
|
|
28
|
+
>>> # ... do other work ...
|
|
29
|
+
>>> await installer.wait_all_tasks() # wait for installs to finish
|
|
30
|
+
|
|
31
|
+
Public API
|
|
32
|
+
----------
|
|
33
|
+
- ``auto_install_sync()`` — activate sync installer
|
|
34
|
+
- ``auto_install_async()`` — activate async installer
|
|
35
|
+
- ``SyncAutoInstaller`` — sync installer class
|
|
36
|
+
- ``AsyncAutoInstaller`` — async installer class
|
|
37
|
+
- ``add_pip_mapping()`` — register custom import→pip name mappings
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
from __future__ import annotations
|
|
41
|
+
|
|
42
|
+
# ---------------------------------------------------------------------------
|
|
43
|
+
# Public classes
|
|
44
|
+
# ---------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
from .core import AutoInstallerCore
|
|
47
|
+
from .sync import SyncAutoInstaller, auto_install_sync
|
|
48
|
+
from ._async import AsyncAutoInstaller, auto_install_async
|
|
49
|
+
|
|
50
|
+
# ---------------------------------------------------------------------------
|
|
51
|
+
# Public utility functions
|
|
52
|
+
# ---------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
from .utils import (
|
|
55
|
+
resolve_pip_name,
|
|
56
|
+
is_builtin,
|
|
57
|
+
is_stdlib,
|
|
58
|
+
is_system_module,
|
|
59
|
+
is_already_importable,
|
|
60
|
+
should_skip_install,
|
|
61
|
+
add_pip_mapping,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# ---------------------------------------------------------------------------
|
|
66
|
+
# Export list
|
|
67
|
+
# ---------------------------------------------------------------------------
|
|
68
|
+
|
|
69
|
+
__all__ = [
|
|
70
|
+
# ── Core ──────────────────────────────────────────────────────────
|
|
71
|
+
"AutoInstallerCore",
|
|
72
|
+
|
|
73
|
+
# ── Sync ──────────────────────────────────────────────────────────
|
|
74
|
+
"SyncAutoInstaller",
|
|
75
|
+
"auto_install_sync",
|
|
76
|
+
|
|
77
|
+
# ── Async ─────────────────────────────────────────────────────────
|
|
78
|
+
"AsyncAutoInstaller",
|
|
79
|
+
"auto_install_async",
|
|
80
|
+
|
|
81
|
+
# ── Utilities ─────────────────────────────────────────────────────
|
|
82
|
+
"resolve_pip_name",
|
|
83
|
+
"is_builtin",
|
|
84
|
+
"is_stdlib",
|
|
85
|
+
"is_system_module",
|
|
86
|
+
"is_already_importable",
|
|
87
|
+
"should_skip_install",
|
|
88
|
+
"add_pip_mapping",
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# ---------------------------------------------------------------------------
|
|
93
|
+
# Interactive convenience
|
|
94
|
+
# ---------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
def _interactive_activate() -> SyncAutoInstaller:
|
|
97
|
+
"""
|
|
98
|
+
Called when the module is executed directly (``python -m auto_installer``).
|
|
99
|
+
|
|
100
|
+
Activates the sync installer immediately for interactive use.
|
|
101
|
+
"""
|
|
102
|
+
print(
|
|
103
|
+
f"auto-installer v{__version__} activated for interactive session.\n"
|
|
104
|
+
f"Missing packages will be installed automatically on import."
|
|
105
|
+
)
|
|
106
|
+
return auto_install_sync()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if __name__ == "__main__":
|
|
110
|
+
_interactive_activate()
|