Sha256: 08f0624a701f7303baac493421644711e25bf275b752be8607c6402008e6a392

Contents?: true

Size: 1.69 KB

Versions: 27

Compression:

Stored size: 1.69 KB

Contents

module DPL
  class Provider
    class PyPI < Provider
      DEFAULT_SERVER = 'http://www.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'
      end

      install_setuptools

      def config
        {
          :header => '[distutils]',
          :servers_line => 'index-servers =',
          :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'}"
        context.shell "python setup.py upload_docs --upload-dir #{options[:docs_dir] || 'build/docs'}"
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
dpl-1.5.2.travis.196.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.194.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.193.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.190.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.188.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.187.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.184.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.183.2 lib/dpl/provider/pypi.rb
dpl-1.5.1 lib/dpl/provider/pypi.rb
dpl-1.5.1.travis.182.2 lib/dpl/provider/pypi.rb
dpl-1.5.1.travis.180.2 lib/dpl/provider/pypi.rb
dpl-1.5.1.travis.174.2 lib/dpl/provider/pypi.rb
dpl-1.5.1.travis.173.2 lib/dpl/provider/pypi.rb
dpl-1.5.1.travis.167.2 lib/dpl/provider/pypi.rb
dpl-1.5.0 lib/dpl/provider/pypi.rb
dpl-1.5.0.travis.166.2 lib/dpl/provider/pypi.rb
dpl-1.5.0.travis.164.2 lib/dpl/provider/pypi.rb
dpl-1.4.9.travis.163.2 lib/dpl/provider/pypi.rb
dpl-1.4.9 lib/dpl/provider/pypi.rb
dpl-1.4.9.travis.151.2 lib/dpl/provider/pypi.rb