termux-diffusion 1.6.0__tar.gz → 1.6.2__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.
- {termux_diffusion-1.6.0/termux_diffusion.egg-info → termux_diffusion-1.6.2}/PKG-INFO +1 -1
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/pyproject.toml +1 -1
- termux_diffusion-1.6.2/termux_diffusion/_version.py +1 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/installer.py +88 -21
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2/termux_diffusion.egg-info}/PKG-INFO +1 -1
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/tests/test_installer.py +22 -0
- termux_diffusion-1.6.0/termux_diffusion/_version.py +0 -1
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/LICENSE +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/README.md +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/setup.cfg +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/setup.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/__init__.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/adapter.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/cli.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/control/__init__.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/control/component.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/control/status.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/core.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/data/bootstrap-manifest.json +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/data/release-public-keys.json +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/data/validated-vulkan-profiles.json +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/downloader.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/exceptions.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/hardware.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/hub.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/locking.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/manifest.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/npu.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/platform.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/py.typed +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/selftest.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion.egg-info/SOURCES.txt +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion.egg-info/dependency_links.txt +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion.egg-info/entry_points.txt +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion.egg-info/requires.txt +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion.egg-info/top_level.txt +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/tests/test_core.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/tests/test_hardware.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/tests/test_hub.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/tests/test_npu.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/tests/test_platform.py +0 -0
- {termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/tests/test_presets.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: termux-diffusion
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.2
|
|
4
4
|
Summary: On-device Stable Diffusion runtime utilizing device resources for Android Termux & Samsung Galaxy (Dual-Engine Python & Node.js)
|
|
5
5
|
Home-page: https://github.com/uno-km/termux-diffusion
|
|
6
6
|
Author: uno-km (AMEVA Foundation)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "termux-diffusion"
|
|
7
|
-
version = "1.6.
|
|
7
|
+
version = "1.6.2"
|
|
8
8
|
description = "On-device Stable Diffusion runtime utilizing device resources for Android Termux & Samsung Galaxy (Dual-Engine Python & Node.js)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.6.2"
|
|
@@ -33,10 +33,42 @@ from .platform import (
|
|
|
33
33
|
is_arm64,
|
|
34
34
|
)
|
|
35
35
|
|
|
36
|
+
from ._version import __version__
|
|
37
|
+
|
|
36
38
|
logger = logging.getLogger("termux_diffusion.installer")
|
|
37
39
|
|
|
38
40
|
SD_CPP_REPO = "https://github.com/leejet/stable-diffusion.cpp"
|
|
39
|
-
|
|
41
|
+
|
|
42
|
+
AMEVA_RUNTIME_RELEASE_LATEST = "https://github.com/uno-km/ameva-runtime/releases/latest/download"
|
|
43
|
+
TERMUX_DIFFUSION_RELEASE_LATEST = "https://github.com/uno-km/termux-diffusion/releases/latest/download"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def get_prebuilt_base_url() -> str:
|
|
47
|
+
"""Resolve dynamic base URL for prebuilt binary assets."""
|
|
48
|
+
if custom := os.environ.get("TERMUX_DIFFUSION_RELEASE_BASE") or os.environ.get("AMEVA_RELEASE_BASE"):
|
|
49
|
+
return custom.rstrip("/")
|
|
50
|
+
if custom_tag := os.environ.get("TERMUX_DIFFUSION_RELEASE_TAG") or os.environ.get("AMEVA_RELEASE_TAG"):
|
|
51
|
+
tag = custom_tag if custom_tag.startswith("v") else f"v{custom_tag}"
|
|
52
|
+
return f"https://github.com/uno-km/termux-diffusion/releases/download/{tag}"
|
|
53
|
+
return f"https://github.com/uno-km/termux-diffusion/releases/download/v{__version__}"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
PREBUILT_BASE_URL = get_prebuilt_base_url()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def get_candidate_prebuilt_urls(filename: str = "sd-cli-vulkan-android-arm64.tar.gz") -> List[str]:
|
|
60
|
+
"""Resolve prioritized candidate URLs for downloading prebuilt engine packages."""
|
|
61
|
+
urls: List[str] = []
|
|
62
|
+
if custom_base := os.environ.get("TERMUX_DIFFUSION_RELEASE_BASE") or os.environ.get("AMEVA_RELEASE_BASE"):
|
|
63
|
+
urls.append(f"{custom_base.rstrip('/')}/{filename}")
|
|
64
|
+
if custom_tag := os.environ.get("TERMUX_DIFFUSION_RELEASE_TAG") or os.environ.get("AMEVA_RELEASE_TAG"):
|
|
65
|
+
tag = custom_tag if custom_tag.startswith("v") else f"v{custom_tag}"
|
|
66
|
+
urls.append(f"https://github.com/uno-km/termux-diffusion/releases/download/{tag}/{filename}")
|
|
67
|
+
urls.append(f"https://github.com/uno-km/ameva-runtime/releases/download/{tag}/{filename}")
|
|
68
|
+
urls.append(f"https://github.com/uno-km/termux-diffusion/releases/download/v{__version__}/{filename}")
|
|
69
|
+
urls.append(f"{TERMUX_DIFFUSION_RELEASE_LATEST}/{filename}")
|
|
70
|
+
urls.append(f"{AMEVA_RUNTIME_RELEASE_LATEST}/{filename}")
|
|
71
|
+
return urls
|
|
40
72
|
|
|
41
73
|
|
|
42
74
|
import uuid
|
|
@@ -103,37 +135,55 @@ def fetch_prebuilt_binary(backend: str = "auto", install_mode: str = "prebuilt-f
|
|
|
103
135
|
lock_file = get_default_cache_dir() / "install.lock"
|
|
104
136
|
|
|
105
137
|
with InstallLock(lock_file, timeout_sec=5.0):
|
|
106
|
-
# 1. Try Vulkan Prebuilt (Multi-SoC Aware: Adreno vs Mali via validated profiles)
|
|
138
|
+
# 1. Try Vulkan Prebuilt (Multi-SoC Aware: Adreno vs Mali via validated profiles and SSOT endpoints)
|
|
107
139
|
if backend in ("auto", "vulkan"):
|
|
108
140
|
vulkan_bin = bin_dir / "sd-cli-vulkan"
|
|
109
141
|
print("[termux-diffusion] Attempting Prebuilt Vulkan Engine installation...")
|
|
110
142
|
try:
|
|
143
|
+
# First: Check if ameva-runtime NativeAssetManager is available and can provision
|
|
144
|
+
try:
|
|
145
|
+
from ameva_runtime.installer import provision_native_assets
|
|
146
|
+
results = provision_native_assets(modalities=["diffusion"], force=False)
|
|
147
|
+
if results.get("diffusion") and (bin_dir / "sd-cli-vulkan").is_file():
|
|
148
|
+
active = activate_binary(bin_dir, "sd-cli-vulkan")
|
|
149
|
+
return active
|
|
150
|
+
except Exception as ameva_err:
|
|
151
|
+
logger.debug("NativeAssetManager delegation skipped: %s", ameva_err)
|
|
152
|
+
|
|
111
153
|
if not vulkan_bin.is_file():
|
|
112
154
|
from .hardware import detect_hardware_profile, get_profile_gating_manager, _detect_device_model
|
|
113
155
|
hw = detect_hardware_profile()
|
|
114
156
|
gating_mgr = get_profile_gating_manager()
|
|
115
157
|
dev_model = _detect_device_model()
|
|
116
158
|
matched = gating_mgr.find_matching_profile(dev_model, hw.soc_name, hw.gpu_name)
|
|
117
|
-
|
|
159
|
+
|
|
160
|
+
candidate_urls: List[str] = []
|
|
161
|
+
expected_sha256 = None
|
|
118
162
|
if matched and matched.get("package_tarball") and matched.get("package_sha256"):
|
|
119
|
-
pkg_tag = matched.get("package_tag"
|
|
163
|
+
pkg_tag = matched.get("package_tag")
|
|
120
164
|
pkg_tarball = matched.get("package_tarball")
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
pkg_sha256 = "65e4e305241b22385313e386afbcd12722061041280d00a44dfdc3ff23aa17b8"
|
|
128
|
-
else:
|
|
129
|
-
pkg_url = "https://github.com/uno-km/termux-diffusion/releases/download/v1.3.1-vulkan-experimental/termux-diffusion-vulkan-prebuilt-v1.3.1-android-arm64-adreno.tar.gz"
|
|
130
|
-
pkg_sha256 = "d1f0a2656a33d0929cfd3335e01feeabf9c3a1e34a0ae0eacc04ddb3701ece92"
|
|
165
|
+
if pkg_tag:
|
|
166
|
+
candidate_urls.append(f"https://github.com/uno-km/termux-diffusion/releases/download/{pkg_tag}/{pkg_tarball}")
|
|
167
|
+
expected_sha256 = matched.get("package_sha256")
|
|
168
|
+
|
|
169
|
+
# Extend with dynamic SSOT endpoints for universal prebuilt bundle
|
|
170
|
+
candidate_urls.extend(get_candidate_prebuilt_urls("sd-cli-vulkan-android-arm64.tar.gz"))
|
|
131
171
|
|
|
132
172
|
tar_dest = bin_dir / "vulkan-prebuilt.tar.gz"
|
|
133
|
-
|
|
134
|
-
|
|
173
|
+
downloaded = False
|
|
174
|
+
for pkg_url in candidate_urls:
|
|
175
|
+
try:
|
|
176
|
+
print(f"[termux-diffusion] Downloading prebuilt binary from: {pkg_url} ...")
|
|
177
|
+
sha_check = expected_sha256 if (expected_sha256 and pkg_url == candidate_urls[0]) else None
|
|
178
|
+
atomic_download_file(pkg_url, tar_dest, expected_sha256=sha_check)
|
|
179
|
+
downloaded = True
|
|
180
|
+
break
|
|
181
|
+
except Exception as dl_err:
|
|
182
|
+
logger.debug("Vulkan prebuilt download candidate failed from %s: %s", pkg_url, dl_err)
|
|
183
|
+
|
|
184
|
+
if downloaded and tar_dest.is_file():
|
|
135
185
|
import tarfile
|
|
136
|
-
extract_target =
|
|
186
|
+
extract_target = bin_dir
|
|
137
187
|
with tarfile.open(tar_dest, "r:gz") as tar:
|
|
138
188
|
# 경로 탈출(Directory Traversal) 방지 검증
|
|
139
189
|
for member in tar.getmembers():
|
|
@@ -147,15 +197,32 @@ def fetch_prebuilt_binary(backend: str = "auto", install_mode: str = "prebuilt-f
|
|
|
147
197
|
)
|
|
148
198
|
tar.extractall(path=extract_target)
|
|
149
199
|
tar_dest.unlink(missing_ok=True)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
200
|
+
|
|
201
|
+
# Check extracted binary and set mode
|
|
202
|
+
if vulkan_bin.is_file():
|
|
203
|
+
vulkan_bin.chmod(0o755)
|
|
204
|
+
elif (bin_dir / "sd-cli").is_file():
|
|
205
|
+
(bin_dir / "sd-cli").chmod(0o755)
|
|
206
|
+
shutil.copy2(bin_dir / "sd-cli", vulkan_bin)
|
|
207
|
+
vulkan_bin.chmod(0o755)
|
|
208
|
+
|
|
209
|
+
# Deploy companion libraries if extracted
|
|
210
|
+
lib_dir = get_default_cache_dir() / "lib"
|
|
211
|
+
lib_dir.mkdir(parents=True, exist_ok=True)
|
|
212
|
+
for shlib in ("libegl_shim.so", "libomp.so"):
|
|
213
|
+
shlib_src = bin_dir / shlib
|
|
214
|
+
if shlib_src.is_file():
|
|
215
|
+
shutil.copy2(shlib_src, lib_dir / shlib)
|
|
216
|
+
local_lib = Path(os.path.expanduser("~/.local/lib"))
|
|
217
|
+
local_lib.mkdir(parents=True, exist_ok=True)
|
|
218
|
+
shutil.copy2(shlib_src, local_lib / shlib)
|
|
154
219
|
|
|
155
220
|
if vulkan_bin.is_file() and run_binary_self_test(vulkan_bin, expected_backend="vulkan").stage1_load_passed:
|
|
156
221
|
active = activate_binary(bin_dir, "sd-cli-vulkan")
|
|
157
222
|
print("[termux-diffusion] Fast-Track: Prebuilt Vulkan binary validated and activated.")
|
|
158
223
|
return active
|
|
224
|
+
except ProvisioningError:
|
|
225
|
+
raise
|
|
159
226
|
except Exception as exc:
|
|
160
227
|
logger.debug("Vulkan prebuilt attempt failed: %s", exc)
|
|
161
228
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: termux-diffusion
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.2
|
|
4
4
|
Summary: On-device Stable Diffusion runtime utilizing device resources for Android Termux & Samsung Galaxy (Dual-Engine Python & Node.js)
|
|
5
5
|
Home-page: https://github.com/uno-km/termux-diffusion
|
|
6
6
|
Author: uno-km (AMEVA Foundation)
|
|
@@ -76,3 +76,25 @@ def test_mutually_exclusive_install_options_fail():
|
|
|
76
76
|
with pytest.raises(SystemExit) as exc:
|
|
77
77
|
run_install_cli(["--prebuilt-only", "--build-from-source"])
|
|
78
78
|
assert exc.value.code == ExitCode.CLI_ERROR
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_prebuilt_dynamic_urls_and_env_override():
|
|
82
|
+
from termux_diffusion.installer import get_prebuilt_base_url, get_candidate_prebuilt_urls
|
|
83
|
+
from termux_diffusion._version import __version__
|
|
84
|
+
|
|
85
|
+
with patch.dict(os.environ, {}, clear=True):
|
|
86
|
+
os.environ.pop("TERMUX_DIFFUSION_RELEASE_BASE", None)
|
|
87
|
+
os.environ.pop("AMEVA_RELEASE_BASE", None)
|
|
88
|
+
base = get_prebuilt_base_url()
|
|
89
|
+
assert f"v{__version__}" in base
|
|
90
|
+
assert "v1.3.1" not in base
|
|
91
|
+
|
|
92
|
+
urls = get_candidate_prebuilt_urls("sd-cli-vulkan-android-arm64.tar.gz")
|
|
93
|
+
assert any(f"v{__version__}" in u for u in urls)
|
|
94
|
+
assert any("releases/latest/download" in u for u in urls)
|
|
95
|
+
assert not any("v1.3.1" in u for u in urls)
|
|
96
|
+
|
|
97
|
+
with patch.dict(os.environ, {"TERMUX_DIFFUSION_RELEASE_TAG": "v2.5.0"}):
|
|
98
|
+
base_override = get_prebuilt_base_url()
|
|
99
|
+
assert "v2.5.0" in base_override
|
|
100
|
+
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.6.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/data/bootstrap-manifest.json
RENAMED
|
File without changes
|
{termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion/data/release-public-keys.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{termux_diffusion-1.6.0 → termux_diffusion-1.6.2}/termux_diffusion.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|