dpl-pypi 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e687c2bc72fb800e747b113560250e1807f46783
4
+ data.tar.gz: f699d025b50d3ce90be4cc3dce9ddd9b38524af5
5
+ SHA512:
6
+ metadata.gz: a35b0cad6c32393ab9737545f7a2940faa9f4b0cd03e13829f28a86b82325d00ae1f0b2cec66e94b3bf9df486b4948f6873818d381aec7afc2b2bb0f5b2db1a4
7
+ data.tar.gz: e647b53f420c0cb408a5f09cca11ed98f1a835b52af9dd5e0494a4c00dae3e5b234de78432a7f5f1515e9cb08951fb61223dfe682712b14a060092100c5bdc62
data/dpl-pypi.gemspec ADDED
@@ -0,0 +1,3 @@
1
+ require './gemspec_helper'
2
+
3
+ gemspec_for 'pypi'
@@ -0,0 +1,103 @@
1
+ module DPL
2
+ class Provider
3
+ class PyPI < Provider
4
+ DEFAULT_SERVER = 'https://upload.pypi.org/legacy/'
5
+ PYPIRC_FILE = '~/.pypirc'
6
+
7
+ def pypi_user
8
+ option(:username, :user) || context.env['PYPI_USER'] || context.env['PYPI_USERNAME']
9
+ end
10
+
11
+ def pypi_password
12
+ options[:password] || context.env['PYPI_PASSWORD']
13
+ end
14
+
15
+ def pypi_server
16
+ options[:server] || context.env['PYPI_SERVER'] || DEFAULT_SERVER
17
+ end
18
+
19
+ def pypi_distributions
20
+ options[:distributions] || context.env['PYPI_DISTRIBUTIONS'] || 'sdist'
21
+ end
22
+
23
+ def pypi_docs_dir_option
24
+ docs_dir = options[:docs_dir] || context.env['PYPI_DOCS_DIR'] || ''
25
+ if !docs_dir.empty?
26
+ '--upload-dir ' + docs_dir
27
+ end
28
+ end
29
+
30
+ def skip_upload_docs?
31
+ ! options.has_key?(:skip_upload_docs) ||
32
+ (options.has_key?(:skip_upload_docs) && options[:skip_upload_docs])
33
+ end
34
+
35
+ def install_deploy_dependencies
36
+ unless context.shell "wget -O - https://bootstrap.pypa.io/get-pip.py | python - --no-setuptools --no-wheel && " \
37
+ "pip install --upgrade setuptools twine wheel"
38
+ error "Couldn't install pip, setuptools, twine or wheel."
39
+ end
40
+ end
41
+
42
+ def config
43
+ {
44
+ :header => '[distutils]',
45
+ :servers_line => 'index-servers = pypi',
46
+ :servers => {
47
+ 'pypi' => [
48
+ "repository: #{pypi_server}",
49
+ "username: #{pypi_user}",
50
+ "password: #{pypi_password}",
51
+ ]
52
+ }
53
+ }
54
+ end
55
+
56
+ def write_servers(f)
57
+ config[:servers].each do |key, val|
58
+ f.puts " " * 4 + key
59
+ end
60
+
61
+ config[:servers].each do |key, val|
62
+ f.puts "[#{key}]"
63
+ f.puts val
64
+ end
65
+ end
66
+
67
+ def write_config
68
+ File.open(File.expand_path(PYPIRC_FILE), 'w') do |f|
69
+ config.each do |key, val|
70
+ f.puts(val) if val.is_a? String or val.is_a? Array
71
+ end
72
+ write_servers(f)
73
+ end
74
+ end
75
+
76
+ def check_auth
77
+ error "missing PyPI username" unless pypi_user
78
+ error "missing PyPI password" unless pypi_password
79
+ write_config
80
+ log "Authenticated as #{pypi_user}"
81
+ end
82
+
83
+ def check_app
84
+ end
85
+
86
+ def needs_key?
87
+ false
88
+ end
89
+
90
+ def push_app
91
+ context.shell "python setup.py #{pypi_distributions}"
92
+ unless context.shell "twine upload -r pypi dist/*"
93
+ error 'PyPI upload failed.'
94
+ end
95
+ context.shell "rm -rf dist/*"
96
+ unless skip_upload_docs?
97
+ log "Uploading documentation (skip with \"skip_upload_docs: true\")"
98
+ context.shell "python setup.py upload_docs #{pypi_docs_dir_option} -r #{pypi_server}"
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+ require 'dpl/provider/pypi'
3
+
4
+ describe DPL::Provider::PyPI do
5
+ subject :provider do
6
+ described_class.new(DummyContext.new, :user => 'foo', :password => 'bar')
7
+ end
8
+
9
+ describe "#install_deploy_dependencies" do
10
+ example do
11
+ expect(provider.context).to receive(:shell).with(
12
+ "wget -O - https://bootstrap.pypa.io/get-pip.py | python - --no-setuptools --no-wheel && pip install --upgrade setuptools twine wheel"
13
+ ).and_return(true)
14
+ provider.install_deploy_dependencies
15
+ end
16
+ end
17
+
18
+ describe "#config" do
19
+ it 'accepts a user and a password' do
20
+ expect(provider.config[:servers]['pypi']).to include 'username: foo'
21
+ expect(provider.config[:servers]['pypi']).to include 'password: bar'
22
+ end
23
+ end
24
+
25
+ describe "#check_auth" do
26
+ example do
27
+ expect(provider).to receive(:log).with("Authenticated as foo")
28
+ provider.check_auth
29
+ end
30
+ end
31
+
32
+ describe "#push_app" do
33
+ example "default" do
34
+ expect(provider.context).to receive(:shell).with("python setup.py sdist").and_return(true)
35
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*").and_return(true)
36
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*").and_return(true)
37
+ expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/")
38
+ provider.push_app
39
+ end
40
+
41
+ example "with :distributions option" do
42
+ provider.options.update(:distributions => 'sdist bdist')
43
+ expect(provider.context).to receive(:shell).with("python setup.py sdist bdist").and_return(true)
44
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*").and_return(true)
45
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*").and_return(true)
46
+ expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/")
47
+ provider.push_app
48
+ end
49
+
50
+ example "with :server option" do
51
+ provider.options.update(:server => 'http://blah.com')
52
+ expect(provider.context).to receive(:shell).with("python setup.py sdist").and_return(true)
53
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*").and_return(true)
54
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*").and_return(true)
55
+ expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r http://blah.com")
56
+ provider.push_app
57
+ end
58
+
59
+ example "with :skip_upload_docs option" do
60
+ provider.options.update(:skip_upload_docs => true)
61
+ expect(provider.context).to receive(:shell).with("python setup.py sdist").and_return(true)
62
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*").and_return(true)
63
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*").and_return(true)
64
+ expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/")
65
+ provider.push_app
66
+ end
67
+
68
+ context "with :skip_upload_docs option being false" do
69
+ before :each do
70
+ provider.options.update(:skip_upload_docs => false)
71
+ end
72
+
73
+ it "runs upload_docs" do
74
+ expect(provider.context).to receive(:shell).with("python setup.py sdist").and_return(true)
75
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*").and_return(true)
76
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*").and_return(true)
77
+ expect(provider.context).to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/").and_return(true)
78
+ provider.push_app
79
+ end
80
+
81
+ example "with :docs_dir option" do
82
+ provider.options.update(:docs_dir => 'some/dir')
83
+ expect(provider.context).to receive(:shell).with("python setup.py sdist").and_return(true)
84
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*").and_return(true)
85
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*").and_return(true)
86
+ expect(provider.context).to receive(:shell).with("python setup.py upload_docs --upload-dir some/dir -r https://upload.pypi.org/legacy/").and_return(true)
87
+ provider.push_app
88
+ end
89
+ end
90
+
91
+ end
92
+
93
+ describe "#write_servers" do
94
+ example do
95
+ f = double(:f)
96
+ expect(f).to receive(:puts).with(" pypi")
97
+ expect(f).to receive(:puts).with("[pypi]")
98
+ expect(f).to receive(:puts).with(["repository: https://upload.pypi.org/legacy/",
99
+ "username: foo",
100
+ "password: bar"
101
+ ])
102
+ provider.write_servers(f)
103
+ end
104
+ end
105
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dpl-pypi
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Konstantin Haase
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dpl
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-its
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json_pure
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tins
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: highline
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: deploy tool abstraction for clients
126
+ email: konstantin.mailinglists@googlemail.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - dpl-pypi.gemspec
132
+ - lib/dpl/provider/pypi.rb
133
+ - spec/provider/pypi_spec.rb
134
+ homepage: https://github.com/travis-ci/dpl
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '2.2'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.6.13
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: deploy tool
158
+ test_files:
159
+ - spec/provider/pypi_spec.rb