class DPL::Provider::PyPI
Constants
- DEFAULT_SERVER
- PYPIRC_FILE
Public Instance Methods
check_app()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 122 def check_app end
check_auth()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 115 def check_auth error "missing PyPI username" unless pypi_user error "missing PyPI password" unless pypi_password write_config log "Authenticated as #{pypi_user}" end
config()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 78 def config servers = { 'pypi' => [ "username: #{pypi_user}", "password: #{pypi_password}", ] } if pypi_server servers['pypi'].insert(0, "repository: #{pypi_server}") end { :header => '[distutils]', :servers_line => 'index-servers = pypi', :servers => servers } end
install_deploy_dependencies()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 68 def install_deploy_dependencies # --user likely fails inside virtualenvs but is needed outside to avoid needing sudo. # `--upgrade-strategy eager` prevents the old resolver from keeping an outdated dependency if it's preinstalled unless context.shell "if [ -z ${VIRTUAL_ENV+x} ]; then export PIP_USER=yes; fi && " \ "wget -nv -O - https://bootstrap.pypa.io/get-pip.py | python - --no-setuptools --no-wheel && " \ "pip install --upgrade --upgrade-strategy eager #{pypi_setuptools_arg} #{pypi_twine_arg} #{pypi_wheel_arg}" error "Couldn't install pip, setuptools, twine or wheel." end end
needs_key?()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 125 def needs_key? false end
push_app()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 129 def push_app context.shell "python setup.py #{pypi_distributions}" unless context.shell "twine upload#{pypi_skip_existing_option} -r pypi dist/*" error 'PyPI upload failed.' end context.shell "rm -rf dist/*" unless skip_upload_docs? log "Uploading documentation (skip with \"skip_upload_docs: true\")" context.shell "python setup.py upload_docs #{pypi_docs_dir_option} -r #{pypi_server}" end end
pypi_distributions()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 19 def pypi_distributions options[:distributions] || context.env['PYPI_DISTRIBUTIONS'] || 'sdist' end
pypi_docs_dir_option()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 23 def pypi_docs_dir_option docs_dir = options[:docs_dir] || context.env['PYPI_DOCS_DIR'] || '' if !docs_dir.empty? '--upload-dir ' + docs_dir end end
pypi_password()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 11 def pypi_password options[:password] || context.env['PYPI_PASSWORD'] end
pypi_server()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 15 def pypi_server options[:server] || context.env['PYPI_SERVER'] || DEFAULT_SERVER end
pypi_setuptools_arg()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 41 def pypi_setuptools_arg setuptools_version = options[:setuptools_version] || context.env['SETUPTOOLS_VERSION'] || '' if setuptools_version[/\A\d+(?:\.\d+)*\z/] 'setuptools==' + setuptools_version else 'setuptools' end end
pypi_skip_existing_option()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 35 def pypi_skip_existing_option if options.fetch(:skip_existing, false) ' --skip-existing' end end
pypi_twine_arg()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 50 def pypi_twine_arg twine_version = options[:twine_version] || context.env['TWINE_VERSION'] || '' if twine_version[/\A\d+(?:\.\d+)*\z/] 'twine==' + twine_version else 'twine' end end
pypi_user()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 7 def pypi_user option(:username, :user) || context.env['PYPI_USER'] || context.env['PYPI_USERNAME'] end
pypi_wheel_arg()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 59 def pypi_wheel_arg wheel_version = options[:wheel_version] || context.env['WHEEL_VERSION'] || '' if wheel_version[/\A\d+(?:\.\d+)*\z/] 'wheel==' + wheel_version else 'wheel' end end
skip_upload_docs?()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 30 def skip_upload_docs? ! options.has_key?(:skip_upload_docs) || (options.has_key?(:skip_upload_docs) && options[:skip_upload_docs]) end
write_config()
click to toggle source
# File lib/dpl/provider/pypi.rb, line 106 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)
click to toggle source
# File lib/dpl/provider/pypi.rb, line 95 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