From 24b6887fe007482bfa9071ae2dfb82055ed36632 Mon Sep 17 00:00:00 2001 From: "Guenther, Karsten (RDD-RM)" Date: Mon, 19 Aug 2024 15:34:30 +0200 Subject: [PATCH] chore: cleanup python install, silence some scoop commands and add some comment regarding pip-system-certs --- bootstrap.ps1 | 13 +++++-------- bootstrap.py | 2 ++ tests/bootstrap.Tests.ps1 | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bootstrap.ps1 b/bootstrap.ps1 index 6ffe382..37801e2 100644 --- a/bootstrap.ps1 +++ b/bootstrap.ps1 @@ -91,7 +91,7 @@ function Install-Scoop { Write-Output "Applying scoop configuration" foreach ($item in $config.scoop_config.GetEnumerator()) { - Invoke-CommandLine ("scoop config " + $item.Key + " " + $item.Value) -Silent $true + Invoke-CommandLine ("scoop config " + $item.Key + " " + $item.Value) -Silent $true -PrintCommand $false } # Install any installer dependencies @@ -105,7 +105,7 @@ function Install-Scoop { "dark.json" ) $manifests | ForEach-Object { - Invoke-CommandLine "scoop install $($config.scoop_default_bucket_base_url)/$_" -Silent $true + Invoke-CommandLine "scoop install $($config.scoop_default_bucket_base_url)/$_" -Silent $true -PrintCommand $false } # Import scoopfile.json @@ -144,14 +144,11 @@ function Install-Python { Write-Output "$python not found. Try to install $python via scoop ..." # Install python Invoke-CommandLine "scoop install $($config.scoop_python_bucket_base_url)/$python.json" + + Initialize-EnvPath } else { - Write-Output "$python found in $pythonPath" - # Extract the directory of python exe file and add it to PATH. It needs to be the first entry in PATH - # such that this version is used when the user calls python and not python311 - $pythonDir = [System.IO.Path]::GetDirectoryName($pythonPath) - Write-Output "Adding $pythonDir to PATH" - $Env:Path += ";$pythonDir" + Write-Output "$python found in $pythonPath, skipping installation." } } diff --git a/bootstrap.py b/bootstrap.py index d59d78a..f97718c 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -364,6 +364,8 @@ def run(self) -> int: pypi_source = PyPiSourceParser.from_pyproject(self.root_dir) if pypi_source: self.virtual_env.pip_configure(index_url=pypi_source.url, verify_ssl=True) + # We need pip-system-certs in venv to use system certificates, + # pip-system-certs in Python is not used by pip, pipenv nor poetry from venv. pip_args = ["install", package_manager, "pip-system-certs"] if sys.version_info >= (3, 11): # Use the new trust store feature in Python 3.11 diff --git a/tests/bootstrap.Tests.ps1 b/tests/bootstrap.Tests.ps1 index c9fc0f3..8cce489 100644 --- a/tests/bootstrap.Tests.ps1 +++ b/tests/bootstrap.Tests.ps1 @@ -258,7 +258,7 @@ Describe "Install-Python" { Install-Python Should -Invoke -CommandName Invoke-CommandLine -Exactly 0 - Should -Invoke -CommandName Write-Output -Exactly 2 - Should -Invoke -CommandName Write-Output -Exactly 1 -ParameterFilter { $InputObject -eq "python311 found in somebloodypath" } + Should -Invoke -CommandName Write-Output -Exactly 1 + Should -Invoke -CommandName Write-Output -Exactly 1 -ParameterFilter { $InputObject -eq "python311 found in somebloodypath, skipping installation." } } }