Sha256: 14397a895e0d98ef02c36cb08ff4fa16373d343eb3d099585f8f36b2d8cb4f07

Contents?: true

Size: 1.73 KB

Versions: 29

Compression:

Stored size: 1.73 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'
        shell 'rm -f setuptools-*.tar.gz'
      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

29 entries across 29 versions & 1 rubygems

Version Path
dpl-1.5.3.travis.264.1 lib/dpl/provider/pypi.rb
dpl-1.5.3.travis.265.1 lib/dpl/provider/pypi.rb
dpl-1.5.3.travis.262.1 lib/dpl/provider/pypi.rb
dpl-1.5.3.travis.261.1 lib/dpl/provider/pypi.rb
dpl-1.5.3.travis.259.1 lib/dpl/provider/pypi.rb
dpl-1.5.3.travis.257.1 lib/dpl/provider/pypi.rb
dpl-1.5.3.travis.255.2 lib/dpl/provider/pypi.rb
dpl-1.5.3.travis.254.2 lib/dpl/provider/pypi.rb
dpl-1.5.3.travis.252.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.248.2 lib/dpl/provider/pypi.rb
dpl-1.5.3.travis.249.2 lib/dpl/provider/pypi.rb
dpl-1.5.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.245.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.244.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.243.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.242.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.241.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.240.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.226.2 lib/dpl/provider/pypi.rb
dpl-1.5.2.travis.220.2 lib/dpl/provider/pypi.rb