Skip to content

Commit

Permalink
chore: cleanup python install, silence some scoop commands and add so…
Browse files Browse the repository at this point in the history
…me comment regarding pip-system-certs
  • Loading branch information
xxthunder committed Aug 19, 2024
1 parent ba278ac commit 24b6887
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
13 changes: 5 additions & 8 deletions bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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."
}
}

Expand Down
2 changes: 2 additions & 0 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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." }
}
}

0 comments on commit 24b6887

Please sign in to comment.