Sha256: f70dafc1f2a7cc9ff00d3bb0aa8fc16c1b91f9cd25ed384cf750887b59e739c8

Contents?: true

Size: 1.87 KB

Versions: 95

Compression:

Stored size: 1.87 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 =',
          :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

95 entries across 95 versions & 1 rubygems

Version Path
dpl-1.7.3.travis.594.1 lib/dpl/provider/pypi.rb
dpl-1.7.2 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.592.1 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.591.1 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.590.1 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.589.1 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.588.1 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.586.1 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.584.1 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.582.1 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.581.1 lib/dpl/provider/pypi.rb
dpl-1.7.1 lib/dpl/provider/pypi.rb
dpl-1.7.2.travis.579.1 lib/dpl/provider/pypi.rb
dpl-1.7.1.travis.578.1 lib/dpl/provider/pypi.rb
dpl-1.7.1.travis.577.1 lib/dpl/provider/pypi.rb
dpl-1.7.1.travis.575.1 lib/dpl/provider/pypi.rb
dpl-1.7.1.travis.570.1 lib/dpl/provider/pypi.rb
dpl-1.7.1.travis.567.1 lib/dpl/provider/pypi.rb
dpl-1.7.1.travis.561.1 lib/dpl/provider/pypi.rb
dpl-1.6.10.travis.560.1 lib/dpl/provider/pypi.rb