# ============================================================================== # AITURK Unified Windows Installer (AGY Uyumlu / Guvenli ve Otomatik Bootstrap) # irm https://turkservis.online/install.ps1 | iex # ============================================================================== $ErrorActionPreference = "Stop" Write-Host ">>> AITURK Kurulumu baslatiliyor..." -ForegroundColor Cyan $tempDir = Join-Path ([IO.Path]::GetTempPath()) ("aiturk-install-" + [Guid]::NewGuid().ToString("N")) $installer = Join-Path $tempDir "install.py" $pythonCommand = $null $pythonPrefix = @() $probe = "import pip,platform,sys; raise SystemExit(0 if platform.python_implementation() == 'CPython' and (3, 11) <= sys.version_info[:2] < (3, 14) else 1)" function Install-AiturkBootstrapPython { param([string]$Root, [string]$Architecture, [string]$ArchivePath = '') # Fixed publisher assets, verified before extraction or execution. $assets = @{ 'x64' = @('x86_64', '9bcc038a0bf180612ed56dec93d4977d035e80b8d9320ef51a38c287baf134b7', 47042104) 'arm64' = @('aarch64', 'ce87247378f43f88e0202a0fa6d3cdb5f5fb246a3bc61b2fb604bd49b7862508', 43801216) } if (-not $assets.ContainsKey($Architecture)) { throw 'Desteklenmeyen Windows mimarisi. x64 veya ARM64 gerekli.' } $asset = $assets[$Architecture] $parent = [IO.Path]::GetFullPath($Root) if ($parent -eq [IO.Path]::GetPathRoot($parent) -or $parent -eq [Environment]::GetFolderPath('UserProfile')) { throw 'Calisma ortami icin ozel bir alt klasor gerekli.' } New-Item -ItemType Directory -Path $parent -Force | Out-Null if ((Get-Item -LiteralPath $parent).Attributes -band [IO.FileAttributes]::ReparsePoint) { throw 'Baglantili kurulum klasoru kullanilamaz.' } $target = Join-Path $parent ('cpython-3.13.15-20260901-' + $Architecture) $target = [IO.Path]::GetFullPath($target) if (-not $target.StartsWith($parent.TrimEnd('\') + '\', [StringComparison]::OrdinalIgnoreCase)) { throw 'Gecersiz calisma ortami hedefi.' } $exe = Join-Path $target 'python.exe' if (Test-Path -LiteralPath $exe) { & $exe -I -c 'import pip,ssl,venv; import sys; assert sys.version_info[:3] == (3,13,15)' 2>$null if ($LASTEXITCODE -eq 0) { return $exe } throw 'Kayitli AITURK calisma ortami dogrulanamadi.' } if (Test-Path -LiteralPath $target) { throw 'Calisma ortami klasoru eksik veya baska bir kurulum tarafindan kullaniliyor.' } $tar = Get-Command tar.exe -ErrorAction SilentlyContinue if (-not $tar) { throw 'Windows tar.exe bulunamadi. Guncel Windows 10 veya 11 gerekli.' } $stage = Join-Path $parent ('.staging-' + [Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $stage | Out-Null try { $archive = $ArchivePath if (-not $archive) { $archive = Join-Path $stage 'runtime.tar.gz' $url = 'https://github.com/astral-sh/python-build-standalone/releases/download/20260901/cpython-3.13.15%2B20260901-' + $asset[0] + '-pc-windows-msvc-install_only.tar.gz' Write-Host '>>> AITURK ozel calisma ortami indiriliyor; ayrica Python/pip kurmaniz gerekmiyor.' Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $archive } if ((Get-Item -LiteralPath $archive).Length -ne $asset[2] -or (Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash.ToLowerInvariant() -ne $asset[1]) { throw 'Calisma ortami boyutu veya SHA-256 dogrulamasi basarisiz.' } & $tar.Source -xzf $archive -C $stage if ($LASTEXITCODE -ne 0) { throw 'Calisma ortami acilamadi.' } $stagedPython = Join-Path $stage 'python/python.exe' & $stagedPython -I -c 'import pip,ssl,venv; import sys; assert sys.version_info[:3] == (3,13,15)' if ($LASTEXITCODE -ne 0) { throw 'Ozel calisma ortami testi basarisiz.' } Move-Item -LiteralPath (Join-Path $stage 'python') -Destination $target return $exe } finally { $resolvedStage = [IO.Path]::GetFullPath($stage) if (-not $resolvedStage.StartsWith($parent.TrimEnd('\') + '\', [StringComparison]::OrdinalIgnoreCase)) { throw 'Gecici kurulum yolu beklenen klasor disinda.' } if (Test-Path -LiteralPath $resolvedStage) { Remove-Item -LiteralPath $resolvedStage -Recurse -Force } } } # 1. Asama: py (Python Launcher) kontrolu (3.13, 3.12, 3.11, 3.14 veya en guncel) $py = Get-Command py.exe -ErrorAction SilentlyContinue if ($py) { foreach ($selector in @("-3.13", "-3.12", "-3.11")) { & $py.Source $selector -c $probe 2>$null if ($LASTEXITCODE -eq 0) { $pythonCommand = $py.Source $pythonPrefix = @($selector) break } } } # 2. Asama: Windows Registry uzerinden kurulu Python arama (PATH'e eklenmemis olsa bile bulur) if (-not $pythonCommand) { $registryHives = @("HKCU:\Software\Python\PythonCore", "HKLM:\Software\Python\PythonCore") foreach ($hive in $registryHives) { if (Test-Path $hive) { Get-ChildItem $hive -ErrorAction SilentlyContinue | ForEach-Object { $installPathKey = Join-Path $_.PSPath "InstallPath" if (Test-Path $installPathKey) { $dir = (Get-ItemProperty $installPathKey -ErrorAction SilentlyContinue).'(default)' if ($dir) { $candidate = Join-Path $dir "python.exe" if (Test-Path -LiteralPath $candidate) { & $candidate -c $probe 2>$null if ($LASTEXITCODE -eq 0) { $pythonCommand = $candidate $pythonPrefix = @() } } } } } } if ($pythonCommand) { break } } } # 3. Asama: Standart Kurulum Dizinleri if (-not $pythonCommand) { $knownDirs = @( "$env:LOCALAPPDATA\Programs\Python\Python3*", "$env:ProgramFiles\Python3*", "${env:ProgramFiles(x86)}\Python3*" ) foreach ($pattern in $knownDirs) { Get-Item $pattern -ErrorAction SilentlyContinue | ForEach-Object { $candidate = Join-Path $_.FullName "python.exe" if (Test-Path -LiteralPath $candidate) { & $candidate -c $probe 2>$null if ($LASTEXITCODE -eq 0) { $pythonCommand = $candidate $pythonPrefix = @() } } } if ($pythonCommand) { break } } } # 4. Asama: PATH icindeki Python'lar (Windows Store stub olan WindowsApps haric tutulur) if (-not $pythonCommand) { $resolvedList = Get-Command python.exe, python3.exe -All -ErrorAction SilentlyContinue | Where-Object { $_.Source -notlike "*WindowsApps*" } foreach ($resolved in $resolvedList) { & $resolved.Source -c $probe 2>$null if ($LASTEXITCODE -eq 0) { $pythonCommand = $resolved.Source $pythonPrefix = @() break } } } # 5. Asama: Sistem Python/pip veya winget gerektirmeyen ozel calisma ortami. if (-not $pythonCommand) { $nativeArch = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE } $runtimeArch = switch ($nativeArch) { 'AMD64' { 'x64' } 'ARM64' { 'arm64' } default { throw 'Desteklenmeyen Windows mimarisi.' } } $pythonCommand = Install-AiturkBootstrapPython -Root (Join-Path $env:LOCALAPPDATA 'TurkServis/AITURK/bootstrap') -Architecture $runtimeArch $pythonPrefix = @() } if (-not $pythonCommand) { throw 'AITURK ozel calisma ortami hazirlanamadi. Indirme baglantisini kontrol edin.' } New-Item -ItemType Directory -Path $tempDir -Force | Out-Null try { Write-Host ">>> Kurucu indiriliyor..." -ForegroundColor Gray Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 ` -Uri "https://turkservis.online/install.py" -OutFile $installer Write-Host ">>> AITURK bilesenleri kuruluyor..." -ForegroundColor Gray & $pythonCommand @pythonPrefix $installer if ($LASTEXITCODE -ne 0) { throw "AITURK birlesik kurulumu basarisiz oldu." } # 6. Asama (AGY Paritesi): Komut dizinini aktif oturuma ve sisteme tanit $binDir = Join-Path $env:LOCALAPPDATA "TurkServis\AITURK\program\bin" if (Test-Path $binDir) { if ($env:PATH -split ';' -notcontains $binDir) { $env:PATH = "$binDir;" + $env:PATH } try { if (-not ([System.Management.Automation.PSTypeName]'Win32EnvBroadcast').Type) { Add-Type -Namespace Win32Env -Name NativeMethods -MemberDefinition @' [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam, uint fuFlags, uint uTimeout, out UIntPtr lpdwResult); '@ } $broadcastRes = [UIntPtr]::Zero [Win32Env.NativeMethods]::SendMessageTimeout([IntPtr]0xffff, 0x001A, [UIntPtr]::Zero, "Environment", 2, 5000, [ref]$broadcastRes) | Out-Null } catch {} } Write-Host "`n[OK] AITURK CLI basariyla yuklendi!" -ForegroundColor Green Write-Host "Komut hazir: aiturk version`n" -ForegroundColor Yellow } finally { if (Test-Path -LiteralPath $installer) { Remove-Item -LiteralPath $installer -Force } $resolvedTemp = [IO.Path]::GetFullPath($tempDir) $tempParent = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('\') + '\' if (-not $resolvedTemp.StartsWith($tempParent, [StringComparison]::OrdinalIgnoreCase) -or -not [IO.Path]::GetFileName($resolvedTemp).StartsWith('aiturk-install-')) { throw 'Gecici kurulum yolu dogrulanamadi.' } if (Test-Path -LiteralPath $resolvedTemp) { Remove-Item -LiteralPath $resolvedTemp -Recurse -Force } }