Skip to content

Commit

Permalink
Only adjust $PATH instead of symlinking to an intermediate directory
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed Apr 30, 2014
1 parent cc76ddf commit 782af6b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
13 changes: 10 additions & 3 deletions ci_environment/python/attributes/default.rb
Expand Up @@ -18,14 +18,20 @@
# limitations under the License.
#
default['python']['pyenv']['revision'] = "cf89abaacff804b7b2047e3ee2ff6df5651b1ce5"

# Order matters for this list of Pythons. It will be used to construct the
# $PATH so items earlier in the list will take precedence over items later in
# the list. This order means that ``python`` will be 2.7.6, ``python2`` will be
# 2.7.6, and ``python3`` will be 3.4.0.
default['python']['pyenv']['pythons'] = [
"2.6.9",
"2.7.6",
"3.2.5",
"3.3.5",
"2.6.9",
"3.4.0",
"3.3.5",
"3.2.5",
"pypy-2.2.1",
]

default['python']['pyenv']['aliases'] = {
"2.6.9" => ["2.6"],
"2.7.6" => ["2.7"],
Expand All @@ -34,6 +40,7 @@
"3.4.0" => ["3.4"],
"pypy-2.2.1" => ["pypy"],
}

default['python']['pip']['packages'] = {
"default" => ["nose", "pytest", "mock"],
"2.6" => ["numpy"],
Expand Down
50 changes: 18 additions & 32 deletions ci_environment/python/recipes/pyenv.rb
Expand Up @@ -32,15 +32,6 @@
action :create
end

# Create a directory to store our "flattened" bins in
directory "/opt/python/bin" do
owner "root"
group "root"
mode "755"

action :create
end

# Create a directory to store our virtualenvs in
directory virtualenv_root do
owner node.travis_build_environment.user
Expand All @@ -50,16 +41,8 @@
action :create
end

# Create a profile script that adds our Python bins to the $PATH
file "/etc/profile.d/pyenv.sh" do
owner node.travis_build_environment.user
group node.travis_build_environment.group
mode "0755"

content "export PATH=/opt/python/bin:$PATH"

action :create
end
# Store a list of all of our bin dirs
bindirs = Array.new

# Install the baked in versions of Python we are offering
node.python.pyenv.pythons.each do |py|
Expand All @@ -79,12 +62,8 @@
})
end

# Add a symlink to /usr/local/bin
link "/opt/python/bin/#{pyname}" do
to "/opt/python/#{py}/bin/python"
owner node.travis_build_environment.user
group node.travis_build_environment.group
end
# Record our bindir
bindirs << "/opt/python/#{py}/bin"

# Create our virtualenvs for this python
python_virtualenv "python_#{py}" do
Expand All @@ -104,13 +83,6 @@
pyaliasname = pyalias
end

# Add an alias link in our /opt/python/bin directory
link "/opt/python/bin/#{pyaliasname}" do
to "/opt/python/#{py}/bin/python"
owner node.travis_build_environment.user
group node.travis_build_environment.group
end

link "#{virtualenv_root}/#{pyaliasname}" do
to "#{virtualenv_root}/#{pyname}"
owner node.travis_build_environment.user
Expand All @@ -131,3 +103,17 @@
group node.travis_build_environment.group
end
end

# Create a profile script that adds our Python bins to the $PATH
template "/etc/profile.d/pyenv.sh" do
owner node.travis_build_environment.user
group node.travis_build_environment.group
mode 0755

variables({
:bindirs => bindirs,
})

source "pyenv.sh.erb"
backup false
end
2 changes: 2 additions & 0 deletions ci_environment/python/templates/default/pyenv.sh.erb
@@ -0,0 +1,2 @@
# Export the $PATH with the pyenv bindirs prepended to it
export PATH=<%= @bindirs.join(':') %>:$PATH

0 comments on commit 782af6b

Please sign in to comment.