autoproj 2.12.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +25 -0
  3. data/.github/workflows/test.yml +30 -0
  4. data/.rubocop.yml +79 -91
  5. data/.rubocop_todo.yml +1473 -0
  6. data/Gemfile +9 -9
  7. data/Rakefile +24 -24
  8. data/autoproj.gemspec +22 -22
  9. data/bin/alocate +4 -4
  10. data/bin/alog +6 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +2 -2
  14. data/bin/autoproj_bootstrap +186 -183
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +185 -182
  17. data/bin/autoproj_install.in +6 -7
  18. data/lib/autoproj/aruba_minitest.rb +6 -11
  19. data/lib/autoproj/autobuild.rb +5 -6
  20. data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
  21. data/lib/autoproj/autobuild_extensions/dsl.rb +61 -44
  22. data/lib/autoproj/autobuild_extensions/git.rb +27 -26
  23. data/lib/autoproj/autobuild_extensions/package.rb +23 -22
  24. data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
  25. data/lib/autoproj/base.rb +1 -1
  26. data/lib/autoproj/bash_completion.rb +5 -6
  27. data/lib/autoproj/build_option.rb +22 -24
  28. data/lib/autoproj/cli/base.rb +27 -27
  29. data/lib/autoproj/cli/bootstrap.rb +14 -16
  30. data/lib/autoproj/cli/build.rb +18 -10
  31. data/lib/autoproj/cli/cache.rb +51 -8
  32. data/lib/autoproj/cli/clean.rb +10 -10
  33. data/lib/autoproj/cli/commit.rb +7 -8
  34. data/lib/autoproj/cli/doc.rb +2 -2
  35. data/lib/autoproj/cli/envsh.rb +1 -2
  36. data/lib/autoproj/cli/exec.rb +60 -20
  37. data/lib/autoproj/cli/inspection_tool.rb +18 -13
  38. data/lib/autoproj/cli/locate.rb +30 -41
  39. data/lib/autoproj/cli/log.rb +7 -7
  40. data/lib/autoproj/cli/main.rb +217 -205
  41. data/lib/autoproj/cli/main_doc.rb +22 -21
  42. data/lib/autoproj/cli/main_global.rb +44 -19
  43. data/lib/autoproj/cli/main_plugin.rb +18 -18
  44. data/lib/autoproj/cli/main_test.rb +28 -27
  45. data/lib/autoproj/cli/manifest.rb +7 -7
  46. data/lib/autoproj/cli/osdeps.rb +12 -11
  47. data/lib/autoproj/cli/patcher.rb +2 -3
  48. data/lib/autoproj/cli/query.rb +17 -18
  49. data/lib/autoproj/cli/reconfigure.rb +1 -2
  50. data/lib/autoproj/cli/reset.rb +9 -12
  51. data/lib/autoproj/cli/show.rb +48 -55
  52. data/lib/autoproj/cli/status.rb +56 -44
  53. data/lib/autoproj/cli/switch_config.rb +5 -6
  54. data/lib/autoproj/cli/tag.rb +12 -11
  55. data/lib/autoproj/cli/test.rb +7 -7
  56. data/lib/autoproj/cli/update.rb +104 -51
  57. data/lib/autoproj/cli/utility.rb +14 -12
  58. data/lib/autoproj/cli/version.rb +42 -40
  59. data/lib/autoproj/cli/versions.rb +14 -15
  60. data/lib/autoproj/cli/watch.rb +33 -37
  61. data/lib/autoproj/cli/which.rb +16 -20
  62. data/lib/autoproj/cli.rb +4 -2
  63. data/lib/autoproj/configuration.rb +78 -85
  64. data/lib/autoproj/default.osdeps +29 -3
  65. data/lib/autoproj/environment.rb +42 -23
  66. data/lib/autoproj/exceptions.rb +9 -3
  67. data/lib/autoproj/find_workspace.rb +20 -25
  68. data/lib/autoproj/git_server_configuration.rb +40 -44
  69. data/lib/autoproj/gitorious.rb +1 -1
  70. data/lib/autoproj/installation_manifest.rb +64 -29
  71. data/lib/autoproj/local_package_set.rb +13 -11
  72. data/lib/autoproj/manifest.rb +145 -135
  73. data/lib/autoproj/metapackage.rb +2 -6
  74. data/lib/autoproj/ops/atomic_write.rb +7 -6
  75. data/lib/autoproj/ops/build.rb +4 -6
  76. data/lib/autoproj/ops/cache.rb +64 -53
  77. data/lib/autoproj/ops/cached_env.rb +7 -6
  78. data/lib/autoproj/ops/configuration.rb +511 -506
  79. data/lib/autoproj/ops/import.rb +90 -61
  80. data/lib/autoproj/ops/install.rb +179 -175
  81. data/lib/autoproj/ops/loader.rb +77 -76
  82. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  83. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  84. data/lib/autoproj/ops/snapshot.rb +250 -247
  85. data/lib/autoproj/ops/tools.rb +76 -78
  86. data/lib/autoproj/ops/watch.rb +6 -6
  87. data/lib/autoproj/ops/which.rb +17 -14
  88. data/lib/autoproj/options.rb +13 -2
  89. data/lib/autoproj/os_package_installer.rb +102 -92
  90. data/lib/autoproj/os_package_query.rb +7 -13
  91. data/lib/autoproj/os_package_resolver.rb +189 -140
  92. data/lib/autoproj/os_repository_installer.rb +4 -4
  93. data/lib/autoproj/os_repository_resolver.rb +8 -6
  94. data/lib/autoproj/package_definition.rb +12 -13
  95. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +46 -31
  96. data/lib/autoproj/package_managers/bundler_manager.rb +156 -118
  97. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  98. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  99. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  100. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  101. data/lib/autoproj/package_managers/manager.rb +8 -3
  102. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  103. data/lib/autoproj/package_managers/pip_manager.rb +37 -27
  104. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  105. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  106. data/lib/autoproj/package_managers/shell_script_manager.rb +66 -36
  107. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  108. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  109. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  110. data/lib/autoproj/package_manifest.rb +66 -53
  111. data/lib/autoproj/package_selection.rb +187 -187
  112. data/lib/autoproj/package_set.rb +128 -114
  113. data/lib/autoproj/python.rb +285 -0
  114. data/lib/autoproj/query_base.rb +20 -14
  115. data/lib/autoproj/reporter.rb +19 -19
  116. data/lib/autoproj/repository_managers/apt.rb +101 -67
  117. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  118. data/lib/autoproj/shell_completion.rb +16 -13
  119. data/lib/autoproj/source_package_query.rb +29 -36
  120. data/lib/autoproj/system.rb +32 -21
  121. data/lib/autoproj/test.rb +131 -106
  122. data/lib/autoproj/variable_expansion.rb +10 -10
  123. data/lib/autoproj/vcs_definition.rb +53 -37
  124. data/lib/autoproj/version.rb +1 -1
  125. data/lib/autoproj/workspace.rb +162 -117
  126. data/lib/autoproj/zsh_completion.rb +8 -9
  127. data/lib/autoproj.rb +53 -53
  128. data/samples/autoproj/init.rb +1 -2
  129. metadata +62 -72
  130. data/.travis.yml +0 -22
@@ -27,29 +27,29 @@ module Autoproj
27
27
  # of GEM_PATH
28
28
  def initialize_environment
29
29
  env = ws.env
30
- env.original_env['GEM_PATH'] =
31
- (env['GEM_PATH'] || "").split(File::PATH_SEPARATOR).find_all do |p|
30
+ env.original_env["GEM_PATH"] =
31
+ (env["GEM_PATH"] || "").split(File::PATH_SEPARATOR).find_all do |p|
32
32
  !Autoproj.in_autoproj_installation?(p)
33
33
  end.join(File::PATH_SEPARATOR)
34
- env.inherit 'GEM_PATH'
35
- env.init_from_env 'GEM_PATH'
34
+ env.inherit "GEM_PATH"
35
+ env.init_from_env "GEM_PATH"
36
36
 
37
- orig_gem_path = env.original_env['GEM_PATH'].split(File::PATH_SEPARATOR)
38
- env.system_env['GEM_PATH'] = Gem.default_path
39
- env.original_env['GEM_PATH'] = orig_gem_path.join(File::PATH_SEPARATOR)
37
+ orig_gem_path = env.original_env["GEM_PATH"].split(File::PATH_SEPARATOR)
38
+ env.system_env["GEM_PATH"] = Gem.default_path
39
+ env.original_env["GEM_PATH"] = orig_gem_path.join(File::PATH_SEPARATOR)
40
40
 
41
41
  ws.config.each_reused_autoproj_installation do |p|
42
- p_gems = File.join(p, '.gems')
42
+ p_gems = File.join(p, ".gems")
43
43
  if File.directory?(p_gems)
44
- env.push_path 'GEM_PATH', p_gems
45
- env.push_path 'PATH', File.join(p_gems, 'bin')
44
+ env.push_path "GEM_PATH", p_gems
45
+ env.push_path "PATH", File.join(p_gems, "bin")
46
46
  end
47
47
  end
48
48
 
49
- @gem_home = (ENV['AUTOPROJ_GEM_HOME'] || File.join(ws.root_dir, ".gems"))
50
- env.push_path 'GEM_PATH', gem_home
51
- env.set 'GEM_HOME', gem_home
52
- env.push_path 'PATH', "#{gem_home}/bin"
49
+ @gem_home = (ENV["AUTOPROJ_GEM_HOME"] || File.join(ws.root_dir, ".gems"))
50
+ env.push_path "GEM_PATH", gem_home
51
+ env.set "GEM_HOME", gem_home
52
+ env.push_path "PATH", "#{gem_home}/bin"
53
53
 
54
54
  # Now, reset the directories in our own RubyGems instance
55
55
  Gem.paths = env.resolved_env
@@ -59,47 +59,47 @@ module Autoproj
59
59
 
60
60
  # Override the gem home detected by {initialize_environment}, or set
61
61
  # it in cases where calling {initialize_environment} is not possible
62
- def self.gem_home=(gem_home)
63
- @gem_home = gem_home
62
+ class << self
63
+ attr_writer :gem_home
64
64
  end
65
65
 
66
66
  # A global cache directory that should be used to avoid
67
67
  # re-downloading gems
68
68
  def self.cache_dir
69
- if dir = ENV['AUTOBUILD_CACHE_DIR']
70
- dir = File.join(dir, 'gems')
71
- FileUtils.mkdir_p dir
72
- dir
73
- end
69
+ return unless (dir = ENV["AUTOBUILD_CACHE_DIR"])
70
+
71
+ dir = File.join(dir, "gems")
72
+ FileUtils.mkdir_p dir
73
+ dir
74
74
  end
75
75
 
76
76
  def self.use_cache_dir
77
77
  # If there is a cache directory, make sure .gems/cache points to
78
78
  # it (there are no programmatic ways to override this)
79
- if cache = cache_dir
80
- gem_cache_dir = File.join(gem_home, 'cache')
81
- if !File.symlink?(gem_cache_dir) || File.readlink(gem_cache_dir) != cache
82
- FileUtils.mkdir_p gem_home
83
- FileUtils.rm_rf gem_cache_dir
84
- Autoproj.create_symlink(cache, gem_cache_dir)
85
- end
79
+ return unless (cache = cache_dir)
80
+
81
+ gem_cache_dir = File.join(gem_home, "cache")
82
+ if !File.symlink?(gem_cache_dir) || File.readlink(gem_cache_dir) != cache
83
+ FileUtils.mkdir_p gem_home
84
+ FileUtils.rm_rf gem_cache_dir
85
+ Autoproj.create_symlink(cache, gem_cache_dir)
86
86
  end
87
87
  end
88
88
 
89
89
  # Return the directory in which RubyGems package should be installed
90
- def self.gem_home
91
- @gem_home
90
+ class << self
91
+ attr_reader :gem_home
92
92
  end
93
93
 
94
94
  @gem_home = nil
95
-
95
+
96
96
  # Returns the set of default options that are added to gem
97
97
  #
98
98
  # By default, we add --no-user-install to un-break distributions
99
99
  # like Arch that set --user-install by default (thus disabling the
100
100
  # role of GEM_HOME)
101
101
  def self.default_install_options
102
- @default_install_options ||= ['--no-user-install', '--no-format-executable']
102
+ @default_install_options ||= ["--no-user-install", "--no-format-executable"]
103
103
  end
104
104
 
105
105
  def initialize(ws)
@@ -115,7 +115,7 @@ module Autoproj
115
115
  attr_reader :installed_gems
116
116
 
117
117
  def gem_fetcher
118
- if !@gem_fetcher
118
+ unless @gem_fetcher
119
119
  Autoproj.message " looking for RubyGems updates"
120
120
  @gem_fetcher = Gem::SpecFetcher.fetcher
121
121
  end
@@ -123,35 +123,29 @@ module Autoproj
123
123
  end
124
124
 
125
125
  def guess_gem_program
126
- if Autobuild.programs['gem']
127
- return Autobuild.programs['gem']
128
- end
126
+ return Autobuild.programs["gem"] if Autobuild.programs["gem"]
129
127
 
130
- ruby_bin = RbConfig::CONFIG['RUBY_INSTALL_NAME']
131
- ruby_bindir = RbConfig::CONFIG['bindir']
128
+ ruby_bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
129
+ ruby_bindir = RbConfig::CONFIG["bindir"]
132
130
 
133
- candidates = ['gem']
134
- if ruby_bin =~ /^ruby(.+)$/
135
- candidates << "gem#{$1}"
136
- end
131
+ candidates = ["gem"]
132
+ candidates << "gem#{$1}" if ruby_bin =~ /^ruby(.+)$/
137
133
 
138
134
  candidates.each do |gem_name|
139
135
  if File.file?(gem_full_path = File.join(ruby_bindir, gem_name))
140
- Autobuild.programs['gem'] = gem_full_path
136
+ Autobuild.programs["gem"] = gem_full_path
141
137
  return
142
138
  end
143
139
  end
144
140
 
145
- raise ArgumentError, "cannot find a gem program (tried #{candidates.sort.join(", ")} in #{ruby_bindir})"
141
+ raise ArgumentError, "cannot find a gem program (tried #{candidates.sort.join(', ')} in #{ruby_bindir})"
146
142
  end
147
143
 
148
144
  def build_gem_cmdlines(gems)
149
145
  with_version, without_version = gems.partition { |name, v| v }
150
146
 
151
147
  cmdlines = []
152
- if !without_version.empty?
153
- cmdlines << without_version.flatten
154
- end
148
+ cmdlines << without_version.flatten unless without_version.empty?
155
149
  with_version.each do |name, v|
156
150
  cmdlines << [name, "-v", v]
157
151
  end
@@ -160,17 +154,17 @@ module Autoproj
160
154
 
161
155
  def pristine(gems)
162
156
  guess_gem_program
163
- base_cmdline = [Autobuild.tool_in_path('ruby', env: ws.env), '-S', Autobuild.tool('gem')]
157
+ base_cmdline = [Autobuild.tool_in_path("ruby", env: ws.env), "-S", Autobuild.tool("gem")]
164
158
  cmdlines = [
165
- [*base_cmdline, 'clean'],
159
+ [*base_cmdline, "clean"]
166
160
  ]
167
161
  cmdlines += build_gem_cmdlines(gems).map do |line|
168
162
  base_cmdline + ["pristine", "--extensions"] + line
169
163
  end
170
164
  if gems_interaction(gems, cmdlines)
171
- Autoproj.message " restoring RubyGems: #{gems.map { |g| g.join(" ") }.sort.join(", ")}"
165
+ Autoproj.message " restoring RubyGems: #{gems.map { |g| g.join(' ') }.sort.join(', ')}"
172
166
  cmdlines.each do |c|
173
- Autobuild::Subprocess.run 'autoproj', 'osdeps', *c
167
+ Autobuild::Subprocess.run "autoproj", "osdeps", *c
174
168
  end
175
169
  end
176
170
  end
@@ -178,25 +172,21 @@ module Autoproj
178
172
  def install(gems)
179
173
  guess_gem_program
180
174
 
181
- base_cmdline = [Autobuild.tool_in_path('ruby', env: ws.env), '-S', Autobuild.tool('gem'), 'install', *GemManager.default_install_options]
182
- if !GemManager.with_doc
183
- base_cmdline << '--no-rdoc' << '--no-ri'
184
- end
175
+ base_cmdline = [Autobuild.tool_in_path("ruby", env: ws.env), "-S", Autobuild.tool("gem"), "install", *GemManager.default_install_options]
176
+ base_cmdline << "--no-rdoc" << "--no-ri" unless GemManager.with_doc
185
177
 
186
- if GemManager.with_prerelease
187
- base_cmdline << "--prerelease"
188
- end
178
+ base_cmdline << "--prerelease" if GemManager.with_prerelease
189
179
 
190
180
  cmdlines = build_gem_cmdlines(gems).map do |line|
191
181
  base_cmdline + line
192
182
  end
193
183
  if gems_interaction(gems, cmdlines)
194
- Autoproj.message " installing/updating RubyGems dependencies: #{gems.map { |g| g.join(" ") }.sort.join(", ")}"
184
+ Autoproj.message " installing/updating RubyGems dependencies: #{gems.map { |g| g.join(' ') }.sort.join(', ')}"
195
185
 
196
186
  cmdlines.each do |c|
197
- Autobuild::Subprocess.run 'autoproj', 'osdeps', *c,
198
- env: Hash['GEM_HOME' => Gem.paths.home,
199
- 'GEM_PATH' => Gem.paths.path.join(":")]
187
+ Autobuild::Subprocess.run "autoproj", "osdeps", *c,
188
+ env: Hash["GEM_HOME" => Gem.paths.home,
189
+ "GEM_PATH" => Gem.paths.path.join(":")]
200
190
  end
201
191
  gems.each do |name, v|
202
192
  installed_gems << name
@@ -209,14 +199,14 @@ module Autoproj
209
199
  # installed, or that can be upgraded
210
200
  def filter_uptodate_packages(gems, options = Hash.new)
211
201
  options = validate_options options,
212
- install_only: !Autobuild.do_update
202
+ install_only: !Autobuild.do_update
213
203
 
214
204
  # Don't install gems that are already there ...
215
205
  gems = gems.dup
216
206
  gems.delete_if do |name, version|
217
207
  next(true) if installed_gems.include?(name)
218
208
 
219
- version_requirements = Gem::Requirement.new(version || '>= 0')
209
+ version_requirements = Gem::Requirement.new(version || ">= 0")
220
210
  installed =
221
211
  if Gem::Specification.respond_to?(:find_by_name)
222
212
  begin
@@ -236,14 +226,16 @@ module Autoproj
236
226
  non_prerelease = gem_fetcher.find_matching(dep, true, true).map(&:first)
237
227
  if GemManager.with_prerelease
238
228
  prerelease = gem_fetcher.find_matching(dep, false, true, true).map(&:first)
239
- else prerelease = Array.new
229
+ else
230
+ prerelease = Array.new
240
231
  end
241
- (non_prerelease + prerelease).
242
- map { |n, v, _| [n, v] }
232
+ (non_prerelease + prerelease)
233
+ .map { |n, v, _| [n, v] }
243
234
 
244
235
  else # Post RubyGems-2.0
245
236
  type = if GemManager.with_prerelease then :complete
246
- else :released
237
+ else
238
+ :released
247
239
  end
248
240
 
249
241
  gem_fetcher.detect(type) do |tuple|
@@ -252,7 +244,7 @@ module Autoproj
252
244
  end
253
245
  installed_version = installed.map(&:version).max
254
246
  available_version = available.map { |_, v| v }.max
255
- if !available_version
247
+ unless available_version
256
248
  if version
257
249
  raise ConfigError.new, "cannot find any gem with the name '#{name}' and version #{version}"
258
250
  else
@@ -288,22 +280,22 @@ module Autoproj
288
280
  # We're not supposed to install rubygem packages but silent is not
289
281
  # set, so display information about them anyway
290
282
  puts <<-EOMSG
291
- #{Autoproj.color("The build process and/or the packages require some Ruby Gems to be installed", :bold)}
292
- #{Autoproj.color("and you required autoproj to not do it itself", :bold)}
283
+ #{Autoproj.color('The build process and/or the packages require some Ruby Gems to be installed', :bold)}
284
+ #{Autoproj.color('and you required autoproj to not do it itself', :bold)}
293
285
  You can use the --all or --ruby options to autoproj osdeps to install these
294
286
  packages anyway, and/or change to the osdeps handling mode by running an
295
287
  autoproj operation with the --reconfigure option as for instance
296
288
  autoproj build --reconfigure
297
-
289
+ #{' '}
298
290
  The following command line can be used to install them manually
299
-
300
- #{cmdlines.map { |c| c.join(" ") }.join("\n ")}
301
-
291
+ #{' '}
292
+ #{cmdlines.map { |c| c.join(' ') }.join("\n ")}
293
+ #{' '}
302
294
  Autoproj expects these Gems to be installed in #{GemManager.gem_home} This can
303
295
  be overridden by setting the AUTOPROJ_GEM_HOME environment variable manually
304
296
 
305
297
  EOMSG
306
- print " #{Autoproj.color("Press ENTER to continue ", :bold)}"
298
+ print " #{Autoproj.color('Press ENTER to continue ', :bold)}"
307
299
 
308
300
  STDOUT.flush
309
301
  STDIN.readline
@@ -313,4 +305,3 @@ module Autoproj
313
305
  end
314
306
  end
315
307
  end
316
-
@@ -5,8 +5,8 @@ module Autoproj
5
5
  class HomebrewManager < ShellScriptManager
6
6
  def initialize(ws)
7
7
  super(ws, true,
8
- %w{brew install},
9
- %w{brew install},
8
+ %w[brew install],
9
+ %w[brew install],
10
10
  false)
11
11
  end
12
12
 
@@ -16,7 +16,7 @@ module Autoproj
16
16
  packages = packages.uniq
17
17
  command_line = "brew info --json=v1 #{packages.join(' ')}"
18
18
  result = Autoproj.bundler_with_unbundled_env do
19
- (Autobuild::Subprocess.run 'autoproj', 'osdeps', command_line).first
19
+ (Autobuild::Subprocess.run "autoproj", "osdeps", command_line).first
20
20
  end
21
21
 
22
22
  begin
@@ -53,4 +53,3 @@ module Autoproj
53
53
  end
54
54
  end
55
55
  end
56
-
@@ -11,10 +11,16 @@ module Autoproj
11
11
  attr_reader :ws
12
12
 
13
13
  attr_writer :enabled
14
- def enabled?; !!@enabled end
14
+
15
+ def enabled?
16
+ !!@enabled
17
+ end
15
18
 
16
19
  attr_writer :silent
17
- def silent?; !!@silent end
20
+
21
+ def silent?
22
+ !!@silent
23
+ end
18
24
 
19
25
  # Whether this package manager should be called even if no packages
20
26
  # should be installed
@@ -68,4 +74,3 @@ module Autoproj
68
74
  end
69
75
  end
70
76
  end
71
-
@@ -5,10 +5,9 @@ module Autoproj
5
5
  class PacmanManager < ShellScriptManager
6
6
  def initialize(ws)
7
7
  super(ws, true,
8
- %w{pacman -Sy --needed},
9
- %w{pacman -Sy --needed --noconfirm})
8
+ %w[pacman -Sy --needed],
9
+ %w[pacman -Sy --needed --noconfirm])
10
10
  end
11
11
  end
12
12
  end
13
13
  end
14
-
@@ -1,3 +1,5 @@
1
+ require "autoproj/python"
2
+
1
3
  module Autoproj
2
4
  module PackageManagers
3
5
  # Using pip to install python packages
@@ -5,14 +7,14 @@ module Autoproj
5
7
  attr_reader :installed_pips
6
8
 
7
9
  def initialize_environment
8
- ws.env.set 'PYTHONUSERBASE', pip_home
9
- ws.env.add_path 'PATH', File.join(pip_home, 'bin')
10
+ ws.env.set "PYTHONUSERBASE", pip_home
11
+ ws.env.add_path "PATH", File.join(pip_home, "bin")
10
12
  end
11
13
 
12
14
  # Return the directory where python packages are installed to.
13
15
  # The actual path is pip_home/lib/pythonx.y/site-packages.
14
16
  def pip_home
15
- ws.env['AUTOPROJ_PYTHONUSERBASE'] || File.join(ws.prefix_dir, "pip")
17
+ ws.env["AUTOPROJ_PYTHONUSERBASE"] || File.join(ws.prefix_dir, "pip")
16
18
  end
17
19
 
18
20
  def initialize(ws)
@@ -21,34 +23,43 @@ module Autoproj
21
23
  end
22
24
 
23
25
  def os_dependencies
24
- super + ['pip']
26
+ super + ["pip"]
25
27
  end
26
28
 
27
29
  def guess_pip_program
28
- if Autobuild.programs['pip']
29
- return Autobuild.programs['pip']
30
+ unless ws.config.has_value_for?("USE_PYTHON")
31
+ Autoproj::Python.setup_python_configuration_options(ws: ws)
32
+ end
33
+ unless ws.config.get("USE_PYTHON")
34
+ raise ConfigError,
35
+ "Your current package selection requires the use of pip, but" \
36
+ " the use of python is either unspecified or has been denied,"\
37
+ " see setting of USE_PYTHON in your workspace configuration." \
38
+ " Either remove all packages depending on pip packages " \
39
+ " from the workspace layout (manifest) or " \
40
+ " call 'autoproj reconfigure' to change the setting."
41
+
30
42
  end
31
43
 
32
- Autobuild.programs['pip'] = "pip"
44
+ Autobuild.programs["pip"] = "pip" unless Autobuild.programs["pip"]
45
+ Autobuild.programs["pip"]
33
46
  end
34
47
 
35
48
  def install(pips, filter_uptodate_packages: false, install_only: false)
36
49
  guess_pip_program
37
- if pips.is_a?(String)
38
- pips = [pips]
39
- end
50
+ pips = [pips] if pips.is_a?(String)
40
51
 
41
- base_cmdline = [Autobuild.tool('pip'), 'install','--user']
52
+ base_cmdline = [Autobuild.tool("pip"), "install", "--user"]
42
53
 
43
54
  cmdlines = [base_cmdline + pips]
44
55
 
45
- if pips_interaction(pips, cmdlines)
46
- Autoproj.message " installing/updating Python dependencies: "+
47
- "#{pips.sort.join(", ")}"
56
+ if pips_interaction(cmdlines)
57
+ Autoproj.message " installing/updating Python dependencies:" \
58
+ " #{pips.sort.join(', ')}"
48
59
 
49
60
  cmdlines.each do |c|
50
- Autobuild::Subprocess.run 'autoproj', 'osdeps', *c,
51
- env: ws.env.resolved_env
61
+ Autobuild::Subprocess.run "autoproj", "osdeps", *c,
62
+ env: ws.env.resolved_env
52
63
  end
53
64
 
54
65
  pips.each do |p|
@@ -56,8 +67,8 @@ module Autoproj
56
67
  end
57
68
  end
58
69
  end
59
-
60
- def pips_interaction(pips, cmdlines)
70
+
71
+ def pips_interaction(cmdlines)
61
72
  if OSPackageInstaller.force_osdeps
62
73
  return true
63
74
  elsif enabled?
@@ -69,24 +80,23 @@ module Autoproj
69
80
  # We're not supposed to install rubygem packages but silent is not
70
81
  # set, so display information about them anyway
71
82
  puts <<-EOMSG
72
- #{Autoproj.color("The build process and/or the packages require some Python packages to be installed", :bold)}
73
- #{Autoproj.color("and you required autoproj to not do it itself", :bold)}
83
+ #{Autoproj.color('The build process and/or the packages require some Python packages to be installed', :bold)}
84
+ #{Autoproj.color('and you required autoproj to not do it itself', :bold)}
74
85
  The following command line can be used to install them manually
75
-
76
- #{cmdlines.map { |c| c.join(" ") }.join("\n ")}
77
-
86
+ #{' '}
87
+ #{cmdlines.map { |c| c.join(' ') }.join("\n ")}
88
+ #{' '}
78
89
  Autoproj expects these Python packages to be installed in #{pip_home} This can
79
90
  be overridden by setting the AUTOPROJ_PYTHONUSERBASE environment variable manually
80
91
 
81
92
  EOMSG
82
- print " #{Autoproj.color("Press ENTER to continue ", :bold)}"
93
+ print " #{Autoproj.color('Press ENTER to continue ', :bold)}"
83
94
 
84
- STDOUT.flush
85
- STDIN.readline
95
+ $stdout.flush
96
+ $stdin.readline
86
97
  puts
87
98
  false
88
99
  end
89
100
  end
90
101
  end
91
102
  end
92
-
@@ -1,14 +1,13 @@
1
1
  module Autoproj
2
2
  module PackageManagers
3
- # Package manager interface for systems that use pkg (i.e. FreeBSD) as
3
+ # Package manager interface for systems that use pkg (i.e. FreeBSD) as
4
4
  # their package manager
5
5
  class PkgManager < ShellScriptManager
6
6
  def initialize(ws)
7
7
  super(ws, true,
8
- %w{pkg install -y},
9
- %w{pkg install -y})
8
+ %w[pkg install -y],
9
+ %w[pkg install -y])
10
10
  end
11
11
  end
12
12
  end
13
13
  end
14
-
@@ -5,10 +5,9 @@ module Autoproj
5
5
  class PortManager < ShellScriptManager
6
6
  def initialize(ws)
7
7
  super(ws, true,
8
- %w{port install},
9
- %w{port install})
8
+ %w[port install],
9
+ %w[port install])
10
10
  end
11
11
  end
12
12
  end
13
13
  end
14
-