diff --git a/builders/macos-python-builder.psm1 b/builders/macos-python-builder.psm1 index 6b36fddc..1e52540d 100644 --- a/builders/macos-python-builder.psm1 +++ b/builders/macos-python-builder.psm1 @@ -31,10 +31,10 @@ class macOSPythonBuilder : NixPythonBuilder { .SYNOPSIS Prepare system environment by installing dependencies and required packages. #> - + if ($this.Version -eq "3.7.17") { - # We have preinstalled ncurses and readLine on the hoster runners. But we need to install bzip2 for - # setting up an environemnt + # We have preinstalled ncurses and readLine on the hoster runners. But we need to install bzip2 for + # setting up an environemnt # If we get any issues realted to ncurses or readline we can try to run this command # brew install ncurses readline Execute-Command -Command "brew install bzip2" @@ -53,6 +53,9 @@ class macOSPythonBuilder : NixPythonBuilder { $configureString += " --enable-optimizations" $configureString += " --enable-shared" $configureString += " --with-lto" + if ($this.WithPyDebug) { + $configureString += " --with-pydebug" + } ### For Python versions which support it, compile a universal2 (arm64 + x86_64 hybrid) build. The arm64 slice ### will never be used itself by a Github Actions runner but using a universal2 Python is the only way to build diff --git a/builders/python-builder.psm1 b/builders/python-builder.psm1 index c2541d37..69784298 100644 --- a/builders/python-builder.psm1 +++ b/builders/python-builder.psm1 @@ -12,6 +12,9 @@ class PythonBuilder { .PARAMETER Architecture The architecture with which Python should be built. + .PARAMETER WithPyDebug + The flag that indicates whether Python should be a debug build with the --with-pydebug configure option. + .PARAMETER HostedToolcacheLocation The location of hostedtoolcache artifacts. Using system AGENT_TOOLSDIRECTORY variable value. @@ -97,9 +100,9 @@ class PythonBuilder { [void] PreparePythonToolcacheLocation() { <# .SYNOPSIS - Prepare system hostedtoolcache folder for new Python version. + Prepare system hostedtoolcache folder for new Python version. #> - + $pythonBinariesLocation = $this.GetFullPythonToolcacheLocation() if (Test-Path $pythonBinariesLocation) { @@ -107,7 +110,7 @@ class PythonBuilder { Remove-Item $pythonBinariesLocation -Recurse -Force } else { Write-Host "Create $pythonBinariesLocation folder..." - New-Item -ItemType Directory -Path $pythonBinariesLocation + New-Item -ItemType Directory -Path $pythonBinariesLocation } } } diff --git a/builders/ubuntu-python-builder.psm1 b/builders/ubuntu-python-builder.psm1 index 35b159c5..820da35f 100644 --- a/builders/ubuntu-python-builder.psm1 +++ b/builders/ubuntu-python-builder.psm1 @@ -36,6 +36,9 @@ class UbuntuPythonBuilder : NixPythonBuilder { $configureString += " --prefix=$pythonBinariesLocation" $configureString += " --enable-shared" $configureString += " --enable-optimizations" + if ($this.WithPyDebug) { + $configureString += " --with-pydebug" + } ### Compile with support of loadable sqlite extensions. ### Link to documentation (https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.enable_load_extension) diff --git a/builders/win-python-builder.psm1 b/builders/win-python-builder.psm1 index 95d11bc3..44ba7a33 100644 --- a/builders/win-python-builder.psm1 +++ b/builders/win-python-builder.psm1 @@ -14,6 +14,9 @@ class WinPythonBuilder : PythonBuilder { .PARAMETER architecture The architecture with which Python should be built. + .PARAMETER WithPyDebug + The flag that indicates whether Python should be installed with debug symbols. + .PARAMETER InstallationTemplateName The name of installation script template that will be used in generated artifact. @@ -39,7 +42,7 @@ class WinPythonBuilder : PythonBuilder { [string] GetPythonExtension() { <# .SYNOPSIS - Return extension for required version of Python executable. + Return extension for required version of Python executable. #> $extension = if ($this.Version -lt "3.5" -and $this.Version -ge "2.5") { ".msi" } else { ".exe" } @@ -50,7 +53,7 @@ class WinPythonBuilder : PythonBuilder { [string] GetArchitectureExtension() { <# .SYNOPSIS - Return architecture suffix for Python executable. + Return architecture suffix for Python executable. #> $ArchitectureExtension = "" @@ -60,7 +63,7 @@ class WinPythonBuilder : PythonBuilder { } else { $ArchitectureExtension = ".amd64" } - }elseif ($this.Architecture -eq "arm64") { + } elseif ($this.Architecture -eq "arm64") { $ArchitectureExtension = "-arm64" } @@ -114,7 +117,11 @@ class WinPythonBuilder : PythonBuilder { $variablesToReplace = @{ "{{__ARCHITECTURE__}}" = $this.Architecture; "{{__VERSION__}}" = $this.Version; - "{{__PYTHON_EXEC_NAME__}}" = $pythonExecName + "{{__PYTHON_EXEC_NAME__}}" = $pythonExecName; + "{{__PYTHON_EXTRA_PARAMS__}}" = ""; + } + if ($this.WithPyDebug) { + $variablesToReplace["{{__PYTHON_EXTRA_PARAMS__}}"] " Include_debug=1 Include_symbols=1" } $variablesToReplace.keys | ForEach-Object { $installationTemplateContent = $installationTemplateContent.Replace($_, $variablesToReplace[$_]) } diff --git a/installers/win-setup-template.ps1 b/installers/win-setup-template.ps1 index e2a33b8b..e8af7fa0 100644 --- a/installers/win-setup-template.ps1 +++ b/installers/win-setup-template.ps1 @@ -1,6 +1,7 @@ [String] $Architecture = "{{__ARCHITECTURE__}}" [String] $Version = "{{__VERSION__}}" [String] $PythonExecName = "{{__PYTHON_EXEC_NAME__}}" +[String] $PythonExtraParams = "{{__PYTHON_EXTRA_PARAMS__}}" function Get-RegistryVersionFilter { param( @@ -122,7 +123,7 @@ Copy-Item -Path ./$PythonExecName -Destination $PythonArchPath | Out-Null Write-Host "Install Python $Version in $PythonToolcachePath..." $ExecParams = Get-ExecParams -IsMSI $IsMSI -PythonArchPath $PythonArchPath -cmd.exe /c "cd $PythonArchPath && call $PythonExecName $ExecParams /quiet" +cmd.exe /c "cd $PythonArchPath && call $PythonExecName $ExecParams $PythonExtraParams /quiet" if ($LASTEXITCODE -ne 0) { Throw "Error happened during Python installation" }