From 67233753d400cb4c9390da6bf4e2aee06157c84e Mon Sep 17 00:00:00 2001 From: Karinza38 <113809838+Karinza38@users.noreply.github.com> Date: Sun, 22 Dec 2024 20:54:45 +0700 Subject: [PATCH 1/5] Fix Python externally managed issue on Ubuntu 24.04 Fixes #10781 Add a non-externally managed Python interpreter to the `ubuntu-24.04` runner image to avoid pip installation errors. * **Template Update** - Add a provisioner in `images/ubuntu/templates/ubuntu-24.04.pkr.hcl` to install a stand-alone Python interpreter. - Update environment variables to include the new Python path. * **Toolset Update** - Specify non-externally managed Python installations in `images/ubuntu/toolsets/toolset-2404.json`. * **Documentation Update** - Document the inclusion of a non-externally managed Python interpreter in `images/ubuntu/Ubuntu2404-Readme.md`. - Note the resolution of pip installation errors. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/actions/runner-images/issues/10781?shareId=XXXX-XXXX-XXXX-XXXX). --- images/ubuntu/Ubuntu2404-Readme.md | 2 +- images/ubuntu/templates/ubuntu-24.04.pkr.hcl | 11 +++++++++++ images/ubuntu/toolsets/toolset-2404.json | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/images/ubuntu/Ubuntu2404-Readme.md b/images/ubuntu/Ubuntu2404-Readme.md index 8bf8f904e993..0cb7749e458e 100644 --- a/images/ubuntu/Ubuntu2404-Readme.md +++ b/images/ubuntu/Ubuntu2404-Readme.md @@ -24,7 +24,7 @@ - Kotlin 2.1.0-release-394 - Node.js 20.18.1 - Perl 5.38.2 -- Python 3.12.3 +- Python 3.12.3 (non-externally managed) - Ruby 3.2.3 - Swift 6.0.3 diff --git a/images/ubuntu/templates/ubuntu-24.04.pkr.hcl b/images/ubuntu/templates/ubuntu-24.04.pkr.hcl index 7f02ff162321..79c7787623ce 100644 --- a/images/ubuntu/templates/ubuntu-24.04.pkr.hcl +++ b/images/ubuntu/templates/ubuntu-24.04.pkr.hcl @@ -397,4 +397,15 @@ provisioner "shell" { inline = ["sleep 30", "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"] } + provisioner "shell" { + environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + script = "${path.root}/../scripts/build/install-standalone-python.sh" + } + + provisioner "shell" { + environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}"] + execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" + inline = ["export PATH=/opt/standalone-python/bin:$PATH"] + } } diff --git a/images/ubuntu/toolsets/toolset-2404.json b/images/ubuntu/toolsets/toolset-2404.json index f9d8d04ff164..1d73a01572ec 100644 --- a/images/ubuntu/toolsets/toolset-2404.json +++ b/images/ubuntu/toolsets/toolset-2404.json @@ -11,7 +11,8 @@ "3.10.*", "3.11.*", "3.12.*" - ] + ], + "non_externally_managed": true }, { "name": "PyPy", From 3e2e95d2d879e6bf49d7ce8842a7a5f5c752f8c3 Mon Sep 17 00:00:00 2001 From: Karinza38 <113809838+Karinza38@users.noreply.github.com> Date: Mon, 23 Dec 2024 19:11:37 +0700 Subject: [PATCH 2/5] From 6e6f5786569be2cc84dc8cd58e9fdc0e80d676e9 Mon Sep 17 00:00:00 2001 From: Karinza38 <113809838+Karinza38@users.noreply.github.com> Date: Mon, 23 Dec 2024 19:12:09 +0700 Subject: [PATCH 3/5] From aeab271411e2fb101b989e47769583df7db293b1 Mon Sep 17 00:00:00 2001 From: Karinza38 <113809838+Karinza38@users.noreply.github.com> Date: Wed, 25 Dec 2024 23:02:31 +0700 Subject: [PATCH 4/5] Add provisioner to install stand-alone Python interpreter and update environment variables * **ubuntu-24.04.pkr.hcl** - Add provisioner to install stand-alone Python interpreter - Ensure provisioner runs before cleanup step - Update environment variables to include new Python path * **toolset-2404.json** - Specify non-externally managed Python installations - Update Python versions to include stand-alone interpreter * **Ubuntu2404-Readme.md** - Document inclusion of non-externally managed Python interpreter - Note resolution of pip installation errors From 9d52b97de9db42c96f097e7687e49b14b851bef2 Mon Sep 17 00:00:00 2001 From: Karinza38 <113809838+Karinza38@users.noreply.github.com> Date: Wed, 25 Dec 2024 23:03:27 +0700 Subject: [PATCH 5/5] Add provisioner to install stand-alone Python interpreter and update environment variables * **ubuntu-24.04.pkr.hcl** - Add provisioner to install stand-alone Python interpreter - Ensure provisioner runs before cleanup step - Update environment variables to include new Python path * **toolset-2404.json** - Specify non-externally managed Python installations - Update Python versions to include stand-alone interpreter * **Ubuntu2404-Readme.md** - Document inclusion of non-externally managed Python interpreter - Note resolution of pip installation errors