Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 2 additions & 5 deletions recipes/pip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 20 additions & 21 deletions recipes/python.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
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
end

package 'python3.6-dev' 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

alternatives 'python-set-version-3' do
link_name 'python3'
path '/usr/bin/python3.6'
priority 100
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 install python3.6 python3.6-dev -y;
EOH
flags "-x"
end