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.
data/bin/autoproj CHANGED
@@ -85,6 +85,9 @@ EOTEXT
85
85
  if name =~ /^#{Regexp.quote(Autoproj.config_dir + File::SEPARATOR)}/ ||
86
86
  name =~ /^#{Regexp.quote(Autoproj.remotes_dir + File::SEPARATOR)}/
87
87
  needs_update_config = true
88
+ elsif (Autoproj.config_dir + File::SEPARATOR) =~ /^#{Regexp.quote(name)}/
89
+ needs_update_config = true
90
+ false
88
91
  end
89
92
  end
90
93
 
@@ -142,6 +142,13 @@ module Autoproj
142
142
  def name
143
143
  names.first
144
144
  end
145
+
146
+ # Overload to perform initialization of environment variables in
147
+ # order to have a properly functioning package manager
148
+ #
149
+ # This is e.g. needed for python pip or rubygems
150
+ def self.initialize_environment
151
+ end
145
152
  end
146
153
 
147
154
  # Dummy package manager used for unknown OSes. It simply displays a
@@ -432,6 +439,44 @@ fi
432
439
  @with_prerelease = false
433
440
  @with_doc = false
434
441
 
442
+ # Filters all paths that come from other autoproj installations out
443
+ # of GEM_PATH
444
+ def self.initialize_environment
445
+ Autobuild::ORIGINAL_ENV['GEM_PATH'] =
446
+ (ENV['GEM_PATH'] || "").split(":").find_all do |p|
447
+ !Autoproj.in_autoproj_installation?(p)
448
+ end.join(":")
449
+ Autobuild.env_inherit 'GEM_PATH'
450
+ Autobuild.env_init_from_env 'GEM_PATH'
451
+
452
+ orig_gem_path = Autobuild::ORIGINAL_ENV['GEM_PATH'].split(':')
453
+ Gem.default_path.each do |p|
454
+ if !orig_gem_path.include?(p)
455
+ orig_gem_path << ":#{p}"
456
+ end
457
+ end
458
+
459
+ Autoproj.manifest.each_reused_autoproj_installation do |p|
460
+ p_gems = File.join(Autoproj.root_dir, '.gems')
461
+ if File.directory?(p_gems)
462
+ Autobuild.env_add_path 'GEM_PATH', p_gems
463
+ end
464
+ end
465
+ Autobuild.env_add_path 'GEM_PATH', gem_home
466
+ Autobuild.env_set 'GEM_HOME', gem_home
467
+ Autobuild.env_add_path 'PATH', "#{gem_home}/bin"
468
+
469
+ # Now, reset the directories in our own RubyGems instance
470
+ if Gem::Specification.respond_to?(:dirs=)
471
+ Gem::Specification.dirs = ENV['GEM_PATH'].split(':')
472
+ end
473
+ end
474
+
475
+ # Return the directory in which RubyGems package should be installed
476
+ def self.gem_home
477
+ ENV['AUTOPROJ_GEM_HOME'] || File.join(Autoproj.root_dir, ".gems")
478
+ end
479
+
435
480
  def initialize
436
481
  super(['gem'])
437
482
  @installed_gems = Set.new
@@ -595,8 +640,94 @@ fi
595
640
  false
596
641
  end
597
642
  end
643
+
644
+ # Using pip to install python packages
645
+ class PipManager < Manager
646
+
647
+ attr_reader :installed_gems
648
+
649
+ def self.initialize_environment
650
+ Autoproj.env_set 'PYTHONUSERBASE', pip_home
651
+ end
652
+
653
+ # Return the directory where python packages are installed to.
654
+ # The actual path is pip_home/lib/pythonx.y/site-packages.
655
+ def self.pip_home
656
+ ENV['AUTOPROJ_PYTHONUSERBASE'] || File.join(Autoproj.root_dir,".pip")
657
+ end
658
+
659
+
660
+ def initialize
661
+ super(['pip'])
662
+ @installed_pips = Set.new
663
+ end
664
+
665
+ def guess_pip_program
666
+ if Autobuild.programs['pip']
667
+ return Autobuild.programs['pip']
668
+ end
669
+
670
+ Autobuild.programs['pip'] = "pip"
671
+ end
672
+
673
+ def install(pips)
674
+ guess_pip_program
675
+ if pips.is_a?(String)
676
+ pips = [pips]
677
+ end
678
+
679
+ base_cmdline = [Autobuild.tool('pip'), 'install','--user']
680
+
681
+ cmdlines = [base_cmdline + pips]
682
+
683
+ if pips_interaction(pips, cmdlines)
684
+ Autoproj.message " installing/updating Python dependencies: "+
685
+ "#{pips.sort.join(", ")}"
686
+
687
+ cmdlines.each do |c|
688
+ Autobuild::Subprocess.run 'autoproj', 'osdeps', *c
689
+ end
690
+
691
+ pips.each do |p|
692
+ @installed_pips << p
693
+ end
694
+ end
695
+ end
696
+
697
+ def pips_interaction(pips, cmdlines)
698
+ if OSDependencies.force_osdeps
699
+ return true
700
+ elsif enabled?
701
+ return true
702
+ elsif silent?
703
+ return false
704
+ end
705
+
706
+ # We're not supposed to install rubygem packages but silent is not
707
+ # set, so display information about them anyway
708
+ puts <<-EOMSG
709
+ #{Autoproj.color("The build process and/or the packages require some Python packages to be installed", :bold)}
710
+ #{Autoproj.color("and you required autoproj to not do it itself", :bold)}
711
+ The following command line can be used to install them manually
712
+
713
+ #{cmdlines.map { |c| c.join(" ") }.join("\n ")}
714
+
715
+ Autoproj expects these Python packages to be installed in #{Autoproj.pip_home} This can
716
+ be overridden by setting the AUTOPROJ_PYTHONUSERBASE environment variable manually
717
+
718
+ EOMSG
719
+ print " #{Autoproj.color("Press ENTER to continue ", :bold)}"
720
+
721
+ STDOUT.flush
722
+ STDIN.readline
723
+ puts
724
+ false
725
+ end
726
+ end
727
+
598
728
  end
599
729
 
730
+
600
731
  # Manager for packages provided by external package managers
601
732
  class OSDependencies
602
733
  class << self
@@ -678,7 +809,8 @@ fi
678
809
  PackageManagers::EmergeManager,
679
810
  PackageManagers::PacmanManager,
680
811
  PackageManagers::YumManager,
681
- PackageManagers::PortManager]
812
+ PackageManagers::PortManager,
813
+ PackageManagers::PipManager]
682
814
  OS_PACKAGE_HANDLERS = {
683
815
  'debian' => 'apt-dpkg',
684
816
  'gentoo' => 'emerge',
@@ -1299,27 +1431,22 @@ packages)
1299
1431
  This option is meant to allow you to control autoproj's behaviour while handling
1300
1432
  OS dependencies.
1301
1433
 
1302
- * if you say "ruby", the RubyGem packages will be installed.
1434
+ * if you say "gem", the RubyGem packages will be installed.
1303
1435
  * if you say "none", autoproj will not do anything related to the OS
1304
1436
  dependencies.
1305
1437
 
1306
1438
  As any configuration value, the mode can be changed anytime by calling
1307
- an autoproj operation with the --reconfigure option (e.g. autoproj update
1308
- --reconfigure).
1439
+ autoproj reconfigure
1309
1440
 
1310
- Finally, OS dependencies can be installed by calling "autoproj osdeps"
1311
- with the corresponding option (--all, --ruby, --os or --none). Calling
1312
- "autoproj osdeps" without arguments will also give you information as
1313
- to what you should install to compile the software successfully.
1441
+ Finally, the "autoproj osdeps" command will give you the necessary information about the OS packages that you will need to install manually.
1314
1442
 
1315
- So, what do you want ? (ruby or none)
1443
+ So, what do you want ? (either 'all', 'none', or a comma-separated list of 'gem' and 'pip' -- without the quotes)
1316
1444
  EOT
1317
- message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically (ruby, none) ?", long_doc.strip ]
1445
+ 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 ]
1318
1446
 
1319
1447
  Autoproj.configuration_option 'osdeps_mode', 'string',
1320
1448
  :default => 'ruby',
1321
1449
  :doc => message,
1322
- :possible_values => %w{ruby none},
1323
1450
  :lowercase => true
1324
1451
  end
1325
1452
 
@@ -1337,7 +1464,9 @@ while handling OS dependencies.
1337
1464
 
1338
1465
  * if you say "all", it will install all packages automatically.
1339
1466
  This requires root access thru 'sudo'
1340
- * if you say "ruby", only the Ruby packages will be installed.
1467
+ * if you say "pip", only the Ruby packages will be installed.
1468
+ Installing these packages does not require root access.
1469
+ * if you say "gem", only the Ruby packages will be installed.
1341
1470
  Installing these packages does not require root access.
1342
1471
  * if you say "os", only the OS-provided packages will be installed.
1343
1472
  Installing these packages requires root access.
@@ -1345,20 +1474,17 @@ while handling OS dependencies.
1345
1474
  OS dependencies.
1346
1475
 
1347
1476
  As any configuration value, the mode can be changed anytime by calling
1348
- an autoproj operation with the --reconfigure option (e.g. autoproj update
1349
- --reconfigure).
1477
+ autoproj reconfigure
1350
1478
 
1351
- Finally, OS dependencies can be installed by calling "autoproj osdeps"
1352
- with the corresponding option (--all, --ruby, --os or --none).
1479
+ Finally, the "autoproj osdeps" command
1353
1480
 
1354
- So, what do you want ? (all, ruby, os or none)
1481
+ So, what do you want ? (either 'all', 'none', or a comma-separated list of 'os', 'gem' and 'pip' -- without the quotes)
1355
1482
  EOT
1356
- message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically (all, ruby, os, none) ?", long_doc.strip ]
1483
+ 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 ]
1357
1484
 
1358
1485
  Autoproj.configuration_option 'osdeps_mode', 'string',
1359
1486
  :default => 'all',
1360
1487
  :doc => message,
1361
- :possible_values => %w{all ruby os none},
1362
1488
  :lowercase => true
1363
1489
  end
1364
1490
 
@@ -1373,11 +1499,11 @@ So, what do you want ? (all, ruby, os or none)
1373
1499
  def self.osdeps_mode_string_to_value(string)
1374
1500
  string = string.to_s.downcase
1375
1501
  case string
1376
- when 'all' then HANDLE_ALL
1377
- when 'ruby' then HANDLE_RUBY
1378
- when 'os' then HANDLE_OS
1379
- when 'none' then HANDLE_NONE
1380
- else raise ArgumentError, "invalid osdeps mode string '#{string}'"
1502
+ when 'all' then ['os', 'gem', 'pip']
1503
+ when 'ruby' then ['gem']
1504
+ when 'os' then ['os']
1505
+ when 'none' then ['none']
1506
+ else string.split(',')
1381
1507
  end
1382
1508
  end
1383
1509
 
@@ -1446,20 +1572,26 @@ So, what do you want ? (all, ruby, os or none)
1446
1572
  # The set of packages that have already been installed
1447
1573
  attr_reader :installed_packages
1448
1574
 
1449
- def installs_os_packages?
1450
- osdeps_mode == HANDLE_ALL || osdeps_mode == HANDLE_OS
1451
- end
1452
-
1453
- def installs_ruby_packages?
1454
- osdeps_mode == HANDLE_ALL || osdeps_mode == HANDLE_RUBY
1455
- end
1456
-
1457
-
1458
1575
  # Requests the installation of the given set of packages
1459
- def install(packages, package_osdeps = Hash.new)
1460
- os_package_handler.enabled = installs_os_packages?
1576
+ def install(packages, options = Hash.new)
1577
+ options =
1578
+ if Kernel.respond_to?(:validate_options)
1579
+ Kernel.validate_options options, :osdeps_mode => osdeps_mode
1580
+ else options.dup
1581
+ end
1582
+
1583
+ os_package_handler.enabled = false
1584
+ package_handlers.each_value do |handler|
1585
+ handler.enabled = false
1586
+ end
1587
+ osdeps_mode.each do |m|
1588
+ if m == 'os'
1589
+ os_package_handler.enabled = true
1590
+ else
1591
+ package_handlers[m].enabled = true
1592
+ end
1593
+ end
1461
1594
  os_package_handler.silent = self.silent?
1462
- package_handlers['gem'].enabled = installs_ruby_packages?
1463
1595
  package_handlers.each_value do |v|
1464
1596
  v.silent = self.silent?
1465
1597
  end
@@ -1809,10 +1941,6 @@ module Autoproj
1809
1941
  File.join(root_dir, ".remotes")
1810
1942
  end
1811
1943
 
1812
- # Return the directory in which RubyGems package should be installed
1813
- def self.gem_home
1814
- ENV['AUTOPROJ_GEM_HOME'] || File.join(root_dir, ".gems")
1815
- end
1816
1944
 
1817
1945
  def self.env_inherit(*names)
1818
1946
  Autobuild.env_inherit(*names)
@@ -1828,15 +1956,30 @@ module Autoproj
1828
1956
  File.join(result, name)
1829
1957
  end
1830
1958
 
1959
+ # @deprecated use isolate_environment instead
1960
+ def self.set_initial_env
1961
+ isolate_environment
1962
+ end
1963
+
1831
1964
  # Initializes the environment variables to a "sane default"
1832
1965
  #
1833
1966
  # Use this in autoproj/init.rb to make sure that the environment will not
1834
1967
  # get polluted during the build.
1835
- def self.set_initial_env
1968
+ def self.isolate_environment
1836
1969
  Autobuild.env_inherit = false
1837
- Autoproj.env_set 'RUBYOPT', "-rubygems"
1838
- Autobuild.env_push_path 'GEM_PATH', Autoproj.gem_home
1839
- Autobuild.env_push_path 'PATH', "#{Autoproj.gem_home}/bin", "/usr/local/bin", "/usr/bin", "/bin"
1970
+ Autobuild.env_push_path 'PATH', "/usr/local/bin", "/usr/bin", "/bin"
1971
+ end
1972
+
1973
+ def self.prepare_environment
1974
+ # Set up some important autobuild parameters
1975
+ env_inherit 'PATH', 'PKG_CONFIG_PATH', 'RUBYLIB', \
1976
+ 'LD_LIBRARY_PATH', 'CMAKE_PREFIX_PATH', 'PYTHONPATH'
1977
+
1978
+ env_set 'AUTOPROJ_CURRENT_ROOT', Autoproj.root_dir
1979
+ env_set 'RUBYOPT', "-rubygems"
1980
+ Autoproj::OSDependencies::PACKAGE_HANDLERS.each do |pkg_mng|
1981
+ pkg_mng.initialize_environment
1982
+ end
1840
1983
  end
1841
1984
 
1842
1985
  class << self
@@ -1847,10 +1990,8 @@ module Autoproj
1847
1990
 
1848
1991
  # Create the env.sh script in +subdir+. In general, +subdir+ should be nil.
1849
1992
  def self.export_env_sh(subdir = nil)
1850
- # Make sure that we have the environment of all selected packages
1851
- if Autoproj.manifest # we don't have a manifest if we are bootstrapping
1852
- Autoproj::CmdLine.update_environment
1853
- end
1993
+ # Make sure that we have as much environment as possible
1994
+ Autoproj::CmdLine.update_environment
1854
1995
 
1855
1996
  filename = if subdir
1856
1997
  File.join(Autoproj.root_dir, subdir, ENV_FILENAME)
@@ -1873,10 +2014,13 @@ module Autoproj
1873
2014
  end
1874
2015
 
1875
2016
  File.open(filename, "w") do |io|
2017
+ io.write <<-EOF
2018
+ if test -n "$AUTOPROJ_CURRENT_ROOT" && test "$AUTOPROJ_CURRENT_ROOT" != "#{Autoproj.root_dir}"; then
2019
+ echo "the env.sh from $AUTOPROJ_CURRENT_ROOT is already loaded. Start a new shell before sourcing this one"
2020
+ return
2021
+ fi
2022
+ EOF
1876
2023
  Autobuild.export_env_sh(io)
1877
- if Autobuild.environment.has_key?('GEM_PATH')
1878
- io.puts "export GEM_PATH=$GEM_PATH:#{Gem.default_path.join(":")}"
1879
- end
1880
2024
  end
1881
2025
  end
1882
2026
 
@@ -1935,130 +2079,132 @@ module Autoproj
1935
2079
  end
1936
2080
 
1937
2081
  DEFS = <<EODEFS
1938
- ---
1939
- none: ignore
1940
- ruby18:
1941
- debian,ubuntu:
1942
- - ruby1.8-dev
1943
- - ruby1.8
1944
- - rubygems1.8
1945
- - ri1.8
1946
- - libopenssl-ruby1.8
2082
+ ---
2083
+ ruby20: ignore
2084
+ pip:
2085
+ debian,ubuntu: python-pip
2086
+ lsb_release:
2087
+ gentoo: sys-apps/lsb-release
2088
+ darwin: ignore
2089
+ fedora: redhat-lsb
2090
+ debian,ubuntu: lsb-release
2091
+ arch: ignore
2092
+ svn:
2093
+ gentoo: dev-util/subversion
2094
+ darwin: subversion
2095
+ fedora: subversion
2096
+ debian,ubuntu: subversion
2097
+ arch: subversion
2098
+ autoproj: gem
2099
+ build-essential:
2100
+ gentoo: ignore
2101
+ darwin: ignore
2102
+ fedora: ignore
2103
+ debian,ubuntu: build-essential
2104
+ arch: ignore
2105
+ cmake:
2106
+ gentoo: dev-util/cmake
2107
+ darwin: cmake
2108
+ fedora: cmake
2109
+ debian,ubuntu: cmake
2110
+ arch: cmake
2111
+ ruby19:
2112
+ gentoo:
2113
+ - dev-lang/ruby:1.9
1947
2114
  - rake
1948
- gentoo:
1949
- - dev-lang/ruby:1.8
2115
+ darwin:
2116
+ - ruby19
1950
2117
  - rake
1951
- fedora:
1952
- '15,16':
2118
+ default: nonexistent
2119
+ fedora:
2120
+ "17":
1953
2121
  - ruby
1954
2122
  - rubygems
1955
- darwin:
1956
- - ruby
1957
- - rb-rake
1958
- default: nonexistent
1959
- ruby19:
1960
- debian:
2123
+ ubuntu:
1961
2124
  - ruby1.9.1
1962
2125
  - ruby1.9.1-dev
1963
2126
  - rubygems1.9.1
2127
+ - ri1.9.1
2128
+ - libopenssl-ruby1.9.1
1964
2129
  - rake
1965
- - rubygems-integration
1966
- ubuntu:
2130
+ debian:
1967
2131
  - ruby1.9.1
1968
2132
  - ruby1.9.1-dev
1969
2133
  - rubygems1.9.1
1970
- - ri1.9.1
1971
- - libopenssl-ruby1.9.1
1972
- - rake
1973
- gentoo:
1974
- - dev-lang/ruby:1.9
1975
2134
  - rake
1976
- arch:
2135
+ - rubygems-integration
2136
+ arch:
1977
2137
  - ruby
1978
2138
  - rake
1979
- fedora:
1980
- '17':
2139
+ ruby18:
2140
+ gentoo:
2141
+ - dev-lang/ruby:1.8
2142
+ - rake
2143
+ darwin:
2144
+ - ruby
2145
+ - rb-rake
2146
+ default: nonexistent
2147
+ fedora:
2148
+ "15,16":
1981
2149
  - ruby
1982
2150
  - rubygems
1983
- darwin:
1984
- - ruby19
2151
+ debian,ubuntu:
2152
+ - ruby1.8-dev
2153
+ - ruby1.8
2154
+ - rubygems1.8
2155
+ - ri1.8
2156
+ - libopenssl-ruby1.8
1985
2157
  - rake
1986
- default: nonexistent
1987
- ruby20: ignore
1988
- build-essential:
1989
- debian,ubuntu: build-essential
1990
- gentoo: ignore
1991
- arch: ignore
1992
- fedora: ignore
1993
- darwin: ignore
1994
2158
  autobuild: gem
1995
- autoproj: gem
1996
- git:
1997
- debian:
1998
- lenny: git
1999
- default: git-core
2000
- ubuntu: git-core
2001
- gentoo: dev-vcs/git
2002
- arch: git
2003
- fedora: git
2004
- darwin: git-core
2005
- svn:
2006
- debian,ubuntu: subversion
2007
- gentoo: dev-util/subversion
2008
- arch: subversion
2009
- fedora: subversion
2010
- darwin: subversion
2011
- cmake:
2012
- debian,ubuntu: cmake
2013
- gentoo: dev-util/cmake
2014
- arch: cmake
2015
- fedora: cmake
2016
- darwin: cmake
2017
- autotools:
2018
- debian,ubuntu:
2019
- - automake1.9
2020
- - autoconf
2021
- gentoo:
2022
- - sys-devel/automake:1.9
2023
- - sys-devel/autoconf
2024
- arch: automake autoconf
2025
- fedora:
2026
- - automake
2027
- - autoconf
2028
- darwin:
2029
- - automake
2030
- - autoconf
2031
- lsb_release:
2032
- debian,ubuntu: lsb-release
2033
- gentoo: sys-apps/lsb-release
2034
- arch: ignore
2035
- fedora: redhat-lsb
2036
- darwin: ignore
2037
- archive:
2038
- debian,ubuntu:
2039
- - tar
2040
- - unzip
2041
- gentoo:
2159
+ cvs:
2160
+ darwin: cvs
2161
+ fedora: cvs
2162
+ debian,ubuntu: cvs
2163
+ archive:
2164
+ gentoo:
2042
2165
  - app-arch/tar
2043
2166
  - app-arch/unzip
2044
- arch:
2167
+ darwin:
2168
+ - gnutar
2169
+ - unzip
2170
+ fedora:
2045
2171
  - tar
2046
2172
  - unzip
2047
- fedora:
2173
+ debian,ubuntu:
2048
2174
  - tar
2049
2175
  - unzip
2050
- darwin:
2051
- - gnutar
2176
+ arch:
2177
+ - tar
2052
2178
  - unzip
2053
- cvs:
2054
- debian,ubuntu: cvs
2055
- fedora: cvs
2056
- darwin: cvs
2179
+ none: ignore
2180
+ autotools:
2181
+ gentoo:
2182
+ - sys-devel/automake:1.9
2183
+ - sys-devel/autoconf
2184
+ darwin:
2185
+ - automake
2186
+ - autoconf
2187
+ fedora:
2188
+ - automake
2189
+ - autoconf
2190
+ debian,ubuntu:
2191
+ - automake1.9
2192
+ - autoconf
2193
+ arch: automake autoconf
2194
+ git:
2195
+ gentoo: dev-vcs/git
2196
+ darwin: git-core
2197
+ fedora: git
2198
+ ubuntu: git-core
2199
+ debian:
2200
+ lenny: git
2201
+ default: git-core
2202
+ arch: git
2057
2203
 
2058
2204
  EODEFS
2059
2205
 
2060
2206
  Autoproj::OSDependencies.define_osdeps_mode_option
2061
- osdeps_mode = Autoproj::OSDependencies.osdeps_mode
2207
+ osdeps_mode = Autoproj::OSDependencies.osdeps_mode.join(",")
2062
2208
  ENV['AUTOPROJ_OSDEPS_MODE'] = osdeps_mode
2063
2209
 
2064
2210
  # First thing we do is install a proper ruby environment. We make sure that we