autobuild 1.20.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) 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 +14 -7
  5. data/autobuild.gemspec +7 -6
  6. data/bin/autobuild +1 -1
  7. data/lib/autobuild/build_logfile.rb +1 -2
  8. data/lib/autobuild/config.rb +5 -5
  9. data/lib/autobuild/environment.rb +126 -58
  10. data/lib/autobuild/exceptions.rb +13 -6
  11. data/lib/autobuild/import/archive.rb +33 -23
  12. data/lib/autobuild/import/cvs.rb +6 -6
  13. data/lib/autobuild/import/darcs.rb +4 -4
  14. data/lib/autobuild/import/git-lfs.rb +4 -4
  15. data/lib/autobuild/import/git.rb +155 -73
  16. data/lib/autobuild/import/hg.rb +7 -7
  17. data/lib/autobuild/import/svn.rb +17 -10
  18. data/lib/autobuild/importer.rb +37 -39
  19. data/lib/autobuild/mail_reporter.rb +5 -2
  20. data/lib/autobuild/package.rb +28 -15
  21. data/lib/autobuild/packages/autotools.rb +6 -10
  22. data/lib/autobuild/packages/cmake.rb +13 -9
  23. data/lib/autobuild/packages/dummy.rb +0 -4
  24. data/lib/autobuild/packages/gnumake.rb +1 -1
  25. data/lib/autobuild/packages/orogen.rb +11 -4
  26. data/lib/autobuild/packages/pkgconfig.rb +2 -2
  27. data/lib/autobuild/packages/python.rb +19 -8
  28. data/lib/autobuild/packages/ruby.rb +5 -5
  29. data/lib/autobuild/parallel.rb +9 -17
  30. data/lib/autobuild/pkgconfig.rb +1 -0
  31. data/lib/autobuild/progress_display.rb +67 -43
  32. data/lib/autobuild/rake_task_extension.rb +6 -0
  33. data/lib/autobuild/reporting.rb +15 -9
  34. data/lib/autobuild/subcommand.rb +30 -26
  35. data/lib/autobuild/test_utility.rb +6 -3
  36. data/lib/autobuild/timestamps.rb +3 -3
  37. data/lib/autobuild/utility.rb +22 -4
  38. data/lib/autobuild/version.rb +1 -1
  39. data/lib/autobuild.rb +0 -3
  40. metadata +28 -26
  41. data/.travis.yml +0 -19
@@ -203,7 +203,8 @@ module Autobuild
203
203
 
204
204
  patches_fingerprint_string = patches_fingerprint(package)
205
205
  if patches_fingerprint_string
206
- Digest::SHA1.hexdigest(vcs_fingerprint_string + patches_fingerprint_string)
206
+ Digest::SHA1.hexdigest(vcs_fingerprint_string +
207
+ patches_fingerprint_string)
207
208
  elsif patches.empty?
208
209
  vcs_fingerprint_string
209
210
  end
@@ -211,16 +212,19 @@ module Autobuild
211
212
 
212
213
  # basic fingerprint of the package and its dependencies
213
214
  def vcs_fingerprint(package)
214
- #each importer type should implement its own
215
- Autoproj.warn "Fingerprint in #{package.name} has not been implemented for this type of packages, results should be discarded"
216
- return nil
215
+ # each importer type should implement its own
216
+ Autoproj.warn "Fingerprint in #{package.name} has not been implemented "\
217
+ "for this type of packages, results should be discarded"
218
+ nil
217
219
  end
218
220
 
219
221
  # fingerprint for patches associated to this package
220
222
  def patches_fingerprint(package)
221
223
  cur_patches = currently_applied_patches(package)
222
- cur_patches.map(&:shift) #leave only level and source information
223
- Digest::SHA1.hexdigest(cur_patches.sort.flatten.join("")) if !patches.empty? && cur_patches
224
+ cur_patches.map(&:shift) # leave only level and source information
225
+ if !patches.empty? && cur_patches
226
+ Digest::SHA1.hexdigest(cur_patches.sort.flatten.join(""))
227
+ end
224
228
  end
225
229
 
226
230
  # Sets the number of times update / checkout should be retried before giving
@@ -314,12 +318,10 @@ module Autobuild
314
318
  end
315
319
 
316
320
  # Enumerate the post-import hooks for this importer
317
- def each_post_hook(error: false)
321
+ def each_post_hook(error: false, &block)
318
322
  return enum_for(__method__, error: false) unless block_given?
319
323
 
320
- self.class.each_post_hook(error: error) do |callback|
321
- yield(callback)
322
- end
324
+ self.class.each_post_hook(error: error, &block)
323
325
 
324
326
  post_hooks.each do |hook|
325
327
  yield(hook.callback) if hook.always || !error
@@ -355,11 +357,12 @@ module Autobuild
355
357
  message = Autobuild.color('interrupted', :red)
356
358
  if last_error
357
359
  raise last_error
358
- else raise
360
+ else
361
+ raise
359
362
  end
360
- rescue ::Exception => original_error
363
+ rescue ::Exception => e
361
364
  message = Autobuild.color('update failed', :red)
362
- last_error = original_error
365
+ last_error = e
363
366
  # If the package is patched, it might be that the update
364
367
  # failed because we needed to unpatch first. Try it out
365
368
  #
@@ -378,11 +381,11 @@ module Autobuild
378
381
  rescue Interrupt
379
382
  raise
380
383
  rescue ::Exception
381
- raise original_error
384
+ raise e
382
385
  end
383
386
  end
384
387
 
385
- retry_count = update_retry_count(original_error, retry_count)
388
+ retry_count = update_retry_count(e, retry_count)
386
389
  raise unless retry_count
387
390
 
388
391
  package.message "update failed in #{package.importdir}, "\
@@ -399,20 +402,21 @@ module Autobuild
399
402
  fallback(e, package, :import, package)
400
403
  end
401
404
 
402
- def perform_checkout(package, options = Hash.new)
405
+ def perform_checkout(package, **options)
403
406
  last_error = nil
404
407
  package.progress_start "checking out %s", :done_message => 'checked out %s' do
405
408
  retry_count = 0
406
409
  begin
407
- checkout(package, options)
410
+ checkout(package, **options)
408
411
  execute_post_hooks(package)
409
412
  rescue Interrupt
410
413
  if last_error then raise last_error
411
- else raise
414
+ else
415
+ raise
412
416
  end
413
- rescue ::Exception => original_error
414
- last_error = original_error
415
- retry_count = update_retry_count(original_error, retry_count)
417
+ rescue ::Exception => e
418
+ last_error = e
419
+ retry_count = update_retry_count(e, retry_count)
416
420
  raise unless retry_count
417
421
 
418
422
  package.message "checkout of %s failed, "\
@@ -456,31 +460,26 @@ module Autobuild
456
460
  # ID is given will, in this mode, reset the repository to the requested ID
457
461
  # (if that does not involve losing commits). Otherwise, it will only
458
462
  # ensure that the requested commit ID is present in the current HEAD.
459
- def import(package, options = Hash.new)
463
+ def import( # rubocop:disable Metrics/ParameterLists
464
+ package, *old_boolean,
465
+ ignore_errors: false, checkout_only: false, allow_interactive: true, **options
466
+ )
460
467
  # Backward compatibility
461
- unless options.kind_of?(Hash)
462
- options = options
468
+ unless old_boolean.empty?
469
+ old_boolean = old_boolean.first
463
470
  Autoproj.warn "calling #import with a boolean as second argument "\
464
471
  "is deprecated, switch to the named argument interface instead"
465
- Autoproj.warn " e.g. call import(package, only_local: #{options})"
472
+ Autoproj.warn " e.g. call import(package, only_local: #{old_boolean})"
466
473
  Autoproj.warn " #{caller(1..1).first}"
467
- options = Hash[only_local: options]
474
+ options[:only_local] = old_boolean
468
475
  end
469
476
 
470
- options = Kernel.validate_options options,
471
- only_local: false,
472
- reset: false,
473
- checkout_only: false,
474
- ignore_errors: false,
475
- allow_interactive: true
476
- ignore_errors = options.delete(:ignore_errors)
477
-
478
477
  importdir = package.importdir
479
478
  if File.directory?(importdir)
480
479
  package.isolate_errors(mark_as_failed: false,
481
480
  ignore_errors: ignore_errors) do
482
- if !options[:checkout_only] && package.update?
483
- perform_update(package, options)
481
+ if !checkout_only && package.update?
482
+ perform_update(package, checkout_only: false, **options)
484
483
  elsif Autobuild.verbose
485
484
  package.message "%s: not updating"
486
485
  end
@@ -488,12 +487,11 @@ module Autobuild
488
487
 
489
488
  elsif File.exist?(importdir)
490
489
  raise ConfigException.new(package, 'import'),
491
- "#{importdir} exists but is not a directory"
490
+ "#{importdir} exists but is not a directory"
492
491
  else
493
492
  package.isolate_errors(mark_as_failed: true,
494
493
  ignore_errors: ignore_errors) do
495
- perform_checkout(package,
496
- allow_interactive: options[:allow_interactive])
494
+ perform_checkout(package, allow_interactive: allow_interactive)
497
495
  true
498
496
  end
499
497
  end
@@ -22,8 +22,11 @@ if Autobuild::HAS_RMAIL
22
22
  end
23
23
 
24
24
  attr_reader :from_email, :to_email, :smtp_hostname, :smtp_port,
25
- :subject, :only_errors
25
+ :subject, :only_errors
26
+
26
27
  def initialize(config)
28
+ super()
29
+
27
30
  @from_email = (config[:from] || default_mail)
28
31
  @to_email = (config[:to] || default_mail)
29
32
  @subject =
@@ -78,7 +81,7 @@ if Autobuild::HAS_RMAIL
78
81
  to_email.each do |email|
79
82
  mail.header.to = email
80
83
  smtp.send_mail(RMail::Serialize.write('', mail),
81
- from_email, email)
84
+ from_email, email)
82
85
  end
83
86
  end
84
87
 
@@ -64,7 +64,7 @@ module Autobuild
64
64
  # Some statistics about the commands that have been run
65
65
  attr_reader :statistics
66
66
 
67
- EnvOp = Struct.new :type, :name, :values
67
+ EnvOp = Struct.new :type, :name, :values # rubocop:disable Lint/StructNewOverride
68
68
 
69
69
  # List of environment values added by this package with {#env_add},
70
70
  # {#env_add_path} or {#env_set}
@@ -119,7 +119,8 @@ module Autobuild
119
119
  def update?
120
120
  if @update.nil?
121
121
  Autobuild.do_update
122
- else @update
122
+ else
123
+ @update
123
124
  end
124
125
  end
125
126
 
@@ -150,6 +151,7 @@ module Autobuild
150
151
  @imported = false
151
152
  @prepared = false
152
153
  @built = false
154
+ @disabled = nil
153
155
 
154
156
  if Hash === spec
155
157
  name, depends = spec.to_a.first
@@ -286,6 +288,11 @@ module Autobuild
286
288
  add_env_op EnvOp.new(:add_prefix, prefix, [includes])
287
289
  end
288
290
 
291
+ # Add a file to be sourced at the end of the generated env file
292
+ def env_source_after(file, shell: "sh")
293
+ add_env_op EnvOp.new(:source_after, file, shell: shell)
294
+ end
295
+
289
296
  # Hook called by autoproj to set up the default environment for this
290
297
  # package
291
298
  #
@@ -326,7 +333,11 @@ module Autobuild
326
333
  set[env_op.name] = [self, env_op.values]
327
334
  end
328
335
  end
329
- env.send(env_op.type, env_op.name, *env_op.values)
336
+ if env_op.type == :source_after
337
+ env.send(env_op.type, env_op.name, **env_op.values)
338
+ else
339
+ env.send(env_op.type, env_op.name, *env_op.values)
340
+ end
330
341
  ops << env_op
331
342
  end
332
343
  ops
@@ -402,8 +413,8 @@ module Autobuild
402
413
  def isolate_errors(options = Hash.new)
403
414
  options = Hash[mark_as_failed: true] unless options.kind_of?(Hash)
404
415
  options = validate_options options,
405
- mark_as_failed: true,
406
- ignore_errors: Autobuild.ignore_errors
416
+ mark_as_failed: true,
417
+ ignore_errors: Autobuild.ignore_errors
407
418
 
408
419
  # Don't do anything if we already have failed
409
420
  if failed?
@@ -448,12 +459,12 @@ module Autobuild
448
459
  # be done there as well.
449
460
  #
450
461
  # (see Importer#import)
451
- def import(options = Hash.new)
452
- options = Hash[only_local: options] unless options.respond_to?(:to_hash)
462
+ def import(*old_boolean, **options)
463
+ options = { only_local: old_boolean.first } unless old_boolean.empty?
453
464
 
454
465
  @import_invoked = true
455
466
  if @importer
456
- result = @importer.import(self, options)
467
+ result = @importer.import(self, **options)
457
468
  elsif update?
458
469
  message "%s: no importer defined, doing nothing"
459
470
  end
@@ -491,16 +502,17 @@ module Autobuild
491
502
  suffix << token.gsub(/%s/, name)
492
503
  elsif suffix.empty?
493
504
  prefix << token
494
- else suffix << token
505
+ else
506
+ suffix << token
495
507
  end
496
508
  end
497
509
  if suffix.empty?
498
- return msg
510
+ msg
499
511
  elsif prefix_style.empty?
500
- return (prefix + suffix).join(" ")
512
+ (prefix + suffix).join(" ")
501
513
  else
502
514
  colorized_prefix = Autobuild.color(prefix.join(" "), *prefix_style)
503
- return [colorized_prefix, *suffix].join(" ")
515
+ [colorized_prefix, *suffix].join(" ")
504
516
  end
505
517
  end
506
518
 
@@ -527,7 +539,7 @@ module Autobuild
527
539
  args[0] = process_formatting_string(args[0], :bold)
528
540
  done_message = process_formatting_string(done_message) if done_message
529
541
  Autobuild.progress_start(self, *args,
530
- done_message: done_message, **raw_options, &block)
542
+ done_message: done_message, **raw_options, &block)
531
543
  end
532
544
 
533
545
  def progress(*args)
@@ -686,10 +698,11 @@ module Autobuild
686
698
  pkg = Autobuild::Package[pkg_name]
687
699
  unless (fingerprint = memo[pkg.name])
688
700
  fingerprint = pkg.fingerprint(recursive: true, memo: memo)
689
- return unless fingerprint
701
+ break unless fingerprint
690
702
  end
691
703
  fingerprint
692
704
  end
705
+ return unless dependency_fingerprints
693
706
 
694
707
  memo[name] = Digest::SHA1.hexdigest(
695
708
  self_fingerprint + dependency_fingerprints.join(""))
@@ -837,7 +850,7 @@ module Autobuild
837
850
  end
838
851
 
839
852
  # Make sure that this package will be ignored in the build
840
- def disable(phases = Autobuild.all_phases)
853
+ def disable(_phases = Autobuild.all_phases)
841
854
  @disabled = true
842
855
  end
843
856
 
@@ -25,13 +25,8 @@ module Autobuild
25
25
  # To override this default behaviour on a per-package basis, use Autotools#use
26
26
  #
27
27
  class Autotools < Configurable
28
- attr_accessor :using
29
- attr_accessor :configureflags
30
- attr_accessor :aclocal_flags
31
- attr_accessor :autoheader_flags
32
- attr_accessor :autoconf_flags
33
- attr_accessor :automake_flags
34
- attr_accessor :bear_flags
28
+ attr_accessor :using, :configureflags, :aclocal_flags, :autoheader_flags,
29
+ :autoconf_flags, :automake_flags, :bear_flags
35
30
 
36
31
  @builddir = 'build'
37
32
  @@enable_bear_globally = false
@@ -151,7 +146,7 @@ module Autobuild
151
146
  FileUtils.rm_f configurestamp
152
147
  end
153
148
 
154
- def import(options = Hash.new)
149
+ def import(**options)
155
150
  # We force a regen after the first checkout. The issue is that
156
151
  # autotools is less robust than it should, and very often it is
157
152
  # better to generate the build system for the system on which we
@@ -211,7 +206,8 @@ module Autobuild
211
206
  varname, = o.split("=").first
212
207
  if (current_flag = testflags.find { |fl| fl =~ /^#{varname}=/ })
213
208
  current_flag != o
214
- else false
209
+ else
210
+ false
215
211
  end
216
212
  end
217
213
  end
@@ -278,7 +274,7 @@ module Autobuild
278
274
  file conffile => "#{conffile}#{confext}"
279
275
  elsif using[:autoconf]
280
276
  raise PackageException.new(self, 'prepare'),
281
- "neither configure.ac nor configure.in present in #{srcdir}"
277
+ "neither configure.ac nor configure.in present in #{srcdir}"
282
278
  end
283
279
 
284
280
  file conffile do
@@ -25,6 +25,7 @@ module Autobuild
25
25
  end
26
26
 
27
27
  attr_writer :full_reconfigures
28
+
28
29
  def full_reconfigures?
29
30
  @full_reconfigures
30
31
  end
@@ -36,8 +37,7 @@ module Autobuild
36
37
  # It can be overriden on a per-package basis with CMake.generator=
37
38
  attr_accessor :generator
38
39
 
39
- attr_reader :prefix_path
40
- attr_reader :module_path
40
+ attr_reader :prefix_path, :module_path
41
41
 
42
42
  # Whether files that are not within CMake's install manifest but are
43
43
  # present in the prefix should be deleted. Note that the contents of
@@ -63,6 +63,7 @@ module Autobuild
63
63
 
64
64
  # a key => value association of defines for CMake
65
65
  attr_reader :defines
66
+
66
67
  # The list of all -D options that should be passed on to CMake
67
68
  def all_defines
68
69
  additional_defines = Hash[
@@ -81,6 +82,7 @@ module Autobuild
81
82
  # Sets a generator explicitely for this component. See #generator and
82
83
  # CMake.generator
83
84
  attr_writer :generator
85
+
84
86
  # The CMake generator to use. You must choose one that generates
85
87
  # Makefiles. If not set for this package explicitely, it is using the
86
88
  # global value CMake.generator.
@@ -267,7 +269,7 @@ module Autobuild
267
269
  run('doc', Autobuild.tool(:doxygen), doxyfile)
268
270
  end
269
271
 
270
- def common_utility_handling(utility, target, start_msg, done_msg)
272
+ def common_utility_handling(utility, target, *args, start_msg, done_msg)
271
273
  utility.source_ref_dir = builddir
272
274
  utility.task do
273
275
  progress_start start_msg, :done_message => done_msg do
@@ -277,7 +279,7 @@ module Autobuild
277
279
  run(utility.name,
278
280
  Autobuild.tool(:make),
279
281
  "-j#{parallel_build_level}",
280
- target,
282
+ target, *args,
281
283
  working_directory: builddir)
282
284
  end
283
285
  yield if block_given?
@@ -295,7 +297,7 @@ module Autobuild
295
297
 
296
298
  def with_tests(target = 'test', &block)
297
299
  common_utility_handling(
298
- test_utility, target,
300
+ test_utility, target, "ARGS=-V",
299
301
  "running tests for %s",
300
302
  "successfully ran tests for %s", &block)
301
303
  end
@@ -320,7 +322,7 @@ module Autobuild
320
322
  end
321
323
  end
322
324
 
323
- def import(options = Hash.new)
325
+ def import(**options)
324
326
  super
325
327
 
326
328
  Dir.glob(File.join(srcdir, "*.pc.in")) do |file|
@@ -410,7 +412,7 @@ module Autobuild
410
412
  in_dir(builddir) do
411
413
  unless File.file?(File.join(srcdir, 'CMakeLists.txt'))
412
414
  raise ConfigException.new(self, 'configure'),
413
- "#{srcdir} contains no CMakeLists.txt file"
415
+ "#{srcdir} contains no CMakeLists.txt file"
414
416
  end
415
417
 
416
418
  command = ["cmake"]
@@ -438,7 +440,8 @@ module Autobuild
438
440
  def show_make_messages?
439
441
  if !@show_make_messages.nil?
440
442
  @show_make_messages
441
- else CMake.show_make_messages?
443
+ else
444
+ CMake.show_make_messages?
442
445
  end
443
446
  end
444
447
 
@@ -545,7 +548,8 @@ module Autobuild
545
548
 
546
549
  def self_fingerprint
547
550
  return unless (base = super)
548
- all_defines = self.class.defines.merge(self.defines).sort_by(&:first)
551
+
552
+ all_defines = self.class.defines.merge(defines).sort_by(&:first)
549
553
  Digest::SHA1.hexdigest(base + all_defines.join(""))
550
554
  end
551
555
  end
@@ -8,10 +8,6 @@ module Autobuild
8
8
  "#{srcdir}/#{STAMPFILE}"
9
9
  end
10
10
 
11
- def initialize(*args)
12
- super
13
- end
14
-
15
11
  def import(options = Hash.new); end
16
12
 
17
13
  def prepare
@@ -95,7 +95,7 @@ module Autobuild
95
95
  def self.make_subcommand(pkg, phase, *options, &block)
96
96
  invoke_make_parallel(pkg, Autobuild.tool(:make)) do |*make_parallel_options|
97
97
  pkg.run(phase, Autobuild.tool(:make),
98
- *make_parallel_options, *options, &block)
98
+ *make_parallel_options, *options, &block)
99
99
  end
100
100
  end
101
101
  end
@@ -97,19 +97,19 @@ module Autobuild
97
97
  end
98
98
  end
99
99
 
100
- attr_writer :corba
100
+ attr_writer :corba, :orogen_file
101
+
101
102
  def corba
102
103
  @corba || (@corba.nil? && Orogen.corba)
103
104
  end
104
105
 
105
106
  # Overrides the global Orocos.extended_states for this particular package
106
107
  attr_writer :extended_states
108
+
107
109
  def extended_states
108
110
  @extended_states || (@extended_states.nil? && Orogen.extended_states)
109
111
  end
110
112
 
111
- attr_writer :orogen_file
112
-
113
113
  # Path to the orogen file used for this package
114
114
  #
115
115
  # If not set, the class will look for a .orogen file in the package
@@ -128,7 +128,7 @@ module Autobuild
128
128
  return File.basename(path)
129
129
  end
130
130
  raise ArgumentError,
131
- "cannot find an oroGen specification file in #{srcdir}"
131
+ "cannot find an oroGen specification file in #{srcdir}"
132
132
  end
133
133
  end
134
134
 
@@ -235,6 +235,13 @@ module Autobuild
235
235
  cmdline << "--type-export-policy=#{Orogen.default_type_export_policy}"
236
236
  cmdline << "--transports=#{Orogen.transports.sort.uniq.join(',')}"
237
237
  end
238
+ if version >= "1.2"
239
+ cmdline << "--parallel-codegen=#{parallel_build_level}"
240
+ if (job_server = Autobuild.parallel_task_manager&.job_server)
241
+ fds = "#{job_server.rio.fileno},#{job_server.wio.fileno}"
242
+ cmdline << "--jobserver-auth=#{fds}"
243
+ end
244
+ end
238
245
 
239
246
  # Now, add raw options
240
247
  #
@@ -2,8 +2,7 @@ require 'autobuild/pkgconfig'
2
2
 
3
3
  module Autobuild
4
4
  class InstalledPkgConfig < Package
5
- attr_reader :pkgconfig
6
- attr_reader :prefix
5
+ attr_reader :pkgconfig, :prefix
7
6
 
8
7
  def initialize(name)
9
8
  @pkgconfig = PkgConfig.new(name)
@@ -23,6 +22,7 @@ module Autobuild
23
22
  pcfile
24
23
  end
25
24
  end
25
+
26
26
  def self.installed_pkgconfig(name, &block)
27
27
  InstalledPkgConfig.new(name, &block)
28
28
  end
@@ -9,8 +9,7 @@ module Autobuild
9
9
 
10
10
  # Handler class to build python-based packages
11
11
  class Python < Configurable
12
- attr_accessor :buildflags
13
- attr_accessor :installflags
12
+ attr_accessor :buildflags, :installflags
14
13
 
15
14
  def configurestamp
16
15
  "#{builddir}/configure-autobuild-stamp"
@@ -28,12 +27,14 @@ module Autobuild
28
27
 
29
28
  def prepare_for_forced_build
30
29
  super
31
- FileUtils.rm_f configurestamp
32
30
  @forced = true
33
31
  end
34
32
 
35
33
  def generate_build_command
36
- command = ['python', 'setup.py', 'build']
34
+ command = %w[python setup.py]
35
+ command << "egg_info"
36
+ command << "--egg-base=#{builddir}"
37
+ command << "build"
37
38
  command << "--build-base=#{builddir}"
38
39
  command += buildflags.flatten
39
40
  command
@@ -43,25 +44,35 @@ module Autobuild
43
44
  command = generate_build_command
44
45
  command << 'install'
45
46
  command << "--prefix=#{prefix}"
47
+ command << "--record=#{builddir}/install.log"
48
+ command << "--single-version-externally-managed"
46
49
  command += installflags.flatten
47
50
  command
48
51
  end
49
52
 
50
- def python_path
53
+ def self.user_site(prefix)
54
+ return File.join(prefix, @user_site) if @user_site
55
+
51
56
  begin
52
- _, output, _, ret = Open3.popen3({ 'PYTHONUSERBASE' => prefix },
53
- 'python -m site --user-site')
57
+ env = Autobuild.env.resolved_env.merge({ 'PYTHONUSERBASE' => "/" })
58
+ _, output, _, ret = Open3.popen3(env, 'python -m site --user-site')
54
59
  rescue Exception => e
55
60
  raise "Unable to set PYTHONPATH: #{e.message}"
56
61
  end
57
62
 
58
63
  if ret.value.success?
59
- output.read.chomp
64
+ @user_site = Pathname.new(output.read.chomp)
65
+ .relative_path_from(Pathname.new("/"))
66
+ File.join(prefix, @user_site)
60
67
  else
61
68
  raise 'Unable to set PYTHONPATH: user site directory disabled?'
62
69
  end
63
70
  end
64
71
 
72
+ def python_path
73
+ self.class.user_site(prefix)
74
+ end
75
+
65
76
  # Do the build in builddir
66
77
  def build
67
78
  return unless install_mode?
@@ -40,7 +40,7 @@ module Autobuild
40
40
  done_message: 'generated documentation for %s' do
41
41
  run 'doc',
42
42
  Autobuild.tool_in_path('ruby'), '-S',
43
- Autobuild.tool('rake'), rake_doc_task,
43
+ Autobuild.tool('rake'), rake_doc_task,
44
44
  working_directory: srcdir
45
45
  end
46
46
  end
@@ -52,7 +52,7 @@ module Autobuild
52
52
  done_message: 'tests passed for %s' do
53
53
  run 'test',
54
54
  Autobuild.tool_in_path('ruby'), '-S',
55
- Autobuild.tool('rake'), rake_test_task, *rake_test_options,
55
+ Autobuild.tool('rake'), rake_test_task, *rake_test_options,
56
56
  working_directory: srcdir
57
57
  end
58
58
  end
@@ -62,7 +62,7 @@ module Autobuild
62
62
  if setup_task && File.file?(File.join(srcdir, 'Rakefile'))
63
63
  run 'post-install',
64
64
  Autobuild.tool_in_path('ruby'), '-S',
65
- Autobuild.tool('rake'), setup_task,
65
+ Autobuild.tool('rake'), setup_task,
66
66
  working_directory: srcdir
67
67
  end
68
68
  end
@@ -80,7 +80,7 @@ module Autobuild
80
80
  %w[ext tmp].each do |extdir|
81
81
  if File.directory?(extdir)
82
82
  Find.find(extdir) do |file|
83
- next if file !~ /\<Makefile\>|\<CMakeCache.txt\>$/
83
+ next if file !~ /<Makefile>|<CMakeCache.txt>$/
84
84
 
85
85
  FileUtils.rm_rf file
86
86
  end
@@ -94,7 +94,7 @@ module Autobuild
94
94
  begin
95
95
  run 'clean',
96
96
  Autobuild.tool_in_path('ruby'), '-S',
97
- Autobuild.tool('rake'), rake_clean_task,
97
+ Autobuild.tool('rake'), rake_clean_task,
98
98
  working_directory: srcdir
99
99
  rescue Autobuild::SubcommandFailed => e
100
100
  warn "%s: clean failed. If this package does not need a clean target,"