diff --git a/Berksfile b/Berksfile index 4e3dece..bfc33ee 100644 --- a/Berksfile +++ b/Berksfile @@ -8,5 +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" + cookbook 'alternatives', git: 'https://github.com/vkhatri/chef-alternatives', tag: "v0.2.0" end diff --git a/recipes/pip.rb b/recipes/pip.rb index 9051f27..f8d9c99 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -39,15 +39,12 @@ not_if { ::File.exists?(pip_binary) } end +#because the latest version of the get-pip.py script requires >=python3.7, this is now hardcoded to the 3.6 version as recommended by pypa.io execute "install-pip" do cwd Chef::Config[:file_cache_path] 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' + command 'sudo curl -s -N https://bootstrap.pypa.io/ez_setup.py -o - | sudo python3.6 && curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py && sudo python3.6 get-pip.py' not_if { ::File.exists?(pip_binary) } end - -execute 'setuptools' do - command 'pip3 install setuptools==41.0.1' -end diff --git a/recipes/python.rb b/recipes/python.rb index c8b5a6e..bd4d269 100644 --- a/recipes/python.rb +++ b/recipes/python.rb @@ -1,26 +1,32 @@ -apt_repository "python3" do - uri 'http://ppa.launchpad.net/deadsnakes/ppa/ubuntu' - components ['trusty main'] +#Add in the deadsnakes ppa repository to app +#note the fkrull/deadsnakes url is correct for Ubuntu 14.04. For higher versions of Ubuntu (>16.0), this is instead "ppa:deadsnakes/ppa" +bash 'add deadsnakes ppa' do + code <<-EOH + sudo add-apt-repository ppa:fkrull/deadsnakes -y; + EOH + flags "-x" end - -execute "update" do - command 'sudo apt-get update' -end - -package 'python3.6' do - options '--force-yes' - action :install +#Update the apt repository list +bash 'update apt-get repos' do + code <<-EOH + sudo apt update; + EOH + flags "-x" end -package 'python3.6-dev' do - options '--force-yes' - action :install +#install python3.6 and python3.6-dev via apt +#note that this is using the fkrull/deadsnakes repository listed above +bash 'install python3.6' do + code <<-EOH + sudo apt-get purge python3.6; + sudo apt-get autoremove && sudo apt-get autoclean; + sudo apt install python3.6 -y --force-yes; + sudo apt install python3.6-dev -y --force-yes; + sudo apt install python3.6-venv -y --force-yes; + sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 + + sudo cp /usr/lib/python3/dist-packages/apt_pkg.cpython* /usr/lib/python3/dist-packages/apt_pkg.so; + EOH + flags "-x" 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