fer
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
This commit is contained in:
@@ -181,50 +181,24 @@ if (-not $NoInstall) {
|
||||
& $venvPython -c "import importlib; importlib.import_module('CLI')" 2>$null
|
||||
if ($LASTEXITCODE -eq 0) { Write-Log "Top-level 'CLI' is importable in the venv." }
|
||||
else {
|
||||
Write-Log "Top-level 'CLI' not importable; attempting to add repo root to venv site-packages via .pth" "INFO"
|
||||
$sites = Get-SitePackages -python $venvPython
|
||||
$siteDir = $sites | Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||
if ($siteDir) {
|
||||
$pth = Join-Path $siteDir 'medeia_repo.pth'
|
||||
if (Test-Path $pth) {
|
||||
if (-not (Select-String -Path $pth -Pattern ([regex]::Escape($repoRoot)) -Quiet)) {
|
||||
Add-Content -Path $pth -Value $repoRoot
|
||||
Write-Log "Appended repo root to existing .pth: $pth" "INFO"
|
||||
} else {
|
||||
Write-Log ".pth already contains repo root: $pth" "INFO"
|
||||
}
|
||||
} else {
|
||||
Set-Content -LiteralPath $pth -Value $repoRoot -Encoding UTF8
|
||||
Write-Log "Wrote .pth adding repo root to venv site-packages: $pth" "INFO"
|
||||
}
|
||||
Write-Log "Top-level 'CLI' not importable; writing venv site-packages .pth pointing at repo root..." "INFO"
|
||||
|
||||
# Re-check import
|
||||
& $venvPython -c "import importlib; importlib.import_module('CLI')" 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Log "Top-level 'CLI' import works after adding .pth" "INFO"
|
||||
} else {
|
||||
Write-Log "Adding .pth did not make top-level 'CLI' importable." "ERROR"
|
||||
if ($Editable) {
|
||||
Write-Log "Editable install already requested; attempting editable reinstall for good measure..." "INFO"
|
||||
try { & $venvPython -m pip install -e . } catch { Write-Log "Editable reinstall failed: $_" "ERROR"; exit 6 }
|
||||
& $venvPython -c "import importlib; importlib.import_module('CLI')" 2>$null
|
||||
if ($LASTEXITCODE -eq 0) { Write-Log "Top-level 'CLI' is now importable after reinstall." "INFO" }
|
||||
else { Write-Log "Editable reinstall did not make 'CLI' importable; inspect the venv or create an egg-link manually." "ERROR"; exit 6 }
|
||||
} else {
|
||||
if (-not $Quiet) {
|
||||
$ans = Read-Host "Top-level 'CLI' not importable; install project in editable mode now? (Y/n)"
|
||||
if ($ans -eq 'y' -or $ans -eq 'Y') { try { & $venvPython -m pip install -e . } catch { Write-Log "Editable install failed: $_" "ERROR"; exit 6 } }
|
||||
else { Write-Log "Warning: continuing without top-level 'CLI' importable; some entrypoints may fail." "ERROR" }
|
||||
} else { Write-Log "Top-level 'CLI' not importable and cannot prompt (quiet mode); aborting." "ERROR"; exit 6 }
|
||||
}
|
||||
}
|
||||
$siteDir = (& $venvPython -c "import sysconfig; print(sysconfig.get_paths().get('purelib',''))" 2>$null).Trim()
|
||||
if (-not $siteDir -or -not (Test-Path $siteDir)) {
|
||||
Write-Log "ERROR: unable to determine venv site-packages directory (purelib='$siteDir'); aborting." "ERROR"
|
||||
exit 6
|
||||
}
|
||||
|
||||
$pth = Join-Path $siteDir 'medeia_repo.pth'
|
||||
Set-Content -LiteralPath $pth -Value $repoRoot -Encoding UTF8
|
||||
Write-Log "Wrote .pth adding repo root to venv site-packages: $pth" "INFO"
|
||||
|
||||
& $venvPython -c "import importlib; importlib.import_module('CLI')" 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Log "OK: top-level 'CLI' is now importable (after .pth)." "INFO"
|
||||
} else {
|
||||
Write-Log "Unable to determine site-packages to write .pth; falling back to editable install prompt" "WARNING"
|
||||
if ($Editable) { try { & $venvPython -m pip install -e . } catch { Write-Log "Editable install failed: $_" "ERROR"; exit 6 } }
|
||||
elseif (-not $Quiet) {
|
||||
$ans = Read-Host "Top-level 'CLI' not importable; install project in editable mode now? (Y/n)"
|
||||
if ($ans -eq 'y' -or $ans -eq 'Y') { try { & $venvPython -m pip install -e . } catch { Write-Log "Editable install failed: $_" "ERROR"; exit 6 } }
|
||||
} else { Write-Log "Top-level 'CLI' not importable and cannot prompt (quiet mode); aborting." "ERROR"; exit 6 }
|
||||
Write-Log "ERROR: top-level 'CLI' still not importable after writing .pth ($pth); aborting." "ERROR"
|
||||
exit 6
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user