Class: DPL::Provider::PyPI

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

Constant Summary collapse

DEFAULT_SERVER =
'http://pypi.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

apt_get, #cleanup, #commit_msg, context, #create_key, #deploy, #detect_encoding?, #encoding_for, #error, experimental, #log, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #warn

Constructor Details

#initialize(*args) ⇒ PyPI

Returns a new instance of PyPI.



12
13
14
15
# File 'lib/dpl/provider/pypi.rb', line 12

def initialize(*args)
  super(*args)
  self.class.pip 'wheel' if options[:distributions].to_s.include? 'bdist_wheel'
end

Class Method Details

.install_setuptoolsObject



7
8
9
10
# 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'
  shell 'rm -f setuptools-*.tar.gz'
end

Instance Method Details

#check_appObject



58
59
# File 'lib/dpl/provider/pypi.rb', line 58

def check_app
end

#check_authObject



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

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

#configObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dpl/provider/pypi.rb', line 19

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)


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

def needs_key?
  false
end

#push_appObject



65
66
67
68
69
# File 'lib/dpl/provider/pypi.rb', line 65

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



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

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



33
34
35
36
37
38
39
40
41
42
# File 'lib/dpl/provider/pypi.rb', line 33

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