Sha256: 57a34fc64c4c8f903cef41a6166a601f5dfcbe60eafded379e058e9a596aa1fb

Contents?: true

Size: 1.99 KB

Versions: 17

Compression:

Stored size: 1.99 KB

Contents

module DPL
  class Provider
    class PyPI < Provider
      DEFAULT_SERVER = 'http://pypi.python.org/pypi'
      PYPIRC_FILE = '~/.pypirc'

      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

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

      install_setuptools

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

      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

      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

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

      def check_app
      end

      def needs_key?
        false
      end

      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'}"
        if options[:docs_dir]
          docs_dir_option = '--upload-dir ' + options[:docs_dir]
        else
          docs_dir_option = ''
        end
        context.shell "python setup.py upload_docs #{docs_dir_option}"
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
dpl-1.7.12.travis.774.4 lib/dpl/provider/pypi.rb
dpl-1.7.12.travis.773.4 lib/dpl/provider/pypi.rb
dpl-1.7.12.travis.766.4 lib/dpl/provider/pypi.rb
dpl-1.7.12.travis.764.4 lib/dpl/provider/pypi.rb
dpl-1.7.12.travis.763.4 lib/dpl/provider/pypi.rb
dpl-1.7.12.travis.762.4 lib/dpl/provider/pypi.rb
dpl-1.7.12.travis.748.4 lib/dpl/provider/pypi.rb
dpl-1.7.12.travis.742.4 lib/dpl/provider/pypi.rb
dpl-1.7.12.travis.734.4 lib/dpl/provider/pypi.rb
dpl-1.7.11.travis.733.4 lib/dpl/provider/pypi.rb
dpl-1.7.11 lib/dpl/provider/pypi.rb
dpl-1.7.10 lib/dpl/provider/pypi.rb
dpl-1.7.11.travis.726.4 lib/dpl/provider/pypi.rb
dpl-1.7.10.travis.725.4 lib/dpl/provider/pypi.rb
dpl-1.7.10.travis.701.4 lib/dpl/provider/pypi.rb
dpl-1.7.10.travis.700.4 lib/dpl/provider/pypi.rb
dpl-1.7.10.travis.699.1 lib/dpl/provider/pypi.rb