autoproj 1.9.4 → 1.9.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -133,7 +133,7 @@ OSDEPS_DEFAULTS
133
133
  EODEFS
134
134
 
135
135
  Autoproj::OSDependencies.define_osdeps_mode_option
136
- osdeps_mode = Autoproj::OSDependencies.osdeps_mode
136
+ osdeps_mode = Autoproj::OSDependencies.osdeps_mode.join(",")
137
137
  ENV['AUTOPROJ_OSDEPS_MODE'] = osdeps_mode
138
138
 
139
139
  # First thing we do is install a proper ruby environment. We make sure that we
@@ -123,42 +123,22 @@ module Autoproj
123
123
  @randomize_layout = Autoproj.user_config('randomize_layout')
124
124
  end
125
125
 
126
- # If we are under rubygems, check that the GEM_HOME is right ...
127
- if $LOADED_FEATURES.any? { |l| l =~ /rubygems/ }
128
- if ENV['GEM_HOME'] != Autoproj.gem_home
129
- raise ConfigError.new, "RubyGems is already loaded with a different GEM_HOME, make sure you are loading the right #{ENV_FILENAME} script !"
130
- end
126
+ # Make sure that the currently loaded env.sh is actually us
127
+ if ENV['AUTOPROJ_CURRENT_ROOT'] && (ENV['AUTOPROJ_CURRENT_ROOT'] != Autoproj.root_dir)
128
+ raise ConfigError.new, "the current environment is for #{ENV['AUTOPROJ_ROOT_DIR']}, but you are in #{Autoproj.root_dir}, make sure you are loading the right #{ENV_FILENAME} script !"
131
129
  end
132
130
 
133
- # Set up some important autobuild parameters
134
- Autoproj.env_inherit 'PATH', 'PKG_CONFIG_PATH', 'RUBYLIB', 'LD_LIBRARY_PATH', 'GEM_PATH', 'CMAKE_PREFIX_PATH', 'PYTHONPATH'
135
- Autoproj.env_set 'GEM_HOME', Autoproj.gem_home
136
- Autoproj.env_add 'GEM_PATH', Autoproj.gem_home
137
- Autoproj.env_add 'PATH', File.join(Autoproj.gem_home, 'bin')
138
- Autoproj.env_set 'RUBYOPT', "-rubygems"
131
+ Autoproj.manifest = Manifest.new
132
+ Autoproj.prepare_environment
139
133
  Autobuild.prefix = Autoproj.build_dir
140
134
  Autobuild.srcdir = Autoproj.root_dir
141
135
  Autobuild.logdir = File.join(Autobuild.prefix, 'log')
142
136
 
143
- Autoproj.manifest = Manifest.new
144
-
145
137
  local_source = LocalPackageSet.new(Autoproj.manifest)
138
+ load_autoprojrc
146
139
 
147
- home_dir =
148
- if Dir.respond_to?(:home) # 1.9 specific
149
- Dir.home
150
- else ENV['HOME']
151
- end
152
- # Load the user-wide autoproj RC file
153
- if home_dir
154
- Autoproj.load_if_present(local_source, home_dir, ".autoprojrc")
155
- end
156
-
157
- if Autoproj.has_config_key?('reused_autoproj_installations')
158
- reused = Autoproj.user_config('reused_autoproj_installations')
159
- reused.each do |path|
160
- Autoproj.manifest.reuse(path)
161
- end
140
+ Autoproj.manifest.each_reused_autoproj_installation do |p|
141
+ Autoproj.manifest.reuse(path)
162
142
  end
163
143
 
164
144
  # We load the local init.rb first so that the manifest loading
@@ -208,6 +188,26 @@ module Autoproj
208
188
  end
209
189
  end
210
190
 
191
+ def self.load_autoprojrc
192
+ home_dir =
193
+ if Dir.respond_to?(:home) # 1.9 specific
194
+ Dir.home
195
+ else ENV['HOME']
196
+ end
197
+
198
+ # Load the user-wide autoproj RC file
199
+ if home_dir
200
+ rcfile = File.join(home_dir, '.autoprojrc')
201
+ if File.file?(rcfile)
202
+ begin
203
+ Kernel.load rcfile
204
+ rescue Interrupt
205
+ raise
206
+ end
207
+ end
208
+ end
209
+ end
210
+
211
211
  def self.update_myself
212
212
  return if !Autoproj::CmdLine.update_os_dependencies?
213
213
 
@@ -712,7 +712,7 @@ module Autoproj
712
712
  # Run a filter now, to have errors as early as possible
713
713
  selection.filter_excluded_and_ignored_packages(Autoproj.manifest)
714
714
  # Delete this package from the current_packages set
715
- true
715
+ next
716
716
  end
717
717
 
718
718
  Autoproj.each_post_import_block(pkg) do |block|
@@ -1554,34 +1554,18 @@ where 'mode' is one of:
1554
1554
  Autoproj.root_dir = Dir.pwd
1555
1555
  Autobuild.logdir = File.join(Autoproj.prefix, 'log')
1556
1556
 
1557
- # Check if GEM_HOME is set. If it is the case, assume that we are
1558
- # bootstrapping from another autoproj directory. We start by
1559
- # forcefully installing autoproj/autobuild so that the installation
1560
- # is self-contained.
1561
- #
1562
- # We don't use Autoproj.gem_home there as we might not be in an
1563
- # autoproj directory at all
1564
- gem_home = ENV['AUTOPROJ_GEM_HOME'] || File.join(Dir.pwd, ".gems")
1565
- if ENV['GEM_HOME'] && Autoproj.in_autoproj_installation?(ENV['GEM_HOME']) && ENV['GEM_HOME'] != gem_home
1566
- Autoproj::OSDependencies.define_osdeps_mode_option
1567
- osdeps = Autoproj::OSDependencies.load_default
1568
- if osdeps_forced_mode
1569
- osdeps.osdeps_mode = osdeps_forced_mode
1570
- end
1571
- osdeps.osdeps_mode
1572
-
1573
- Autoproj.message "autoproj: bootstrapping using another installation's autoproj gem"
1574
- ENV['GEM_HOME'] = gem_home
1575
- ENV.delete('GEM_PATH')
1576
- Autoproj.message "installing autoproj in #{ENV['GEM_HOME']} and restarting"
1577
- osdeps.install ['autoproj']
1578
- Autoproj.message "restarting bootstrapping from #{Dir.pwd}"
1557
+ Autoproj.manifest = Manifest.new
1558
+ load_autoprojrc
1559
+ Autoproj.prepare_environment
1579
1560
 
1580
- require 'rbconfig'
1581
- ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
1582
- ENV['AUTOPROJ_OSDEPS_MODE'] = osdeps.osdeps_mode
1583
- exec ruby, $0, 'bootstrap', *ARGV
1561
+ Autoproj::OSDependencies.define_osdeps_mode_option
1562
+ osdeps = Autoproj::OSDependencies.load_default
1563
+ if osdeps_forced_mode
1564
+ osdeps.osdeps_mode = osdeps_forced_mode
1584
1565
  end
1566
+ osdeps.osdeps_mode
1567
+
1568
+ osdeps.install ['autoproj']
1585
1569
 
1586
1570
  reuse = []
1587
1571
  parser = lambda do |opt|
@@ -1605,12 +1589,6 @@ where 'mode' is one of:
1605
1589
 
1606
1590
  handle_ruby_version
1607
1591
 
1608
- Autobuild.env_set 'RUBYOPT', '-rubygems'
1609
- Autobuild.env_set 'GEM_HOME', Autoproj.gem_home
1610
- Autobuild.env_add_path 'PATH', File.join(Autoproj.gem_home, 'bin')
1611
- Autobuild.env_inherit 'PATH'
1612
- Autobuild.env_add_path 'GEM_PATH', Autoproj.gem_home
1613
- Autobuild.env_inherit 'GEM_PATH'
1614
1592
  Autoproj.export_env_sh
1615
1593
 
1616
1594
  if args.size == 1 # the user asks us to download a manifest
@@ -1888,8 +1866,8 @@ where 'mode' is one of:
1888
1866
  def self.initialize_root_directory
1889
1867
  Autoproj.root_dir
1890
1868
  rescue Autoproj::UserError => error
1891
- if ENV['GEM_HOME']
1892
- Dir.chdir(File.join(ENV['GEM_HOME'], '..'))
1869
+ if ENV['AUTOPROJ_CURRENT_ROOT']
1870
+ Dir.chdir(ENV['AUTOPROJ_CURRENT_ROOT'])
1893
1871
  begin Autoproj.root_dir
1894
1872
  rescue Autoproj::UserError
1895
1873
  raise error
@@ -132,5 +132,8 @@ cvs:
132
132
  fedora: cvs
133
133
  darwin: cvs
134
134
 
135
+ pip:
136
+ debian,ubuntu: python-pip
137
+
135
138
  # vim: expandtab
136
139
 
@@ -1080,7 +1080,7 @@ module Autoproj
1080
1080
 
1081
1081
  def initialize
1082
1082
  @file = nil
1083
- @data = nil
1083
+ @data = Hash.new
1084
1084
  @packages = Hash.new
1085
1085
  @package_manifests = Hash.new
1086
1086
  @automatic_exclusions = Hash.new
@@ -2388,6 +2388,12 @@ module Autoproj
2388
2388
  result
2389
2389
  end
2390
2390
 
2391
+ def each_reused_autoproj_installation
2392
+ if Autoproj.has_config_key?('reused_autoproj_installations')
2393
+ Autoproj.user_config('reused_autoproj_installations').each(&proc)
2394
+ end
2395
+ end
2396
+
2391
2397
  def reuse(*dir)
2392
2398
  dir = File.expand_path(File.join(*dir), Autoproj.root_dir)
2393
2399
  if reused_installations.any? { |mnf| mnf.path == dir }
@@ -24,6 +24,13 @@ module Autoproj
24
24
  def name
25
25
  names.first
26
26
  end
27
+
28
+ # Overload to perform initialization of environment variables in
29
+ # order to have a properly functioning package manager
30
+ #
31
+ # This is e.g. needed for python pip or rubygems
32
+ def self.initialize_environment
33
+ end
27
34
  end
28
35
 
29
36
  # Dummy package manager used for unknown OSes. It simply displays a
@@ -314,6 +321,44 @@ fi
314
321
  @with_prerelease = false
315
322
  @with_doc = false
316
323
 
324
+ # Filters all paths that come from other autoproj installations out
325
+ # of GEM_PATH
326
+ def self.initialize_environment
327
+ Autobuild::ORIGINAL_ENV['GEM_PATH'] =
328
+ (ENV['GEM_PATH'] || "").split(":").find_all do |p|
329
+ !Autoproj.in_autoproj_installation?(p)
330
+ end.join(":")
331
+ Autobuild.env_inherit 'GEM_PATH'
332
+ Autobuild.env_init_from_env 'GEM_PATH'
333
+
334
+ orig_gem_path = Autobuild::ORIGINAL_ENV['GEM_PATH'].split(':')
335
+ Gem.default_path.each do |p|
336
+ if !orig_gem_path.include?(p)
337
+ orig_gem_path << ":#{p}"
338
+ end
339
+ end
340
+
341
+ Autoproj.manifest.each_reused_autoproj_installation do |p|
342
+ p_gems = File.join(Autoproj.root_dir, '.gems')
343
+ if File.directory?(p_gems)
344
+ Autobuild.env_add_path 'GEM_PATH', p_gems
345
+ end
346
+ end
347
+ Autobuild.env_add_path 'GEM_PATH', gem_home
348
+ Autobuild.env_set 'GEM_HOME', gem_home
349
+ Autobuild.env_add_path 'PATH', "#{gem_home}/bin"
350
+
351
+ # Now, reset the directories in our own RubyGems instance
352
+ if Gem::Specification.respond_to?(:dirs=)
353
+ Gem::Specification.dirs = ENV['GEM_PATH'].split(':')
354
+ end
355
+ end
356
+
357
+ # Return the directory in which RubyGems package should be installed
358
+ def self.gem_home
359
+ ENV['AUTOPROJ_GEM_HOME'] || File.join(Autoproj.root_dir, ".gems")
360
+ end
361
+
317
362
  def initialize
318
363
  super(['gem'])
319
364
  @installed_gems = Set.new
@@ -477,8 +522,94 @@ fi
477
522
  false
478
523
  end
479
524
  end
525
+
526
+ # Using pip to install python packages
527
+ class PipManager < Manager
528
+
529
+ attr_reader :installed_gems
530
+
531
+ def self.initialize_environment
532
+ Autoproj.env_set 'PYTHONUSERBASE', pip_home
533
+ end
534
+
535
+ # Return the directory where python packages are installed to.
536
+ # The actual path is pip_home/lib/pythonx.y/site-packages.
537
+ def self.pip_home
538
+ ENV['AUTOPROJ_PYTHONUSERBASE'] || File.join(Autoproj.root_dir,".pip")
539
+ end
540
+
541
+
542
+ def initialize
543
+ super(['pip'])
544
+ @installed_pips = Set.new
545
+ end
546
+
547
+ def guess_pip_program
548
+ if Autobuild.programs['pip']
549
+ return Autobuild.programs['pip']
550
+ end
551
+
552
+ Autobuild.programs['pip'] = "pip"
553
+ end
554
+
555
+ def install(pips)
556
+ guess_pip_program
557
+ if pips.is_a?(String)
558
+ pips = [pips]
559
+ end
560
+
561
+ base_cmdline = [Autobuild.tool('pip'), 'install','--user']
562
+
563
+ cmdlines = [base_cmdline + pips]
564
+
565
+ if pips_interaction(pips, cmdlines)
566
+ Autoproj.message " installing/updating Python dependencies: "+
567
+ "#{pips.sort.join(", ")}"
568
+
569
+ cmdlines.each do |c|
570
+ Autobuild::Subprocess.run 'autoproj', 'osdeps', *c
571
+ end
572
+
573
+ pips.each do |p|
574
+ @installed_pips << p
575
+ end
576
+ end
577
+ end
578
+
579
+ def pips_interaction(pips, cmdlines)
580
+ if OSDependencies.force_osdeps
581
+ return true
582
+ elsif enabled?
583
+ return true
584
+ elsif silent?
585
+ return false
586
+ end
587
+
588
+ # We're not supposed to install rubygem packages but silent is not
589
+ # set, so display information about them anyway
590
+ puts <<-EOMSG
591
+ #{Autoproj.color("The build process and/or the packages require some Python packages to be installed", :bold)}
592
+ #{Autoproj.color("and you required autoproj to not do it itself", :bold)}
593
+ The following command line can be used to install them manually
594
+
595
+ #{cmdlines.map { |c| c.join(" ") }.join("\n ")}
596
+
597
+ Autoproj expects these Python packages to be installed in #{Autoproj.pip_home} This can
598
+ be overridden by setting the AUTOPROJ_PYTHONUSERBASE environment variable manually
599
+
600
+ EOMSG
601
+ print " #{Autoproj.color("Press ENTER to continue ", :bold)}"
602
+
603
+ STDOUT.flush
604
+ STDIN.readline
605
+ puts
606
+ false
607
+ end
608
+ end
609
+
480
610
  end
481
611
 
612
+
482
613
  # Manager for packages provided by external package managers
483
614
  class OSDependencies
484
615
  class << self
@@ -560,7 +691,8 @@ fi
560
691
  PackageManagers::EmergeManager,
561
692
  PackageManagers::PacmanManager,
562
693
  PackageManagers::YumManager,
563
- PackageManagers::PortManager]
694
+ PackageManagers::PortManager,
695
+ PackageManagers::PipManager]
564
696
  OS_PACKAGE_HANDLERS = {
565
697
  'debian' => 'apt-dpkg',
566
698
  'gentoo' => 'emerge',
@@ -1181,27 +1313,22 @@ packages)
1181
1313
  This option is meant to allow you to control autoproj's behaviour while handling
1182
1314
  OS dependencies.
1183
1315
 
1184
- * if you say "ruby", the RubyGem packages will be installed.
1316
+ * if you say "gem", the RubyGem packages will be installed.
1185
1317
  * if you say "none", autoproj will not do anything related to the OS
1186
1318
  dependencies.
1187
1319
 
1188
1320
  As any configuration value, the mode can be changed anytime by calling
1189
- an autoproj operation with the --reconfigure option (e.g. autoproj update
1190
- --reconfigure).
1321
+ autoproj reconfigure
1191
1322
 
1192
- Finally, OS dependencies can be installed by calling "autoproj osdeps"
1193
- with the corresponding option (--all, --ruby, --os or --none). Calling
1194
- "autoproj osdeps" without arguments will also give you information as
1195
- to what you should install to compile the software successfully.
1323
+ Finally, the "autoproj osdeps" command will give you the necessary information about the OS packages that you will need to install manually.
1196
1324
 
1197
- So, what do you want ? (ruby or none)
1325
+ So, what do you want ? (either 'all', 'none', or a comma-separated list of 'gem' and 'pip' -- without the quotes)
1198
1326
  EOT
1199
- message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically (ruby, none) ?", long_doc.strip ]
1327
+ message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically ('all', 'none', or a comma-separated list of 'gem' and 'pip' -- without the quotes) ?", long_doc.strip ]
1200
1328
 
1201
1329
  Autoproj.configuration_option 'osdeps_mode', 'string',
1202
1330
  :default => 'ruby',
1203
1331
  :doc => message,
1204
- :possible_values => %w{ruby none},
1205
1332
  :lowercase => true
1206
1333
  end
1207
1334
 
@@ -1219,7 +1346,9 @@ while handling OS dependencies.
1219
1346
 
1220
1347
  * if you say "all", it will install all packages automatically.
1221
1348
  This requires root access thru 'sudo'
1222
- * if you say "ruby", only the Ruby packages will be installed.
1349
+ * if you say "pip", only the Ruby packages will be installed.
1350
+ Installing these packages does not require root access.
1351
+ * if you say "gem", only the Ruby packages will be installed.
1223
1352
  Installing these packages does not require root access.
1224
1353
  * if you say "os", only the OS-provided packages will be installed.
1225
1354
  Installing these packages requires root access.
@@ -1227,20 +1356,17 @@ while handling OS dependencies.
1227
1356
  OS dependencies.
1228
1357
 
1229
1358
  As any configuration value, the mode can be changed anytime by calling
1230
- an autoproj operation with the --reconfigure option (e.g. autoproj update
1231
- --reconfigure).
1359
+ autoproj reconfigure
1232
1360
 
1233
- Finally, OS dependencies can be installed by calling "autoproj osdeps"
1234
- with the corresponding option (--all, --ruby, --os or --none).
1361
+ Finally, the "autoproj osdeps" command
1235
1362
 
1236
- So, what do you want ? (all, ruby, os or none)
1363
+ So, what do you want ? (either 'all', 'none', or a comma-separated list of 'os', 'gem' and 'pip' -- without the quotes)
1237
1364
  EOT
1238
- message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically (all, ruby, os, none) ?", long_doc.strip ]
1365
+ message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically ('all', 'none', or a comma-separated list of 'os', 'gem' and 'pip' -- without the quotes) ?", long_doc.strip ]
1239
1366
 
1240
1367
  Autoproj.configuration_option 'osdeps_mode', 'string',
1241
1368
  :default => 'all',
1242
1369
  :doc => message,
1243
- :possible_values => %w{all ruby os none},
1244
1370
  :lowercase => true
1245
1371
  end
1246
1372
 
@@ -1255,11 +1381,11 @@ So, what do you want ? (all, ruby, os or none)
1255
1381
  def self.osdeps_mode_string_to_value(string)
1256
1382
  string = string.to_s.downcase
1257
1383
  case string
1258
- when 'all' then HANDLE_ALL
1259
- when 'ruby' then HANDLE_RUBY
1260
- when 'os' then HANDLE_OS
1261
- when 'none' then HANDLE_NONE
1262
- else raise ArgumentError, "invalid osdeps mode string '#{string}'"
1384
+ when 'all' then ['os', 'gem', 'pip']
1385
+ when 'ruby' then ['gem']
1386
+ when 'os' then ['os']
1387
+ when 'none' then ['none']
1388
+ else string.split(',')
1263
1389
  end
1264
1390
  end
1265
1391
 
@@ -1328,20 +1454,26 @@ So, what do you want ? (all, ruby, os or none)
1328
1454
  # The set of packages that have already been installed
1329
1455
  attr_reader :installed_packages
1330
1456
 
1331
- def installs_os_packages?
1332
- osdeps_mode == HANDLE_ALL || osdeps_mode == HANDLE_OS
1333
- end
1334
-
1335
- def installs_ruby_packages?
1336
- osdeps_mode == HANDLE_ALL || osdeps_mode == HANDLE_RUBY
1337
- end
1338
-
1339
-
1340
1457
  # Requests the installation of the given set of packages
1341
- def install(packages, package_osdeps = Hash.new)
1342
- os_package_handler.enabled = installs_os_packages?
1458
+ def install(packages, options = Hash.new)
1459
+ options =
1460
+ if Kernel.respond_to?(:validate_options)
1461
+ Kernel.validate_options options, :osdeps_mode => osdeps_mode
1462
+ else options.dup
1463
+ end
1464
+
1465
+ os_package_handler.enabled = false
1466
+ package_handlers.each_value do |handler|
1467
+ handler.enabled = false
1468
+ end
1469
+ osdeps_mode.each do |m|
1470
+ if m == 'os'
1471
+ os_package_handler.enabled = true
1472
+ else
1473
+ package_handlers[m].enabled = true
1474
+ end
1475
+ end
1343
1476
  os_package_handler.silent = self.silent?
1344
- package_handlers['gem'].enabled = installs_ruby_packages?
1345
1477
  package_handlers.each_value do |v|
1346
1478
  v.silent = self.silent?
1347
1479
  end