Class: Python

Inherits:
Passenger show all
Defined in:
lib/exogenesis/passengers/python.rb

Overview

Install Python and pip packages REQUIRES: Homebrew (so put it after your homebrew task)

Instance Method Summary collapse

Methods inherited from Passenger

by_name, emoji_name, #initialize, needs, register_as, with_emoji

Constructor Details

This class inherits a constructor from Passenger

Instance Method Details

#upObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/exogenesis/passengers/python.rb', line 10

def up
  if command_exists? 'pip'
    skip_task 'Install Python'
  else
    execute 'Install Python', 'brew install python'
  end

  execute 'Link Python', 'brew link --overwrite python' do |output|
    raise TaskSkipped, 'Already linked' if output.include? 'Already linked'
  end

  (['pip'] + pips).each do |package|
    if installed_pips.include? package
      execute "Upgrade #{package}", "pip install --user --upgrade #{package}" do |output|
        raise TaskSkipped, 'Already up to date' if output.include? 'already up-to-date'
      end
    else
      execute "Install #{package}", "pip install --user #{package}"
    end
  end
end