poise-python 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.kitchen.yml +1 -6
  3. data/.travis.yml +7 -6
  4. data/CHANGELOG.md +7 -0
  5. data/Gemfile +3 -1
  6. data/README.md +9 -3
  7. data/Rakefile +1 -1
  8. data/chef/attributes/default.rb +1 -1
  9. data/chef/recipes/default.rb +1 -1
  10. data/lib/poise_python.rb +1 -1
  11. data/lib/poise_python/cheftie.rb +1 -1
  12. data/lib/poise_python/error.rb +1 -1
  13. data/lib/poise_python/python_command_mixin.rb +1 -1
  14. data/lib/poise_python/python_providers.rb +3 -1
  15. data/lib/poise_python/python_providers/base.rb +3 -3
  16. data/lib/poise_python/python_providers/dummy.rb +1 -1
  17. data/lib/poise_python/python_providers/msi.rb +64 -0
  18. data/lib/poise_python/python_providers/portable_pypy.rb +1 -1
  19. data/lib/poise_python/python_providers/portable_pypy3.rb +1 -1
  20. data/lib/poise_python/python_providers/scl.rb +1 -1
  21. data/lib/poise_python/python_providers/system.rb +3 -3
  22. data/lib/poise_python/resources.rb +1 -1
  23. data/lib/poise_python/resources/pip_requirements.rb +1 -1
  24. data/lib/poise_python/resources/python_execute.rb +1 -1
  25. data/lib/poise_python/resources/python_package.rb +14 -6
  26. data/lib/poise_python/resources/python_runtime.rb +1 -1
  27. data/lib/poise_python/resources/python_runtime_pip.rb +45 -28
  28. data/lib/poise_python/resources/python_runtime_test.rb +35 -32
  29. data/lib/poise_python/resources/python_virtualenv.rb +6 -2
  30. data/lib/poise_python/utils.rb +1 -1
  31. data/lib/poise_python/utils/python_encoder.rb +1 -1
  32. data/lib/poise_python/version.rb +2 -2
  33. data/poise-python.gemspec +4 -4
  34. data/test/{cookbooks/poise-python_test → cookbook}/metadata.rb +1 -1
  35. data/test/cookbook/recipes/default.rb +78 -0
  36. data/{Berksfile → test/gemfiles/chef-12.1.gemfile} +3 -12
  37. data/test/gemfiles/chef-12.2.gemfile +19 -0
  38. data/test/gemfiles/chef-12.3.gemfile +19 -0
  39. data/test/gemfiles/chef-12.4.gemfile +21 -0
  40. data/test/gemfiles/chef-12.5.gemfile +19 -0
  41. data/test/gemfiles/chef-12.6.gemfile +19 -0
  42. data/test/gemfiles/chef-12.gemfile +2 -2
  43. data/test/gemfiles/master.gemfile +3 -1
  44. data/test/integration/default/serverspec/default_spec.rb +23 -9
  45. data/test/spec/python_command_mixin_spec.rb +1 -1
  46. data/test/spec/python_providers/dummy_spec.rb +1 -1
  47. data/test/spec/python_providers/portable_pypy3_spec.rb +1 -1
  48. data/test/spec/python_providers/portable_pypy_spec.rb +1 -1
  49. data/test/spec/python_providers/scl_spec.rb +1 -1
  50. data/test/spec/python_providers/system_spec.rb +1 -1
  51. data/test/spec/resources/pip_requirements_spec.rb +1 -1
  52. data/test/spec/resources/python_package_spec.rb +1 -1
  53. data/test/spec/resources/python_runtime_pip_spec.rb +1 -1
  54. data/test/spec/resources/python_virtualenv_spec.rb +1 -1
  55. data/test/spec/spec_helper.rb +1 -1
  56. data/test/spec/utils/python_encoder_spec.rb +1 -1
  57. data/test/spec/utils_spec.rb +1 -1
  58. metadata +26 -15
  59. data/.kitchen.travis.yml +0 -9
  60. data/test/cookbooks/poise-python_test/recipes/default.rb +0 -65
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ module PoisePython
40
40
  attribute(:path, kind_of: String, default: lazy { default_path })
41
41
 
42
42
  def default_path
43
- ::File.join('', 'opt', "python_test_#{name}")
43
+ ::File.join('', "python_test_#{name}")
44
44
  end
45
45
  end
46
46
 
@@ -146,33 +146,36 @@ EOH
146
146
  end
147
147
  test_import('requests', 'requests_version', python: nil, virtualenv: ::File.join(new_resource.path, 'venv3'))
148
148
 
149
- # Create a non-root user and test installing with it.
150
- test_user = "py#{new_resource.name}"
151
- test_home = ::File.join('', 'home', test_user)
152
- group test_user do
153
- system true
154
- end
155
- user test_user do
156
- comment "Test user for python_runtime_test #{new_resource.name}"
157
- gid test_user
158
- home test_home
159
- shell '/bin/false'
160
- system true
161
- end
162
- directory test_home do
163
- mode '700'
164
- group test_user
165
- user test_user
166
- end
167
- test_venv = python_virtualenv ::File.join(test_home, 'env') do
168
- python new_resource.name
169
- user test_user
170
- end
171
- python_package 'attrs' do
172
- user test_user
173
- virtualenv test_venv
149
+ # Don't run the user tests on Windows.
150
+ unless node.platform_family?('windows')
151
+ # Create a non-root user and test installing with it.
152
+ test_user = "py#{new_resource.name}"
153
+ test_home = ::File.join('', 'home', test_user)
154
+ group 'g'+test_user do
155
+ system true
156
+ end
157
+ user test_user do
158
+ comment "Test user for python_runtime_test #{new_resource.name}"
159
+ gid 'g'+test_user
160
+ home test_home
161
+ shell '/bin/false'
162
+ system true
163
+ end
164
+ directory test_home do
165
+ mode '700'
166
+ group 'g'+test_user
167
+ user test_user
168
+ end
169
+ test_venv = python_virtualenv ::File.join(test_home, 'env') do
170
+ python new_resource.name
171
+ user test_user
172
+ end
173
+ python_package 'attrs' do
174
+ user test_user
175
+ virtualenv test_venv
176
+ end
177
+ test_import('attrs', 'attr', python: nil, virtualenv: test_venv, user: test_user)
174
178
  end
175
- test_import('attrs', 'attr', python: nil, virtualenv: test_venv, user: test_user)
176
179
  end
177
180
  end
178
181
 
@@ -187,8 +190,8 @@ EOH
187
190
  def test_version(python: new_resource.name, virtualenv: nil)
188
191
  # Only queue up this resource once, the ivar is just for tracking.
189
192
  @python_version_test ||= file ::File.join(new_resource.path, 'python_version.py') do
190
- user 'root'
191
- group 'root'
193
+ user node.platform_family?('windows') ? Poise::Utils::Win32.admin_user : 'root'
194
+ group node['root_group']
192
195
  mode '644'
193
196
  content <<-EOH
194
197
  import sys, platform
@@ -205,8 +208,8 @@ EOH
205
208
  def test_import(name, path=name, python: new_resource.name, virtualenv: nil, user: nil)
206
209
  # Only queue up this resource once, the ivar is just for tracking.
207
210
  @python_import_test ||= file ::File.join(new_resource.path, 'import_version.py') do
208
- user 'root'
209
- group 'root'
211
+ user node.platform_family?('windows') ? Poise::Utils::Win32.admin_user : 'root'
212
+ group node['root_group']
210
213
  mode '644'
211
214
  content <<-EOH
212
215
  try:
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -98,7 +98,11 @@ module PoisePython
98
98
  alias_method :action_delete, :action_uninstall
99
99
 
100
100
  def python_binary
101
- ::File.join(new_resource.path, 'bin', 'python')
101
+ if node.platform_family?('windows')
102
+ ::File.join(new_resource.path, 'Scripts', 'python.exe')
103
+ else
104
+ ::File.join(new_resource.path, 'bin', 'python')
105
+ end
102
106
  end
103
107
 
104
108
  def python_environment
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoisePython
19
- VERSION = '1.2.1'
19
+ VERSION = '1.3.0'
20
20
  end
data/poise-python.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -34,8 +34,8 @@ Gem::Specification.new do |spec|
34
34
  spec.require_paths = %w{lib}
35
35
 
36
36
  spec.add_dependency 'halite', '~> 1.0'
37
- spec.add_dependency 'poise', '~> 2.0'
38
- spec.add_dependency 'poise-languages', '~> 1.2'
37
+ spec.add_dependency 'poise', '~> 2.7'
38
+ spec.add_dependency 'poise-languages', '~> 1.3'
39
39
 
40
- spec.add_development_dependency 'poise-boiler', '~> 1.0'
40
+ spec.add_development_dependency 'poise-boiler', '~> 1.8'
41
41
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -0,0 +1,78 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'poise_python/resources/python_runtime_test'
18
+
19
+ # Install lsb-release because Debian 6 doesn't by default and serverspec requires it
20
+ package 'lsb-release' if platform?('debian') && node['platform_version'].start_with?('6')
21
+
22
+ # Which tests to run on each platform.
23
+ tests_to_run = value_for_platform(
24
+ default: %w{py2 py3 system pypy pip},
25
+ centos: {default: %w{py2 py3 system scl pypy pip}},
26
+ redhat: {default: %w{py2 py3 system scl pypy pip}},
27
+ ubuntu: {
28
+ '12.04' => %w{py2 pypy pip},
29
+ 'default' => %w{py2 py3 system pypy pip},
30
+ },
31
+ windows: {default: %w{py2 py3}},
32
+ )
33
+
34
+ %w{py2 py3 system pypy scl pip msi}.each do |test|
35
+ unless tests_to_run.include?(test)
36
+ file "/no_#{test}"
37
+ next
38
+ end
39
+
40
+ case test
41
+ when 'py2'
42
+ python_runtime_test '2'
43
+ when 'py3'
44
+ python_runtime_test '3'
45
+ when 'system'
46
+ python_runtime_test 'system' do
47
+ version ''
48
+ runtime_provider :system
49
+ end
50
+ when 'scl'
51
+ python_runtime_test 'scl' do
52
+ version ''
53
+ runtime_provider :scl
54
+ end
55
+ when 'pypy'
56
+ python_runtime_test 'pypy'
57
+ when 'pip'
58
+ # Specific test for pip reversion working correctly.
59
+ pip_provider = value_for_platform_family(default: :portable_pypy, windows: :msi)
60
+ python_runtime 'pip1' do
61
+ pip_version '7.1.2'
62
+ provider pip_provider
63
+ options path: '/test_pip1'
64
+ version ''
65
+ end
66
+ python_runtime 'pip2' do
67
+ provider pip_provider
68
+ options path: '/test_pip2'
69
+ version ''
70
+ end
71
+ python_runtime 'pip2b' do
72
+ pip_version '7.1.2'
73
+ provider pip_provider
74
+ options path: '/test_pip2'
75
+ version ''
76
+ end
77
+ end
78
+ end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,15 +14,6 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- source 'https://supermarket.chef.io/'
18
- extension 'halite'
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
19
18
 
20
- # Force the rebuild every time for development.
21
- cookbook 'poise', gem: 'poise'
22
- cookbook 'poise-languages', gem: 'poise-languages'
23
- cookbook 'poise-python', gem: 'poise-python'
24
-
25
- group :test do
26
- cookbook 'poise-python_test', path: 'test/cookbooks/poise-python_test'
27
- cookbook 'apt'
28
- end
19
+ gem 'chef', '~> 12.1.2'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.2.1'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.3.0'
@@ -0,0 +1,21 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.4.3'
20
+ # Pending https://github.com/berkshelf/ridley/pull/335
21
+ gem 'ridley', '4.4.1'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.5.1'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.6.0'
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -16,4 +16,4 @@
16
16
 
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
- gem 'chef', '~> 12.0'
19
+ gem 'chef', '~> 12.6'
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -19,5 +19,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
19
19
  gem 'chef', github: 'chef/chef'
20
20
  gem 'halite', github: 'poise/halite'
21
21
  gem 'poise', github: 'poise/poise'
22
+ gem 'poise-archive', github: 'poise/poise-archive'
22
23
  gem 'poise-boiler', github: 'poise/poise-boiler'
23
24
  gem 'poise-languages', github: 'poise/poise-languages'
25
+ gem 'poise-profiler', github: 'poise/poise-profiler'
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,13 +14,21 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'rbconfig'
18
+
17
19
  require 'serverspec'
18
- set :backend, :exec
20
+
21
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
22
+ set :backend, :cmd
23
+ set :os, :family => 'windows'
24
+ else
25
+ set :backend, :exec
26
+ end
19
27
 
20
28
  # Set up the shared example for python_runtime_test.
21
29
  RSpec.shared_examples 'a python_runtime_test' do |python_name, version=nil|
22
30
  let(:python_name) { python_name }
23
- let(:python_path) { File.join('', 'opt', "python_test_#{python_name}") }
31
+ let(:python_path) { File.join('', "python_test_#{python_name}") }
24
32
  # Helper for all the file checks.
25
33
  def self.assert_file(rel_path, should_exist=true, &block)
26
34
  describe rel_path do
@@ -73,16 +81,16 @@ RSpec.shared_examples 'a python_runtime_test' do |python_name, version=nil|
73
81
 
74
82
  describe 'pip_requirements' do
75
83
  assert_file('import_requests') do
76
- its(:content) { is_expected.to eq '2.7.0' }
84
+ its(:content) { is_expected.to match /^2\.7\.0\s*$/ }
77
85
  end
78
86
  assert_file('import_six') do
79
- its(:content) { is_expected.to eq '1.8.0' }
87
+ its(:content) { is_expected.to match /^1\.8\.0\s*$/ }
80
88
  end
81
89
  end
82
90
 
83
91
  describe 'non default version' do
84
92
  assert_file('import_requests_version') do
85
- its(:content) { is_expected.to eq '2.8.0' }
93
+ its(:content) { is_expected.to match /^2\.8\.0\s*$/ }
86
94
  end
87
95
  end
88
96
 
@@ -111,13 +119,19 @@ describe 'scl provider', unless: File.exist?('/no_scl') do
111
119
  it_should_behave_like 'a python_runtime_test', 'scl'
112
120
  end
113
121
 
114
- describe 'pip reversion test' do
115
- describe command('/opt/pip1/bin/pypy -m pip --version') do
122
+ describe 'pip reversion test', unless: File.exist?('/no_pip') do
123
+ path_suffix = if os[:family] == 'windows'
124
+ '/Scripts/python.exe'
125
+ else
126
+ '/bin/pypy'
127
+ end
128
+
129
+ describe command("/test_pip1#{path_suffix} -m pip --version") do
116
130
  its(:exit_status) { is_expected.to eq 0 }
117
131
  its(:stdout) { is_expected.to include '7.1.2' }
118
132
  end
119
133
 
120
- describe command('/opt/pip2/bin/pypy -m pip --version') do
134
+ describe command("/test_pip2#{path_suffix} -m pip --version") do
121
135
  its(:exit_status) { is_expected.to eq 0 }
122
136
  its(:stdout) { is_expected.to include '7.1.2' }
123
137
  end