autobuild 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a60642848d28e7f8df4bbc60cd96fdcc5d170778
4
- data.tar.gz: 983a96918df8249f3917b8ca773a6d31f598bdc3
3
+ metadata.gz: cc3844e5cb144f3b3e1fda8a22ac5b6531c12439
4
+ data.tar.gz: ddbecdd7203bd378c2c4504d1598e8da3be460aa
5
5
  SHA512:
6
- metadata.gz: a7e29d504f3b6cb4389ebf1319dcfae314039ebb3f9424a33feeefc3df5f5324f094db3f5fc1a7e2e2ad5bfdfc27f321fc4c45755087fb1e8a0285119533eea1
7
- data.tar.gz: 66acd15c957082f400fbfe9ca95860e4874cf116ab83a692271a217918cb67e72c2322586d0630b5d3d82a9ec47aaa209970ac16536402bde13f1038962f17a0
6
+ metadata.gz: aa366e2f4f0b29e6c9f2752528fb44445cb419cc7b1e0fd697f7b4a1cf66d174d86f11e5eabc5872ba90e8f27ec0cdbcc68a1a097096fa5d3d3fc59fdf8558e3
7
+ data.tar.gz: 72ec8e6137f757cd13af392076b7e6b3b04af67963628e4d8a4de823fe1b631363d3b45f03dc22a69b1432a6dd198a4e51144105231b3924153928ea453b7262
@@ -61,6 +61,6 @@ module Autobuild
61
61
  require 'autobuild/packages/pkgconfig'
62
62
  require 'autobuild/packages/dummy'
63
63
  require 'autobuild/packages/ruby'
64
+ require 'autobuild/packages/python'
64
65
 
65
66
  require 'autobuild/rake_task_extension'
66
-
@@ -12,7 +12,7 @@ module Autobuild
12
12
  # source files have been updated. The #buildstamp stampfile represents when
13
13
  # the last build has been done. The build must be done in the #builddir directory.
14
14
  # * +install+ is ran after +build+.
15
- #
15
+ #
16
16
  class Configurable < Package
17
17
  # Set of regexp matching paths that should not be considered as source
18
18
  # files
@@ -51,7 +51,7 @@ def builddir=(new)
51
51
  end
52
52
  end
53
53
  @builddir = 'build'
54
-
54
+
55
55
  def builddir=(new)
56
56
  raise ConfigException.new(self), "builddir must be non-empty" if new.empty?
57
57
  @builddir = new
@@ -122,7 +122,7 @@ def configure
122
122
  end
123
123
  FileUtils.mkdir_p builddir if !File.directory?(builddir)
124
124
 
125
- yield
125
+ yield if block_given?
126
126
 
127
127
  Autobuild.touch_stamp(configurestamp)
128
128
  end
@@ -0,0 +1,93 @@
1
+ require 'autobuild/configurable'
2
+ require 'open3'
3
+
4
+ # Main Autobuild module
5
+ module Autobuild
6
+ def self.python(opts, &proc)
7
+ Python.new(opts, &proc)
8
+ end
9
+
10
+ # Handler class to build python-based packages
11
+ class Python < Configurable
12
+ attr_accessor :buildflags
13
+ attr_accessor :installflags
14
+
15
+ def configurestamp
16
+ "#{builddir}/configure-autobuild-stamp"
17
+ end
18
+
19
+ def initialize(options)
20
+ @buildflags = []
21
+ @installflags = []
22
+ super
23
+ end
24
+
25
+ def prepare
26
+ super
27
+ @install_mode = File.file?(File.join(srcdir, 'setup.py'))
28
+ end
29
+
30
+ def prepare_for_forced_build
31
+ super
32
+ FileUtils.rm_f configurestamp
33
+ @forced = true
34
+ end
35
+
36
+ def generate_build_command
37
+ command = ['python', 'setup.py', 'build']
38
+ command << "--build-base=#{builddir}"
39
+ command += buildflags.flatten
40
+ command
41
+ end
42
+
43
+ def generate_install_command
44
+ command = generate_build_command
45
+ command << 'install'
46
+ command << "--prefix=#{prefix}"
47
+ command += installflags.flatten
48
+ command
49
+ end
50
+
51
+ def python_path
52
+ begin
53
+ _, output, _, ret = Open3.popen3({ 'PYTHONUSERBASE' => prefix },
54
+ 'python -m site --user-site')
55
+ rescue Exception => e
56
+ raise "Unable to set PYTHONPATH: #{e.message}"
57
+ end
58
+
59
+ return output.read.chomp if ret.value.success?
60
+ raise 'Unable to set PYTHONPATH: user site directory disabled?'
61
+ end
62
+
63
+ # Do the build in builddir
64
+ def build
65
+ return unless @install_mode
66
+ command = generate_build_command
67
+ command << '--force' if @forced
68
+ progress_start 'building %s [progress not available]',
69
+ done_message: 'built %s' do
70
+ run 'build', *command, working_directory: srcdir
71
+ end
72
+ Autobuild.touch_stamp(buildstamp)
73
+ end
74
+
75
+ # Install the result in prefix
76
+ def install
77
+ return unless @install_mode
78
+ command = generate_install_command
79
+ command << '--force' if @forced
80
+ progress_start 'installing %s',
81
+ done_message: 'installed %s' do
82
+ run 'install', *command, working_directory: srcdir
83
+ end
84
+ super
85
+ end
86
+
87
+ def update_environment
88
+ super
89
+ path = @install_mode ? python_path : srcdir
90
+ env_add_path 'PYTHONPATH', path
91
+ end
92
+ end
93
+ end
@@ -52,15 +52,10 @@ def self.display_message(*args)
52
52
  return
53
53
  end
54
54
 
55
- size =
56
- if @last_progress_msg then @last_progress_msg.size
57
- else 0
58
- end
59
-
60
55
  if !silent?
61
- io.puts "\r#{msg}#{" " * [size - msg.size, 0].max}"
56
+ io.puts "#{clear_line}#{msg}"
62
57
  if @last_progress_msg
63
- print "#{@last_progress_msg}"
58
+ io.print @last_progress_msg
64
59
  end
65
60
  end
66
61
  end
@@ -86,6 +81,10 @@ def self.has_progress_for?(key)
86
81
  progress_messages.any? { |msg_key, _| msg_key == key }
87
82
  end
88
83
 
84
+ def self.clear_line
85
+ "\e[2K\e[1G"
86
+ end
87
+
89
88
  def self.progress_start(key, *args)
90
89
  if args.last.kind_of?(Hash)
91
90
  options = Kernel.validate_options args.pop, :done_message => nil
@@ -226,24 +225,17 @@ def self.format_progress_message(messages)
226
225
 
227
226
  def self.display_progress
228
227
  msg = format_progress_message(progress_messages.map(&:last))
229
- last_msg_length =
230
- if @last_progress_msg then @last_progress_msg.length
231
- else 0
232
- end
233
228
 
234
229
  if msg.empty?
235
- blank = " " * last_msg_length
236
230
  @last_progress_msg = nil
237
231
  else
238
232
  msg = " #{msg}"
239
- blank = " " * [last_msg_length - msg.length, 0].max
240
233
  @last_progress_msg = msg
241
234
  end
242
235
 
243
236
  if !silent?
244
237
  if Autobuild.progress_display_enabled?
245
- print "\r#{msg}#{blank}"
246
- print "\r#{msg}"
238
+ print "#{clear_line}#{msg}"
247
239
  elsif @last_progress_msg
248
240
  puts msg
249
241
  end
@@ -1,3 +1,3 @@
1
1
  module Autobuild
2
- VERSION = "1.13.0" unless defined? Autobuild::VERSION
2
+ VERSION = "1.14.0" unless defined? Autobuild::VERSION
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-13 00:00:00.000000000 Z
11
+ date: 2018-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -196,6 +196,7 @@ files:
196
196
  - lib/autobuild/packages/import.rb
197
197
  - lib/autobuild/packages/orogen.rb
198
198
  - lib/autobuild/packages/pkgconfig.rb
199
+ - lib/autobuild/packages/python.rb
199
200
  - lib/autobuild/packages/ruby.rb
200
201
  - lib/autobuild/parallel.rb
201
202
  - lib/autobuild/pkgconfig.rb