From 0793ea9250f37a0cc51e0d5afc21d97ce96ec4a1 Mon Sep 17 00:00:00 2001 From: Fabian Maas Date: Thu, 11 Nov 2021 08:43:34 +0100 Subject: [PATCH 1/4] upgrade pip during setup --- lib/autoproj/package_managers/pip_manager.rb | 1 + lib/autoproj/python.rb | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/autoproj/package_managers/pip_manager.rb b/lib/autoproj/package_managers/pip_manager.rb index 3746bf83..6f41db14 100644 --- a/lib/autoproj/package_managers/pip_manager.rb +++ b/lib/autoproj/package_managers/pip_manager.rb @@ -9,6 +9,7 @@ class PipManager < Manager def initialize_environment ws.env.set "PYTHONUSERBASE", pip_home ws.env.add_path "PATH", File.join(pip_home, "bin") + Autoproj::Python.setup_python_configuration_options(ws: ws) end # Return the directory where python packages are installed to. diff --git a/lib/autoproj/python.rb b/lib/autoproj/python.rb index ba23de57..a0017bbf 100644 --- a/lib/autoproj/python.rb +++ b/lib/autoproj/python.rb @@ -213,6 +213,15 @@ def self.rewrite_pip_shims(python_executable, prefix_dir) pip_path end + def self.upgrade_pip(ws: Autoproj.workspace) + python_executable = ws.config.get("python_executable", nil) + unless python_executable.nil? + Open3.popen3( + { "PYTHONUSERBASE" => ws.env["PYTHONUSERBASE"] }, + "#{python_executable} -m pip install --upgrade pip setuptools wheel") + end + end + # Activate configuration for python in the autoproj configuration # @return [String,String] python path and python version def self.activate_python(ws: Autoproj.workspace, @@ -226,6 +235,7 @@ def self.activate_python(ws: Autoproj.workspace, rewrite_python_shims(bin, ws.prefix_dir) rewrite_pip_shims(bin, ws.prefix_dir) + upgrade_pip(ws: ws) [bin, version] end From 66c7344cf8331c30e4b0a0ba88a3ccc79953a34d Mon Sep 17 00:00:00 2001 From: Fabian Maas Date: Fri, 12 Nov 2021 15:46:36 +0100 Subject: [PATCH 2/4] don't upgrade setuptools (and wheel) due to breaking change with how we use easy_install --- lib/autoproj/python.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/autoproj/python.rb b/lib/autoproj/python.rb index a0017bbf..50454862 100644 --- a/lib/autoproj/python.rb +++ b/lib/autoproj/python.rb @@ -218,7 +218,7 @@ def self.upgrade_pip(ws: Autoproj.workspace) unless python_executable.nil? Open3.popen3( { "PYTHONUSERBASE" => ws.env["PYTHONUSERBASE"] }, - "#{python_executable} -m pip install --upgrade pip setuptools wheel") + "#{python_executable} -m pip install --upgrade pip") end end From ec82f52d03d369c4dca4ea58708dae2090f4cc5d Mon Sep 17 00:00:00 2001 From: Fabian Maas Date: Mon, 15 Nov 2021 10:30:49 +0100 Subject: [PATCH 3/4] address rubocop offenses --- lib/autoproj/python.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/autoproj/python.rb b/lib/autoproj/python.rb index 50454862..59d9f3b4 100644 --- a/lib/autoproj/python.rb +++ b/lib/autoproj/python.rb @@ -215,11 +215,12 @@ def self.rewrite_pip_shims(python_executable, prefix_dir) def self.upgrade_pip(ws: Autoproj.workspace) python_executable = ws.config.get("python_executable", nil) - unless python_executable.nil? - Open3.popen3( - { "PYTHONUSERBASE" => ws.env["PYTHONUSERBASE"] }, - "#{python_executable} -m pip install --upgrade pip") - end + return if python_executable.nil? + + Open3.popen3( + { "PYTHONUSERBASE" => ws.env["PYTHONUSERBASE"] }, + "#{python_executable} -m pip install --upgrade pip" + ) end # Activate configuration for python in the autoproj configuration From 664f72056ca4f09bf36d1237c2a348b60cf02be4 Mon Sep 17 00:00:00 2001 From: Fabian Maas Date: Mon, 15 Nov 2021 10:38:02 +0100 Subject: [PATCH 4/4] activate python for tests --- test/scripts/seed-config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/scripts/seed-config.yml b/test/scripts/seed-config.yml index 66dc294a..b054880b 100644 --- a/test/scripts/seed-config.yml +++ b/test/scripts/seed-config.yml @@ -1,2 +1,4 @@ osdeps_mode: 'all' apt_dpkg_update: true +USE_PYTHON: true +python_executable: '/usr/bin/python3' \ No newline at end of file