Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Download uv through verified PyPI mirrors on Windows (#9)
Bowen Xue01ce2c71d3f6
diff --git a/freevideo.ps1 b/freevideo.ps1index 30605b4..ecaa21f 100644--- a/freevideo.ps1+++ b/freevideo.ps1@@ -78,10 +78,6 @@ try {try {$versions = Get-Content -LiteralPath (Join-Path $PSScriptRoot 'freevideo_engine\bootstrap_versions.json') -Raw -Encoding UTF8 | ConvertFrom-Json$uvSpec = $versions.windows.uv- $archive = Join-Path $bootstrapRoot 'uv.zip'- $partial = "$archive.partial"- $curl = Get-Command curl.exe -ErrorAction SilentlyContinue- if (-not $curl) { throw 'curl.exe is missing. Repair the Windows curl installation, or install Python 3.9+ and rerun.' }$officialOnly = $freevideoArguments -contains '--network=official'for ($i = 0; $i -lt $freevideoArguments.Count - 1; $i++) {if ($freevideoArguments[$i] -eq '--network' -and $freevideoArguments[$i + 1] -eq 'official') { $officialOnly = $true }@@ -91,34 +87,10 @@ try {$proxyRoutes = @('inherited')if ($env:FREEVIDEO_PROXY_MODE -eq 'direct') { $proxyRoutes = @('direct') }elseif ($env:FREEVIDEO_PROXY_MODE -ne 'proxy' -and ($env:HTTP_PROXY -or $env:HTTPS_PROXY -or $env:ALL_PROXY)) { $proxyRoutes += 'direct' }- $valid = (Test-Path -LiteralPath $archive) -and ((Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash -eq $uvSpec.sha256)- if (-not $valid -and (Test-Path -LiteralPath $archive)) {- Move-Item -LiteralPath $archive -Destination "$archive.rejected-$([DateTime]::UtcNow.Ticks)"- }- foreach ($route in $routes) {- foreach ($proxyRoute in $proxyRoutes) {- if ($valid) { break }- $url = $uvSpec.url.Replace('https://github.com', $route)- Write-Progress -Activity 'FreeVideo bootstrap' -Status 'Download and verify package manager'- $curlArgs = @('--disable', '--fail', '--location', '--silent', '--show-error',- '--proto', '=https', '--proto-redir', '=https', '--connect-timeout', '5',- '--max-time', '120', '--retry', '1', '--speed-limit', '1024', '--speed-time', '20',- '--output', $partial, $url)- $curlExit = Invoke-FreeVideoBootstrapCommand -Executable $curl.Source -Arguments $curlArgs `- -LogPath $bootstrapLog -Label "Download package manager ($proxyRoute connection)" -Direct:($proxyRoute -eq 'direct')- if ($curlExit -eq 0 -and (Test-Path -LiteralPath $partial) -and- (Get-FileHash -LiteralPath $partial -Algorithm SHA256).Hash -eq $uvSpec.sha256) {- Move-Item -LiteralPath $partial -Destination $archive- $valid = $true- } elseif (Test-Path -LiteralPath $partial) {- Move-Item -LiteralPath $partial -Destination "$partial.retained-$([DateTime]::UtcNow.Ticks)"- }- }- }- if (-not $valid) { throw "Package manager download failed integrity/network checks. Retry the same command; see $bootstrapLog" }- $toolsDirectory = Join-Path $bootstrapRoot ('uv-' + $uvSpec.version)- Expand-Archive -LiteralPath $archive -DestinationPath $toolsDirectory -Force- $uv = Join-Path $toolsDirectory $uvSpec.executable+ $uvCatalog = Get-Content -LiteralPath (Join-Path $PSScriptRoot 'freevideo_engine\uv_downloads.json') -Raw -Encoding UTF8 | ConvertFrom-Json+ $uv = Get-FreeVideoUv -Spec $uvSpec -Catalog $uvCatalog -BootstrapRoot $bootstrapRoot `+ -EngineRoot $freevideoRoot -LogPath $bootstrapLog -GithubSources $routes `+ -ProxyRoutes $proxyRoutes -OfficialOnly:$officialOnly$env:UV_PYTHON_INSTALL_DIR = Join-Path $bootstrapRoot 'python'$env:UV_HTTP_TIMEOUT = '20'$env:UV_HTTP_RETRIES = '1'diff --git a/freevideo_engine/bootstrap.py b/freevideo_engine/bootstrap.pyindex 3a225f6..71b02e2 100644--- a/freevideo_engine/bootstrap.py+++ b/freevideo_engine/bootstrap.py@@ -812,21 +812,39 @@ class Installer:self.monitor_thread = threading.Thread(target=sample, name='setup-memory', daemon=True)self.monitor_thread.start()- def fetch(self, url, path, sha):+ def fetch(self, url, path, sha, *, size=None, candidates=None, category=None,+ low_speed_limit=1024, max_seconds=None, cycles=2):key = 'download-' + path.nametitle = ('Prepare download tools' if path.name.startswith('uv') else'Download GPU acceleration' if path.suffix == '.whl' else'Prepare Git' if 'git' in path.name.lower() else 'Download CUDA build tools')- self.ui.begin(key, title, detail=path.name if self.ui.verbose else 'Download and verify required files')+ self.ui.begin(key, title, detail=path.name if self.ui.verbose or candidates is not None else 'Download and verify required files')+ transfer = {}+ def source_detail():+ names = {'pypi': {'official': 'PyPI', 'tuna': 'Tsinghua mirror'},+ 'github': {'official': 'GitHub', 'ghfast': 'GitHub mirror'}}+ source = names.get(category, {}).get(transfer.get('source'), transfer.get('source', ''))+ return ' · Source: ' + source if source else ''def progress(done, total, speed):if self.cancel.is_set():raise RuntimeError('Installation cancelled; partial download retained.')+ rate_text = ('%.1f KiB/s' % (speed/1024) if speed < 2**20 else '%.1f MiB/s' % (speed/2**20))self.ui.update(key, done=done, total=total, rate=speed, unit='bytes', scope=path.name,- detail=('%.1f MiB / %.1f MiB' % (done/2**20, total/2**20) if total else '%.1f MiB downloaded' % (done/2**20)) + ' · %.1f MiB/s' % (speed/2**20))+ detail=(path.name + ' · ' if candidates is not None else '') ++ ('%.1f MiB / %.1f MiB' % (done/2**20, total/2**20) if total else '%.1f MiB downloaded' % (done/2**20)) ++ ' · ' + rate_text + source_detail())try:- feedback = lambda row: self.ui.update(key, detail='Source: %s · %s%s' %- (row['source'], row['action'], ' · ' + row['reason'] if row.get('reason') else ''))- download(url, path, sha, progress, networking=dict(self.network, event_callback=feedback), env=self.env)+ def feedback(row):+ transfer.update(row)+ self.ui.update(key, detail=path.name + source_detail() + ' · ' + row['action'] ++ (' · ' + row['reason'] if row.get('reason') else ''))+ networking = dict(self.network, event_callback=feedback)+ if candidates is None:+ download(url, path, sha, progress, networking=networking, env=self.env)+ else:+ network.download(candidates, path, sha, progress, network=networking, env=self.env,+ size=size, category=category or 'download',+ low_speed_limit=low_speed_limit, max_seconds=max_seconds, cycles=cycles)except BaseException:self.ui.end(key, success=False)raise@@ -1162,21 +1180,24 @@ class Installer:return toolkitdef execute(self):- self.ui.phase('Prepare Python', 0, 8)+ self.ui.phase('Prepare download tools', 0, 8)uv_spec = self.versions['uv']- archive = self.root / 'downloads' / ('uv-windows.zip' if self.system == 'Windows' else 'uv.tar.gz')- from .system import bootstrap_root- previous = bootstrap_root(self.root) / ('uv.zip' if self.system == 'Windows' else 'uv-' + uv_spec['version'] + '.tar.gz')- if not archive.exists() and previous.is_file() and digest(previous) == uv_spec['sha256']:- archive.parent.mkdir(parents=True, exist_ok=True)- try:- os.link(previous, archive)- except OSError:- shutil.copyfile(previous, archive)- self.fetch(uv_spec['url'], archive, uv_spec['sha256'])- unpack(archive, self.root / 'tools')- uv = (self.root / 'tools' / uv_spec['executable'] if self.system == 'Windows' else- self.root / 'tools' / 'uv-x86_64-unknown-linux-gnu' / 'uv')+ if self.system == 'Windows':+ from .uv_bootstrap import prepare_windows+ uv = prepare_windows(self.root, uv_spec, self.network, self.env, self.fetch)+ else:+ archive = self.root / 'downloads' / 'uv.tar.gz'+ from .system import bootstrap_root+ previous = bootstrap_root(self.root) / ('uv-' + uv_spec['version'] + '.tar.gz')+ if not archive.exists() and previous.is_file() and digest(previous) == uv_spec['sha256']:+ archive.parent.mkdir(parents=True, exist_ok=True)+ try:+ os.link(previous, archive)+ except OSError:+ shutil.copyfile(previous, archive)+ self.fetch(uv_spec['url'], archive, uv_spec['sha256'])+ unpack(archive, self.root / 'tools')+ uv = self.root / 'tools' / 'uv-x86_64-unknown-linux-gnu' / 'uv'self.env['FREEVIDEO_UV'] = str(uv)from .install_schedule import runtasks, pythons, comfy = self.component_tasks(uv)diff --git a/freevideo_engine/launcher_copy.py b/freevideo_engine/launcher_copy.pyindex c78b01f..95add5a 100644--- a/freevideo_engine/launcher_copy.py+++ b/freevideo_engine/launcher_copy.py@@ -12,6 +12,10 @@ SOURCES = {ZH = dict([('Prepare Python', '准备 Python'), ('Install Python', '安装 Python'),+ ('Prepare download tools', '准备下载工具'), ('Tsinghua mirror', '清华镜像'),+ ('GitHub mirror', 'GitHub 镜像'), ('attempt', '正在连接'),+ ('fallback', '正在切换下载源'), ('route-retry', '正在切换连接'),+ ('verifying', '正在校验'), ('no-progress', '下载无进展'),('Use existing Python', '复用 Python'), ('Create Python environment', '创建运行环境'),('Install PyTorch + CUDA', '安装 GPU 运行环境'),('Install engine dependencies', '安装生成组件'), ('Install encoder support', '安装编码组件'),diff --git a/freevideo_engine/network.py b/freevideo_engine/network.pyindex f1cb0ea..036bfbe 100644--- a/freevideo_engine/network.py+++ b/freevideo_engine/network.py@@ -4,6 +4,7 @@ Only curl and Python stdlib are needed before setup. Proxy and direct routes arecompared without changing user settings. Reports never include proxy credentials."""from concurrent.futures import ThreadPoolExecutor, as_completed+from collections import dequeimport hashlibimport htmlimport json@@ -649,8 +650,13 @@ def pause_download(network, name, path, retained, reason, *, details=None):(Path(path).name, reason, explanation))+class DownloadError(RuntimeError):+ """Every permitted source failed; an alternate artifact may be tried."""++def download(candidates, path, expected, progress=None, *, network=None, env=None, size=None,- algorithm='sha256', git_blob=False, headers_for=None, stall_seconds=None, category='download'):+ algorithm='sha256', git_blob=False, headers_for=None, stall_seconds=None, category='download',+ low_speed_limit=1024, max_seconds=None, cycles=2):"""Resume across ranked sources; hash before accepting, retain rejected bytes."""network = network or {}path = Path(path)@@ -691,7 +697,7 @@ def download(candidates, path, expected, progress=None, *, network=None, env=Nonpass# Try the next ranked candidate promptly. The final candidate gets bounded# retries; every mirror must honor the retained prefix, with no silent reset.- for cycle in range(2):+ for cycle in range(cycles):for candidate_index, (name, url, route) in enumerate(candidates):for restart in range(3 if model else 2):offset = partial.stat().st_size if partial.exists() else 0@@ -711,7 +717,9 @@ def download(candidates, path, expected, progress=None, *, network=None, env=Nonattempt_env = route_environment(network, category, name, env, route)command = curl_command(timeout, attempt_env) + ['--output', str(partial), '--write-out', '%{http_code}']if not model:- command += ['--speed-limit', '1024', '--speed-time', str(stall_seconds)]+ command += ['--speed-limit', str(low_speed_limit), '--speed-time', str(stall_seconds)]+ if max_seconds is not None:+ command += ['--max-time', str(max_seconds)]if url.startswith('https://'):command += ['--proto-redir', '=https']if size:@@ -730,6 +738,7 @@ def download(candidates, path, expected, progress=None, *, network=None, env=Nonoversized = Nonestalled = Falselast_body, previous_done = started, offset+ recent = deque([(started, offset)])try:process.stdin.write(curl_config(url, headers_for(name) if headers_for else ()))process.stdin.close()@@ -740,7 +749,8 @@ def download(candidates, path, expected, progress=None, *, network=None, env=Nonif done > previous_done:previous_done, last_body = done, time.monotonic()remember_source()- if model and time.monotonic()-last_body > stall_seconds:+ now = time.monotonic()+ if now-last_body > stall_seconds:stalled = Truebreakif size is not None and done > size:@@ -750,7 +760,10 @@ def download(candidates, path, expected, progress=None, *, network=None, env=Nonoversized = donebreakif progress:- progress(done, size or 0, max(0, done - offset) / max(.001, time.monotonic() - started))+ recent.append((now, done))+ while len(recent) > 2 and recent[1][0] < now - 5:+ recent.popleft()+ progress(done, size or 0, max(0, done - recent[0][1]) / max(.001, now - recent[0][0]))try:process.wait(timeout=.25)except subprocess.TimeoutExpired:@@ -803,10 +816,10 @@ def download(candidates, path, expected, progress=None, *, network=None, env=Nonalternatives = route_order(network, category, name, env)if alternatives.index(route) + 1 < len(alternatives):event(network, category=category, source=name, route=alternatives[alternatives.index(route)+1],- file=path.name, action='route-retry', reason='curl-' + str(process.returncode), resume_bytes=current_size)+ file=path.name, action='route-retry', reason='no-progress' if stalled else 'curl-' + str(process.returncode), resume_bytes=current_size)else:source_health(network, category, name, False)- event(network, category=category, source=name, route=route, file=path.name, action='fallback', reason='curl-' + str(process.returncode), http_status=status)+ event(network, category=category, source=name, route=route, file=path.name, action='fallback', reason='no-progress' if stalled else 'curl-' + str(process.returncode), http_status=status)breakif model and partial.exists() and partial.stat().st_size:if not network.get('allow_model_restart'):@@ -814,7 +827,7 @@ def download(candidates, path, expected, progress=None, *, network=None, env=Nonevent(network, category=category, source=name, file=path.name, action='restart-approved',retained_bytes=partial.stat().st_size, reason='resume-unavailable')retain_partial(partial, 'restart-approved')- raise RuntimeError('Every download source failed for %s. Check your network or choose another connection mode in Downloads. Partial files retained' % path.name)+ raise DownloadError('Every download source failed for %s. Check your network or choose another connection mode in Downloads. Partial files retained' % path.name)def clone(target, url, commit, *, sparse=None, run=None, network=None, env=None):diff --git a/freevideo_engine/uv_bootstrap.py b/freevideo_engine/uv_bootstrap.pynew file mode 100644index 0000000..1ea4233--- /dev/null+++ b/freevideo_engine/uv_bootstrap.py@@ -0,0 +1,100 @@+"""Acquire the pinned Windows tool without requiring pip or adding launcher bytes."""+import json+import os+from pathlib import Path+import re+import shutil+import zipfile++from . import network+++def wheel_spec(uv):+ catalog = json.loads(Path(__file__).with_name('uv_downloads.json').read_text(encoding='utf-8'))+ if catalog['version'] != uv['version'] or catalog['windows']['legacy_sha256'] != uv['sha256']:+ raise ValueError('The uv download catalog does not match the pinned bootstrap version')+ return catalog['windows']+++def wheel_url(wheel, name, timeout, env):+ if name in wheel['sources']:+ return wheel['sources'][name]+ return network.wheel_link(network.source_url('pypi', name, env) + '/uv/',+ '^' + re.escape(wheel['filename']) + '$', timeout, env)+++def verified(path, sha, size):+ return path.is_file() and path.stat().st_size == size and network.hash_file(path) == sha+++def extract(archive, destination, member, size=None):+ """Only extract the pinned executable, with bounded memory and atomic replacement."""+ destination.parent.mkdir(parents=True, exist_ok=True)+ temporary = destination.with_name(destination.name + '.partial')+ with zipfile.ZipFile(archive) as source:+ info = source.getinfo(member)+ if size is not None and info.file_size != size:+ raise ValueError('Unexpected uv executable size in the verified archive')+ with source.open(info) as incoming, temporary.open('wb') as outgoing:+ shutil.copyfileobj(incoming, outgoing, 1024 * 1024)+ os.replace(temporary, destination)+ return destination+++def prepare_windows(root, uv, networking, env, fetch):+ from .system import bootstrap_root+ root = Path(root)+ bootstrap = bootstrap_root(root)+ wheel = wheel_spec(uv)+ destination = root / 'tools' / uv['executable']+ variants = [+ (wheel, wheel['executable'], [root / 'downloads' / wheel['filename'], bootstrap / wheel['filename']]),+ (dict(bytes=wheel['legacy_bytes'], sha256=uv['sha256']), uv['executable'],+ [root / 'downloads' / 'uv-windows.zip', bootstrap / 'uv.zip']),+ ]+ # Inspect both formats before contacting any server. A fully downloaded+ # .partial from an interrupted final publication is also reusable.+ for artifact, member, paths in variants:+ for path in paths:+ for candidate in (path, path.with_name(path.name + '.partial')):+ if verified(candidate, artifact['sha256'], artifact['bytes']):+ return extract(candidate, destination, member, artifact.get('executable_bytes'))++ candidates = []+ names = network.ordered(networking, 'pypi')+ if not networking.get('sources', {}).get('pypi') and networking.get('mode') != 'official':+ names = list(wheel['sources'])+ for name in names:+ # Built-in mirrors use pinned artifact URLs, so no index/pip/Python+ # installation is needed. Custom indexes still retain their semantics.+ for route in network.route_order(networking, 'pypi', name, env):+ try:+ address = wheel_url(wheel, name, networking.get('timeout_seconds', 5),+ network.route_environment(networking, 'pypi', name, env, route))+ candidates.append((name, address))+ break+ except (OSError, ValueError, RuntimeError):+ network.event(networking, category='pypi', source=name, route=route,+ file=wheel['filename'], action='fallback', reason='wheel-index-unavailable')++ attempts = [+ (wheel, root / 'downloads' / wheel['filename'], wheel['executable'], candidates, 'pypi'),+ (dict(bytes=wheel['legacy_bytes'], sha256=uv['sha256']), root / 'downloads' / 'uv-windows.zip',+ uv['executable'], network.urls(networking, 'github', uv['url'], env), 'github'),+ ]+ for index, (artifact, archive, member, sources, family) in enumerate(attempts):+ if not sources:+ continue+ # Retain an invalid completed tool archive rather than blocking repair.+ # Wheel and release ZIP partials never share a path or a hash.+ if archive.exists():+ network.retain_partial(archive, 'hash-rejected')+ try:+ fetch(sources[0][1], archive, artifact['sha256'], size=artifact['bytes'],+ candidates=sources, category=family, low_speed_limit=32 * 1024, max_seconds=180, cycles=1)+ except network.DownloadError:+ if index + 1 == len(attempts):+ raise+ continue+ return extract(archive, destination, member, artifact.get('executable_bytes'))+ raise network.DownloadError('No uv download source is available; cached files retained')diff --git a/freevideo_engine/uv_downloads.json b/freevideo_engine/uv_downloads.jsonnew file mode 100644index 0000000..21420bc--- /dev/null+++ b/freevideo_engine/uv_downloads.json@@ -0,0 +1,17 @@+{+ "schema": 1,+ "version": "0.9.0",+ "windows": {+ "filename": "uv-0.9.0-py3-none-win_amd64.whl",+ "bytes": 21387424,+ "sha256": "ee5969cef61e8eef251ee14e573fa22b42bbe90a2d194b6de6d794baee176a9b",+ "executable": "uv-0.9.0.data/scripts/uv.exe",+ "executable_bytes": 60162048,+ "sources": {+ "official": "https://files.pythonhosted.org/packages/60/cd/98242bb85c92a06156ebfead3c3c9126e8dbb7872808b11a76428b9aaf4a/uv-0.9.0-py3-none-win_amd64.whl",+ "tuna": "https://pypi.tuna.tsinghua.edu.cn/packages/60/cd/98242bb85c92a06156ebfead3c3c9126e8dbb7872808b11a76428b9aaf4a/uv-0.9.0-py3-none-win_amd64.whl"+ },+ "legacy_bytes": 20742706,+ "legacy_sha256": "4bad2c47dafb52ad774072fb7a260e5c9f3dbf73441658db1128eb2aec5818eb"+ }+}diff --git a/freevideo_engine/windows_bootstrap.ps1 b/freevideo_engine/windows_bootstrap.ps1index 6cd0035..224b7af 100644--- a/freevideo_engine/windows_bootstrap.ps1+++ b/freevideo_engine/windows_bootstrap.ps1@@ -53,3 +53,130 @@ function Invoke-FreeVideoBootstrapCommand {$log.Dispose()}}++function Test-FreeVideoUvArchive {+ param([string]$Path, [string]$Hash, [long]$Bytes)+ return ((Test-Path -LiteralPath $Path -PathType Leaf) -and+ (Get-Item -LiteralPath $Path).Length -eq $Bytes -and+ (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash -eq $Hash)+}++function Expand-FreeVideoUv {+ param([string]$Archive, [string]$Member, [string]$Destination)+ Add-Type -AssemblyName System.IO.Compression.FileSystem+ [IO.Directory]::CreateDirectory((Split-Path -Parent $Destination)) | Out-Null+ $zip = [IO.Compression.ZipFile]::OpenRead($Archive)+ try {+ $entry = $zip.GetEntry($Member)+ if (-not $entry) { throw 'The verified uv archive is missing its executable' }+ [IO.Compression.ZipFileExtensions]::ExtractToFile($entry, "$Destination.partial", $true)+ } finally { $zip.Dispose() }+ Move-Item -LiteralPath "$Destination.partial" -Destination $Destination -Force+ return $Destination+}++function Get-FreeVideoUv {+ param($Spec, $Catalog, [string]$BootstrapRoot, [string]$EngineRoot,+ [string]$LogPath, [string[]]$GithubSources, [string[]]$ProxyRoutes,+ [switch]$OfficialOnly)+ $wheel = $Catalog.windows+ if ($Catalog.version -ne $Spec.version -or $wheel.legacy_sha256 -ne $Spec.sha256) {+ throw 'The uv download catalog does not match the pinned bootstrap version'+ }+ $destination = Join-Path $BootstrapRoot ('uv-' + $Spec.version + '\uv.exe')+ $artifacts = @(+ [pscustomobject]@{Name=$wheel.filename; Hash=$wheel.sha256; Bytes=$wheel.bytes; Member=$wheel.executable;+ Paths=@((Join-Path $BootstrapRoot $wheel.filename), (Join-Path $EngineRoot ('downloads\' + $wheel.filename)))},+ [pscustomobject]@{Name='uv.zip'; Hash=$Spec.sha256; Bytes=$wheel.legacy_bytes; Member=$Spec.executable;+ Paths=@((Join-Path $BootstrapRoot 'uv.zip'), (Join-Path $EngineRoot 'downloads\uv-windows.zip'))}+ )+ foreach ($artifact in $artifacts) {+ foreach ($path in $artifact.Paths) {+ foreach ($candidate in @($path, "$path.partial")) {+ if (Test-FreeVideoUvArchive $candidate $artifact.Hash $artifact.Bytes) {+ Write-Host 'Using verified local download tools'+ return Expand-FreeVideoUv $candidate $artifact.Member $destination+ }+ }+ }+ }+ $curl = Get-Command curl.exe -ErrorAction SilentlyContinue+ if (-not $curl) { throw 'curl.exe is missing. Repair Windows curl, or install Python 3.9+ and retry.' }+ $common = @('--disable', '--fail', '--location', '--silent', '--show-error',+ '--proto', '=https', '--proto-redir', '=https', '--connect-timeout', '5')+ $candidates = @()+ Write-Host 'Checking download tool sources'+ foreach ($source in $wheel.sources.PSObject.Properties) {+ if ($OfficialOnly -and $source.Name -ne 'official') { continue }+ foreach ($route in $ProxyRoutes) {+ # A small, bounded sample compares actual artifact delivery; no+ # region lookup or machine-wide proxy changes are involved.+ $sample = Join-Path $BootstrapRoot ('uv-probe-' + [Guid]::NewGuid().ToString('N'))+ $score = 0.0+ try {+ $watch = [Diagnostics.Stopwatch]::StartNew()+ $probeArgs = $common + @('--range', '0-262143', '--max-filesize', '1048576',+ '--max-time', '5', '--output', $sample, $source.Value)+ $code = Invoke-FreeVideoBootstrapCommand -Executable $curl.Source -Arguments $probeArgs `+ -LogPath $LogPath -Label ("Probe uv: {0}, {1}" -f $source.Name, $route) -Direct:($route -eq 'direct')+ $watch.Stop()+ if ($code -eq 0 -and (Test-Path -LiteralPath $sample)) {+ $score = (Get-Item -LiteralPath $sample).Length / [Math]::Max(0.001, $watch.Elapsed.TotalSeconds)+ }+ } finally {+ if (Test-Path -LiteralPath $sample) { Remove-Item -LiteralPath $sample }+ }+ $candidates += [pscustomobject]@{Source=$source.Name; Route=$route; Url=$source.Value; Score=$score; Artifact=$artifacts[0]}+ }+ }+ $candidates = @($candidates | Sort-Object -Property @{Expression={$_.Score}; Descending=$true})+ # Release ZIPs remain a fallback and use a separate partial/cache file.+ foreach ($source in $GithubSources) {+ foreach ($route in $ProxyRoutes) {+ $candidates += [pscustomobject]@{Source='GitHub'; Route=$route;+ Url=$Spec.url.Replace('https://github.com', $source); Artifact=$artifacts[1]}+ }+ }+ foreach ($candidate in $candidates) {+ $artifact = $candidate.Artifact+ $archive = Join-Path $BootstrapRoot $artifact.Name+ $partial = "$archive.partial"+ if (Test-Path -LiteralPath $archive) {+ Move-Item -LiteralPath $archive -Destination "$archive.rejected-$([DateTime]::UtcNow.Ticks)"+ }+ for ($restart = 0; $restart -lt 2; $restart++) {+ $offset = if (Test-Path -LiteralPath $partial) { (Get-Item -LiteralPath $partial).Length } else { 0 }+ if ($offset -ge $artifact.Bytes) {+ if (Test-FreeVideoUvArchive $partial $artifact.Hash $artifact.Bytes) {+ Move-Item -LiteralPath $partial -Destination $archive+ return Expand-FreeVideoUv $archive $artifact.Member $destination+ }+ Move-Item -LiteralPath $partial -Destination "$partial.rejected-$([DateTime]::UtcNow.Ticks)"+ $offset = 0+ }+ Write-Host ('Downloading uv: {0:N1} / {1:N1} MiB; source {2}; {3} connection' -f+ ($offset / 1MB), ($artifact.Bytes / 1MB), $candidate.Source, $candidate.Route)+ $downloadArgs = $common + @('--max-time', '180', '--speed-limit', '32768', '--speed-time', '20',+ '--max-filesize', [string]($artifact.Bytes - $offset), '--output', $partial)+ if ($offset -gt 0) { $downloadArgs += @('--continue-at', [string]$offset) }+ $downloadArgs += $candidate.Url+ $code = Invoke-FreeVideoBootstrapCommand -Executable $curl.Source -Arguments $downloadArgs `+ -LogPath $LogPath -Label ("Download uv: {0}, {1}" -f $candidate.Source, $candidate.Route) -Direct:($candidate.Route -eq 'direct')+ if (Test-FreeVideoUvArchive $partial $artifact.Hash $artifact.Bytes) {+ Move-Item -LiteralPath $partial -Destination $archive+ return Expand-FreeVideoUv $archive $artifact.Member $destination+ }+ if ($code -eq 0 -or ($offset -gt 0 -and $code -in @(22, 33))) {+ # Keep incompatible/unchecked bytes; do not append a different+ # artifact or treat a rejected Range response as completion.+ if (Test-Path -LiteralPath $partial) {+ Move-Item -LiteralPath $partial -Destination "$partial.retained-$([DateTime]::UtcNow.Ticks)"+ }+ if ($restart -eq 0) { continue }+ }+ Write-Host ("Download source unavailable or too slow (curl {0}); trying another source" -f $code)+ break+ }+ }+ throw "uv download failed on all sources. Partial files retained. See $LogPath and retry."+}diff --git a/pyproject.toml b/pyproject.tomlindex 9abd5d0..844c5f8 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -31,4 +31,4 @@ freevideo = "freevideo_engine.cli:main"include = ["freevideo_engine*"][tool.setuptools.package-data]-freevideo_engine = ["build-version.txt", "dependencies.json", "model_files.json", "model_shares.json", "prepared_models.json", "bootstrap_versions.json", "test_prompts.json", "windows_process_host.ps1", "windows_bootstrap.ps1", "assets/*.png", "assets/*.ico", "launcher/*.qml", "launcher/licenses/*.txt", "licenses/*.txt"]+freevideo_engine = ["build-version.txt", "dependencies.json", "model_files.json", "model_shares.json", "prepared_models.json", "bootstrap_versions.json", "uv_downloads.json", "test_prompts.json", "windows_process_host.ps1", "windows_bootstrap.ps1", "assets/*.png", "assets/*.ico", "launcher/*.qml", "launcher/licenses/*.txt", "licenses/*.txt"]