phamdangdangild commited on
Commit
84e0393
·
verified ·
1 Parent(s): d011768

Release 2.1.1: policy-safe portable Python fallback

Browse files
FOUNDRY_STUDIO_INSTALL.bat CHANGED
@@ -46,8 +46,19 @@ function Test-Administrator {
46
 
47
  function Get-WorkingPython {
48
  $candidates = [System.Collections.Generic.List[string]]::new()
 
 
49
  $managed = Join-Path $Root "runtime\python\python.exe"
50
  if (Test-Path -LiteralPath $managed -PathType Leaf) { $candidates.Add($managed) }
 
 
 
 
 
 
 
 
 
51
  try {
52
  $py = Get-Command py.exe -ErrorAction Stop
53
  $resolved = (& $py.Source -3 -c "import sys;print(sys.executable)" 2>$null | Select-Object -First 1)
@@ -66,25 +77,38 @@ function Get-WorkingPython {
66
  }
67
 
68
  function Install-ManagedPython([string]$SessionDir) {
69
- Step "Python 3.10+ chưa có; cài Python riêng cho user hiện tại"
70
  $version = "3.12.10"
71
  $arch = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { "win32" }
72
- if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { $arch = "arm64" }
73
- $fileName = if ($arch -eq "win32") { "python-$version.exe" } else { "python-$version-$arch.exe" }
74
  $url = "https://www.python.org/ftp/python/$version/$fileName"
75
- $installer = Join-Path $SessionDir $fileName
76
- Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $installer -TimeoutSec 180
77
- $signature = Get-AuthenticodeSignature -LiteralPath $installer
78
- if ($signature.Status -ne "Valid" -or $signature.SignerCertificate.Subject -notmatch "Python Software Foundation") {
79
- throw "Chữ ký bộ cài Python không hợp lệ; đã dừng để bảo vệ VPS."
 
 
 
 
 
80
  }
81
- $target = Join-Path $Root "runtime\python"
 
 
 
 
 
 
 
82
  New-Item -ItemType Directory -Force -Path (Split-Path $target -Parent) | Out-Null
83
- $arguments = "/quiet InstallAllUsers=0 Include_launcher=0 Include_pip=1 Include_test=0 Shortcuts=0 PrependPath=0 TargetDir=`"$target`""
84
- $process = Start-Process -FilePath $installer -ArgumentList $arguments -Wait -PassThru -WindowStyle Hidden
85
- if ($process.ExitCode -ne 0 -or -not (Test-Path -LiteralPath (Join-Path $target "python.exe"))) {
86
- throw "Cài Python thất bại (exit $($process.ExitCode))."
87
  }
 
 
88
  return (Join-Path $target "python.exe")
89
  }
90
 
 
46
 
47
  function Get-WorkingPython {
48
  $candidates = [System.Collections.Generic.List[string]]::new()
49
+ $portable = Join-Path $Root "runtime\python-portable\python.exe"
50
+ if (Test-Path -LiteralPath $portable -PathType Leaf) { $candidates.Add($portable) }
51
  $managed = Join-Path $Root "runtime\python\python.exe"
52
  if (Test-Path -LiteralPath $managed -PathType Leaf) { $candidates.Add($managed) }
53
+ if ($env:FM_FORCE_PORTABLE_PYTHON -eq "1") {
54
+ foreach ($candidate in ($candidates | Select-Object -Unique)) {
55
+ try {
56
+ & $candidate -c "import sys;raise SystemExit(0 if sys.version_info >= (3,10) else 1)" 2>$null
57
+ if ($LASTEXITCODE -eq 0) { return $candidate }
58
+ } catch {}
59
+ }
60
+ return $null
61
+ }
62
  try {
63
  $py = Get-Command py.exe -ErrorAction Stop
64
  $resolved = (& $py.Source -3 -c "import sys;print(sys.executable)" 2>$null | Select-Object -First 1)
 
77
  }
78
 
79
  function Install-ManagedPython([string]$SessionDir) {
80
+ Step "Python 3.10+ chưa có; tải Python portable chính chủ (không chạy installer)"
81
  $version = "3.12.10"
82
  $arch = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { "win32" }
83
+ if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64" -or $env:PROCESSOR_IDENTIFIER -match "ARM") { $arch = "arm64" }
84
+ $fileName = "python-$version-$arch.zip"
85
  $url = "https://www.python.org/ftp/python/$version/$fileName"
86
+ $expectedHashes = @{
87
+ "amd64" = "8649692de846c56a7189d6dae5c322ab20deb1b5908b6f39426b62a36f39415d"
88
+ "arm64" = "20a5b1a707d899ffdfc5e3086d7372f7cc95eeea344d48ae256047cb7075cf63"
89
+ "win32" = "b665393cbead6570e9445d9178e30160581149de2b09f29c8230a28718324801"
90
+ }
91
+ $archive = Join-Path $SessionDir $fileName
92
+ Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $archive -TimeoutSec 300
93
+ $actualHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $archive).Hash.ToLowerInvariant()
94
+ if ($actualHash -ne $expectedHashes[$arch]) {
95
+ throw "SHA256 Python portable không khớp; đã dừng để bảo vệ VPS."
96
  }
97
+ $stage = Join-Path $SessionDir "python-portable"
98
+ New-Item -ItemType Directory -Path $stage | Out-Null
99
+ Expand-VerifiedZip $archive $stage
100
+ $stagePython = Join-Path $stage "python.exe"
101
+ if (-not (Test-Path -LiteralPath $stagePython -PathType Leaf)) { throw "Gói Python portable thiếu python.exe." }
102
+ & $stagePython -c "import ensurepip, venv, sys; raise SystemExit(0 if sys.version_info >= (3,10) else 1)" 2>$null
103
+ if ($LASTEXITCODE -ne 0) { throw "Python portable tải về không vượt qua kiểm tra runtime." }
104
+ $target = Join-Path $Root "runtime\python-portable"
105
  New-Item -ItemType Directory -Force -Path (Split-Path $target -Parent) | Out-Null
106
+ if (Test-Path -LiteralPath $target) {
107
+ $backup = $target + ".replaced-" + [DateTime]::UtcNow.ToString("yyyyMMddHHmmss")
108
+ Move-Item -LiteralPath $target -Destination $backup
 
109
  }
110
+ Move-Item -LiteralPath $stage -Destination $target
111
+ Good "Python portable $version ($arch) đã sẵn sàng; không thay đổi Windows."
112
  return (Join-Path $target "python.exe")
113
  }
114
 
README.md CHANGED
@@ -16,7 +16,7 @@ Trình quản lý Microsoft Foundry chạy cục bộ trên Windows VPS. Tool qu
16
 
17
  1. Tải duy nhất `FOUNDRY_STUDIO_INSTALL.bat`.
18
  2. Double-click bằng user Windows đang dùng trình duyệt. Không cần **Run as administrator**.
19
- 3. BAT tự tải release, kiểm tra SHA256, cài Python/thư viện còn thiếu vào `%LOCALAPPDATA%`, rồi mở Studio ở tab mới.
20
  4. Chọn profile Azure CLI đang có hoặc đăng nhập bằng device code.
21
 
22
  Không cần Hugging Face token vì repo này là public. Profile Azure được lưu riêng tại `%LOCALAPPDATA%\FoundryManagerStudio\data\profiles` và không nằm trong release/update.
 
16
 
17
  1. Tải duy nhất `FOUNDRY_STUDIO_INSTALL.bat`.
18
  2. Double-click bằng user Windows đang dùng trình duyệt. Không cần **Run as administrator**.
19
+ 3. BAT tự tải release, kiểm tra SHA256, tải Python portable/thư viện còn thiếu vào `%LOCALAPPDATA%`, rồi mở Studio ở tab mới. Không chạy Windows Installer.
20
  4. Chọn profile Azure CLI đang có hoặc đăng nhập bằng device code.
21
 
22
  Không cần Hugging Face token vì repo này là public. Profile Azure được lưu riêng tại `%LOCALAPPDATA%\FoundryManagerStudio\data\profiles` và không nằm trong release/update.
checksums.txt CHANGED
@@ -1 +1 @@
1
- d32e347497e709e25f14bb8b812a00943c9f1c3b4d69abd2f7014039bce11e0c releases/foundrymanager-studio-2.1.0.zip
 
1
+ de80f188cce417d3d6fac74314d45b6a7a6031e1d958f4a85400c17403526f35 releases/foundrymanager-studio-2.1.1.zip
manifest.json CHANGED
@@ -1,14 +1,14 @@
1
  {
2
  "schema": 1,
3
  "product": "FoundryManager Studio",
4
- "version": "2.1.0",
5
- "published_at": "2026-08-05T12:25:29Z",
6
  "minimum_python": "3.10",
7
- "zip_url": "https://huggingface.co/datasets/DangPhamPham/foundrymanager-studio/resolve/main/releases/foundrymanager-studio-2.1.0.zip",
8
  "mirrors": [
9
- "https://huggingface.co/datasets/phamdangdangild/foundrymanager-studio/resolve/main/releases/foundrymanager-studio-2.1.0.zip"
10
  ],
11
- "sha256": "d32e347497e709e25f14bb8b812a00943c9f1c3b4d69abd2f7014039bce11e0c",
12
- "size_bytes": 94328,
13
  "entrypoint": "app.py"
14
  }
 
1
  {
2
  "schema": 1,
3
  "product": "FoundryManager Studio",
4
+ "version": "2.1.1",
5
+ "published_at": "2026-08-05T12:41:51Z",
6
  "minimum_python": "3.10",
7
+ "zip_url": "https://huggingface.co/datasets/DangPhamPham/foundrymanager-studio/resolve/main/releases/foundrymanager-studio-2.1.1.zip",
8
  "mirrors": [
9
+ "https://huggingface.co/datasets/phamdangdangild/foundrymanager-studio/resolve/main/releases/foundrymanager-studio-2.1.1.zip"
10
  ],
11
+ "sha256": "de80f188cce417d3d6fac74314d45b6a7a6031e1d958f4a85400c17403526f35",
12
+ "size_bytes": 94417,
13
  "entrypoint": "app.py"
14
  }
releases/foundrymanager-studio-2.1.1.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de80f188cce417d3d6fac74314d45b6a7a6031e1d958f4a85400c17403526f35
3
+ size 94417