From b835ad3707226fc768e2a1c7fdf4507319e47499 Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Fri, 13 Mar 2020 02:46:31 +0300 Subject: [PATCH 01/10] Lock virtualenv version (#1) --- recipes/virtualenv.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/virtualenv.rb b/recipes/virtualenv.rb index e0626a4..775b1e3 100644 --- a/recipes/virtualenv.rb +++ b/recipes/virtualenv.rb @@ -21,6 +21,7 @@ include_recipe "python::pip" python_pip "virtualenv" do - action :upgrade + version "16.6.1" + action :install version node['python']['virtualenv_version'] end From 0f481d786cfbbfdd9847d07615cc8251402f0bcb Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Tue, 17 Mar 2020 21:42:53 +0300 Subject: [PATCH 02/10] lock setuptools version (#2) --- recipes/pip.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/pip.rb b/recipes/pip.rb index ad02ab7..e239515 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -48,6 +48,7 @@ end python_pip 'setuptools' do - action :upgrade + version "41.0.1" + action :install version node['python']['setuptools_version'] end From 045601e727e504a13aa7b343c2681fa0e1af3376 Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Tue, 17 Mar 2020 22:07:31 +0300 Subject: [PATCH 03/10] install pip --- recipes/pip.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/pip.rb b/recipes/pip.rb index e239515..536e937 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -44,6 +44,7 @@ command <<-EOF #{node['python']['binary']} get-pip.py EOF + command 'sudo curl -s -N https://bootstrap.pypa.io/ez_setup.py -o - | sudo python3.6 && sudo python3.6 -m easy_install pip' not_if { ::File.exists?(pip_binary) } end From 0088166d495e5544294762eb0f588346d13ffc2b Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Tue, 17 Mar 2020 22:34:51 +0300 Subject: [PATCH 04/10] install python3.6 --- recipes/python.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 recipes/python.rb diff --git a/recipes/python.rb b/recipes/python.rb new file mode 100644 index 0000000..1944809 --- /dev/null +++ b/recipes/python.rb @@ -0,0 +1,7 @@ +execute "install-python" do + command 'sudo add-apt-repository ppa:deadsnakes/ppa' + command 'sudo apt-get update' + command 'sudo apt-get install python3.6' + command 'sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1' + not_if { ::File.exists?(pip_binary) } + end \ No newline at end of file From 4147bf8132b9293a3b5e89fba50d312ebb807b5f Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Tue, 17 Mar 2020 22:36:03 +0300 Subject: [PATCH 05/10] add python recipe --- recipes/default.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/default.rb b/recipes/default.rb index 725b6cb..26dc8b3 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -19,5 +19,6 @@ # include_recipe "python::#{node['python']['install_method']}" +include_recipe "python::python" include_recipe "python::pip" include_recipe "python::virtualenv" From 4e50e4814b003fd4e36ee4757540619e802d1120 Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Tue, 17 Mar 2020 22:41:41 +0300 Subject: [PATCH 06/10] remove typo --- recipes/python.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/recipes/python.rb b/recipes/python.rb index 1944809..e592c12 100644 --- a/recipes/python.rb +++ b/recipes/python.rb @@ -2,6 +2,11 @@ command 'sudo add-apt-repository ppa:deadsnakes/ppa' command 'sudo apt-get update' command 'sudo apt-get install python3.6' - command 'sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1' - not_if { ::File.exists?(pip_binary) } - end \ No newline at end of file +end + +alternatives 'python-set-version-3' do + link_name 'python3' + path '/usr/bin/python3.6' + priority 100 + action :install +end \ No newline at end of file From 491fa4106144d128d37f76689bc151ca3a99b223 Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Tue, 17 Mar 2020 23:01:24 +0300 Subject: [PATCH 07/10] add alternatives cookbook --- Berksfile | 1 + metadata.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Berksfile b/Berksfile index f59fa9c..4e3dece 100644 --- a/Berksfile +++ b/Berksfile @@ -8,4 +8,5 @@ group :integration do cookbook "yum" cookbook "build-essential" cookbook "python_test", :path => "./test/cookbooks/python_test" + cookbook 'alternatives', github: 'vkhatri/chef-alternatives', tag: "v0.2.0" end diff --git a/metadata.rb b/metadata.rb index 4a86423..c6a0592 100644 --- a/metadata.rb +++ b/metadata.rb @@ -7,6 +7,7 @@ depends "build-essential" depends "yum-epel" +depends "alternatives" recipe "python", "Installs python, pip, and virtualenv" recipe "python::package", "Installs python using packages." @@ -14,6 +15,6 @@ recipe "python::pip", "Installs pip from source." recipe "python::virtualenv", "Installs virtualenv using the python_pip resource." -%w{ debian ubuntu centos redhat fedora freebsd smartos }.each do |os| +%w{ debian ubuntu centos redhat fedora freebsd smartos }.each do |os| supports os end From 98a20fec5d46c60fe391d14220b8d779bf1f2ab6 Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Tue, 17 Mar 2020 23:25:28 +0300 Subject: [PATCH 08/10] refine chef --- recipes/python.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/recipes/python.rb b/recipes/python.rb index e592c12..3824484 100644 --- a/recipes/python.rb +++ b/recipes/python.rb @@ -1,7 +1,16 @@ -execute "install-python" do - command 'sudo add-apt-repository ppa:deadsnakes/ppa' +apt_repository "python3" do + uri 'http://ppa.launchpad.net/deadsnakes/ppa/ubuntu' + components ['trusty main'] +end + + +execute "update" do command 'sudo apt-get update' - command 'sudo apt-get install python3.6' +end + +package 'python3.6' do + options '--force-yes' + action :install end alternatives 'python-set-version-3' do From e3a6b5141e463150af828be8ca128e7692cdea95 Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Wed, 18 Mar 2020 01:43:12 +0300 Subject: [PATCH 09/10] install virtualenv with pip3 --- recipes/pip.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/recipes/pip.rb b/recipes/pip.rb index 536e937..9051f27 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -48,8 +48,6 @@ not_if { ::File.exists?(pip_binary) } end -python_pip 'setuptools' do - version "41.0.1" - action :install - version node['python']['setuptools_version'] +execute 'setuptools' do + command 'pip3 install setuptools==41.0.1' end From dd57852ccbe3f9398da796c4939c642a4b98e05a Mon Sep 17 00:00:00 2001 From: Philip Kwesiga Date: Wed, 18 Mar 2020 23:24:41 +0300 Subject: [PATCH 10/10] install python3.6-dev --- recipes/python.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes/python.rb b/recipes/python.rb index 3824484..c8b5a6e 100644 --- a/recipes/python.rb +++ b/recipes/python.rb @@ -13,6 +13,11 @@ action :install end +package 'python3.6-dev' do + options '--force-yes' + action :install +end + alternatives 'python-set-version-3' do link_name 'python3' path '/usr/bin/python3.6'