Class: DPL::Provider::PyPI

Inherits:
DPL::Provider show all
Defined in:
lib/dpl/provider/pypi.rb

Constant Summary collapse

DEFAULT_SERVER =
'http://www.python.org/pypi'
PYPIRC_FILE =
'~/.pypirc'

Instance Attribute Summary

Attributes inherited from DPL::Provider

#context, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DPL::Provider

#cleanup, context, #create_key, #deploy, #error, experimental, #initialize, #log, new, npm_g, #option, pip, requires, #run, #setup_git_ssh, #sha, shell, #uncleanup

Constructor Details

This class inherits a constructor from DPL::Provider

Class Method Details

.install_setuptoolsObject



7
8
9
# File 'lib/dpl/provider/pypi.rb', line 7

def self.install_setuptools
  shell 'wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python'
end

Instance Method Details

#check_appObject



52
53
# File 'lib/dpl/provider/pypi.rb', line 52

def check_app
end

#check_authObject



47
48
49
50
# File 'lib/dpl/provider/pypi.rb', line 47

def check_auth
  write_config
  log "Authenticated as #{option(:user)}"
end

#configObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dpl/provider/pypi.rb', line 13

def config
  {
    :header => '[distutils]',
    :servers_line => 'index-servers =',
    :servers => {
      'pypi' => [
                   "repository: #{options[:server] || DEFAULT_SERVER}",
                   "username: #{option(:user)}",
                   "password: #{option(:password)}",
                ]
    }
  }
end

#needs_key?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/dpl/provider/pypi.rb', line 55

def needs_key?
  false
end

#push_appObject



59
60
61
62
63
# File 'lib/dpl/provider/pypi.rb', line 59

def push_app
  context.shell "python setup.py register -r #{options[:server] || 'pypi'}"
  context.shell "python setup.py #{options[:distributions] || 'sdist'} upload -r #{options[:server] || 'pypi'}"
  context.shell "python setup.py upload_docs --upload-dir #{options[:docs_dir] || 'build/docs'}"
end

#write_configObject



38
39
40
41
42
43
44
45
# File 'lib/dpl/provider/pypi.rb', line 38

def write_config
  File.open(File.expand_path(PYPIRC_FILE), 'w') do |f|
    config.each do |key, val|
      f.puts(val) if val.is_a? String or val.is_a? Array
    end
    write_servers(f)
  end
end

#write_servers(f) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/dpl/provider/pypi.rb', line 27

def write_servers(f)
  config[:servers].each do |key, val|
    f.puts " " * 4 + key
  end

  config[:servers].each do |key, val|
    f.puts "[#{key}]"
    f.puts val
  end
end