opener-build-tools 1.0.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.
- checksums.yaml +7 -0
- data/README.md +32 -0
- data/lib/opener/build-tools/files.rb +34 -0
- data/lib/opener/build-tools/java.rb +21 -0
- data/lib/opener/build-tools/perl.rb +39 -0
- data/lib/opener/build-tools/python.rb +59 -0
- data/lib/opener/build-tools/requirements.rb +74 -0
- data/lib/opener/build-tools/tasks/clean.rb +17 -0
- data/lib/opener/build-tools/tasks/java.rb +23 -0
- data/lib/opener/build-tools/tasks/python.rb +45 -0
- data/lib/opener/build-tools/version.rb +5 -0
- data/lib/opener/build-tools.rb +8 -0
- data/opener-build-tools.gemspec +20 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f8a5063d6ea876e004378f7547ff3d7f0d71ce4b
|
4
|
+
data.tar.gz: d1e385960745bff993bfb7eb175032cdbb3088e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4cac369bd4b8d7db119756f20dad712f6c1a54bce4bbe4c192dcd01ed0bf20921024e44e9ca17afb07dd0964d51eb37556cd03eb547927689f0db23d2ec28a41
|
7
|
+
data.tar.gz: e96f6091978e2dc2f25fb842d3f0bc9f9eff3ebe0d4183c1b9cc947255ce815938d2686ab53e3351aa76a4c8a573475ab187449e7a46f4a34f28d0f433e742f1
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Build Tools
|
2
|
+
|
3
|
+
The OpeNER build tools is a Gem that contains a collection of helper methods
|
4
|
+
and Rake tasks that ease the process of wrapping and distributing the various
|
5
|
+
OpeNER Gems.
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
* Ruby 1.9.2 or newer
|
10
|
+
* Rake
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Rake tasks can be loaded as any other normal Ruby file:
|
15
|
+
|
16
|
+
require 'opener/build-tools/tasks/python'
|
17
|
+
|
18
|
+
The build tools also come with various helper modules such as
|
19
|
+
`Opener::BuildTools::Python`. The methods in these modules can be accessed
|
20
|
+
either by using the full namespace (e.g.
|
21
|
+
`Opener::BuildTools::Python.python_version`) or by including the modules into a
|
22
|
+
certain scope.
|
23
|
+
|
24
|
+
Using the full namespace:
|
25
|
+
|
26
|
+
Opener::BuildTools::Python.python_version # => "2.7.5"
|
27
|
+
|
28
|
+
Including the module:
|
29
|
+
|
30
|
+
include Opener::BuildTools::Python
|
31
|
+
|
32
|
+
python_version # => "2.7.5"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Opener
|
2
|
+
module BuildTools
|
3
|
+
##
|
4
|
+
# Module that contains various helper methods that makes it easier to work
|
5
|
+
# with collections of files and iterate over them.
|
6
|
+
#
|
7
|
+
module Files
|
8
|
+
module_function
|
9
|
+
|
10
|
+
##
|
11
|
+
# Returns an Array containing the contents of a given directory,
|
12
|
+
# excluding '.' and '..'.
|
13
|
+
#
|
14
|
+
# @param [String] directory
|
15
|
+
#
|
16
|
+
def directory_contents(directory)
|
17
|
+
return Dir.glob(File.join(directory, '*'))
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# Calls the supplied block for each file in the given directory, ignoring
|
22
|
+
# '.' and '..'.
|
23
|
+
#
|
24
|
+
# @param [String] directory
|
25
|
+
# @yield [String]
|
26
|
+
#
|
27
|
+
def each_file(directory)
|
28
|
+
directory_contents(directory).each do |path|
|
29
|
+
yield path
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end # Files
|
33
|
+
end # BuildTools
|
34
|
+
end # Opener
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Opener
|
2
|
+
module BuildTools
|
3
|
+
##
|
4
|
+
# Module that provides helper methods for dealing with Java specific
|
5
|
+
# projects.
|
6
|
+
#
|
7
|
+
module Java
|
8
|
+
module_function
|
9
|
+
|
10
|
+
##
|
11
|
+
# Returns a String containing the Java version in a RubyGems compatible
|
12
|
+
# format.
|
13
|
+
#
|
14
|
+
# @return [String]
|
15
|
+
#
|
16
|
+
def java_version
|
17
|
+
return `java -version 2>&1`.match(/java\s+version\s+"([\d\.]+)_/)[1]
|
18
|
+
end
|
19
|
+
end # Java
|
20
|
+
end # BuildTools
|
21
|
+
end # Opener
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Opener
|
2
|
+
module BuildTools
|
3
|
+
##
|
4
|
+
# Module that provides helper methods for dealing with Perl specific
|
5
|
+
# projects.
|
6
|
+
#
|
7
|
+
module Perl
|
8
|
+
module_function
|
9
|
+
|
10
|
+
##
|
11
|
+
# Checks if a given Perl module is installed. If the module can not be
|
12
|
+
# found the current script is terminated.
|
13
|
+
#
|
14
|
+
# @param [String] name The full name of the Perl module.
|
15
|
+
#
|
16
|
+
def require_perl_module(name)
|
17
|
+
print "Checking for Perl module #{name}... "
|
18
|
+
|
19
|
+
output = `perl -M#{name} -e 'print "exists";' 2>&1`.strip
|
20
|
+
|
21
|
+
if output == 'exists'
|
22
|
+
puts 'yes'
|
23
|
+
else
|
24
|
+
abort 'no'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Returns a String containing the Perl version in a RubyGems comparible
|
30
|
+
# format.
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
#
|
34
|
+
def perl_version
|
35
|
+
`perl --version 2>&1`.match(/\(v([\d\.]+)\)/)[1]
|
36
|
+
end
|
37
|
+
end # Perl
|
38
|
+
end # BuildTools
|
39
|
+
end # Opener
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Opener
|
2
|
+
module BuildTools
|
3
|
+
##
|
4
|
+
# Module that contains various helper methods for dealing with Python, Pip
|
5
|
+
# and other Python tools.
|
6
|
+
#
|
7
|
+
module Python
|
8
|
+
module_function
|
9
|
+
|
10
|
+
##
|
11
|
+
# Returns a String containing the Python version. This only includes the
|
12
|
+
# numerical value, the prefix "Python " is not included.
|
13
|
+
#
|
14
|
+
# @return [String]
|
15
|
+
#
|
16
|
+
def python_version
|
17
|
+
return `python --version 2>&1`.split(/([\d\.]+)/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# Returns a String containing the Pip version in a RubyGems compatible
|
22
|
+
# format.
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
def pip_version
|
27
|
+
return `pip --version 2>&1`.match(/pip\s+([\d\.]+)/)[1].chomp('.')
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Installs the packages in the requirements file in a specific directory.
|
32
|
+
#
|
33
|
+
# @param [String] file The requirements file to use.
|
34
|
+
# @param [String] target The target directory to install packages in.
|
35
|
+
#
|
36
|
+
def pip_install(file, target)
|
37
|
+
Rake::FileUtilsExt.sh(
|
38
|
+
"pip install --requirement=#{file} --target=#{target} " \
|
39
|
+
"--ignore-installed"
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Installs a set of Python packages in a given directory based on a
|
45
|
+
# requirements file. If the directory is not empty this process is
|
46
|
+
# aborted.
|
47
|
+
#
|
48
|
+
# @param [String] file The requirements file to install.
|
49
|
+
# @param [String] directory The name of the directory to install the
|
50
|
+
# packages into.
|
51
|
+
#
|
52
|
+
def install_python_packages(requirements, directory)
|
53
|
+
return unless directory_contents(directory).empty?
|
54
|
+
|
55
|
+
pip_install(requirements, directory)
|
56
|
+
end
|
57
|
+
end # Python
|
58
|
+
end # BuildTools
|
59
|
+
end # Opener
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Opener
|
2
|
+
module BuildTools
|
3
|
+
##
|
4
|
+
# Module that provides various helper methods for ensuring certain
|
5
|
+
# executables exist, version requirements are met and so on.
|
6
|
+
#
|
7
|
+
module Requirements
|
8
|
+
module_function
|
9
|
+
|
10
|
+
##
|
11
|
+
# Checks if a given executable can be found in $PATH and aborts if this
|
12
|
+
# isn't the case.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# require_executable('python')
|
16
|
+
#
|
17
|
+
# @param [String] name
|
18
|
+
#
|
19
|
+
def require_executable(name)
|
20
|
+
print "Checking for #{name}... "
|
21
|
+
|
22
|
+
exists = false
|
23
|
+
|
24
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |directory|
|
25
|
+
path = File.join(directory, name)
|
26
|
+
|
27
|
+
if File.executable?(path)
|
28
|
+
exists = true
|
29
|
+
break
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
if exists
|
34
|
+
puts 'yes'
|
35
|
+
else
|
36
|
+
abort 'no'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Checks if the version specified in `current` is greater than or equal
|
42
|
+
# to the version specified in `requirement`.
|
43
|
+
#
|
44
|
+
# @example Ensures that Python's version is >= 2.7.0
|
45
|
+
# require_version('python', '2.7.5', '2.7.0')
|
46
|
+
#
|
47
|
+
# @param [String] name The name of the executable.
|
48
|
+
# @param [String] current The current version.
|
49
|
+
# @param [String] required The minimum required version.
|
50
|
+
#
|
51
|
+
def require_version(name, current, required)
|
52
|
+
print "Checking for #{name} >= #{required}... "
|
53
|
+
|
54
|
+
if version_greater_than(current, required)
|
55
|
+
puts 'yes'
|
56
|
+
else
|
57
|
+
abort 'no'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# Checks if the version string to the left is greater or equal to the
|
63
|
+
# version string on the right.
|
64
|
+
#
|
65
|
+
# @param [String] left
|
66
|
+
# @param [String] right
|
67
|
+
# @return [TrueClass|FalseClass]
|
68
|
+
#
|
69
|
+
def version_greater_than(left, right)
|
70
|
+
return Gem::Version.new(left) >= Gem::Version.new(right)
|
71
|
+
end
|
72
|
+
end # Requirements
|
73
|
+
end # BuildTools
|
74
|
+
end # Opener
|
@@ -0,0 +1,17 @@
|
|
1
|
+
##
|
2
|
+
# These Rake tasks require the following constants to be predefined:
|
3
|
+
#
|
4
|
+
# * TMP_DIRECTORY: path to the local tmp/ directory
|
5
|
+
#
|
6
|
+
|
7
|
+
namespace :clean do
|
8
|
+
desc 'Removes tmp files'
|
9
|
+
task :tmp do
|
10
|
+
sh("rm -f #{File.join(TMP_DIRECTORY, '*.kaf')}")
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Removes all built Gem files'
|
14
|
+
task :gems do
|
15
|
+
sh('rm -f pkg/*.gem')
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
##
|
2
|
+
# The Java Rake tasks require the following constant to be defined:
|
3
|
+
#
|
4
|
+
# * CORE_DIRECTORY: path containing the Java source code.
|
5
|
+
#
|
6
|
+
|
7
|
+
namespace :java do
|
8
|
+
desc 'Installs Java packages in core/'
|
9
|
+
task :compile do
|
10
|
+
Dir.chdir(CORE_DIRECTORY) do
|
11
|
+
sh "mvn package"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :clean do
|
16
|
+
desc 'Removes built Java packages'
|
17
|
+
task :packages do
|
18
|
+
Dir.chdir(CORE_DIRECTORY) do
|
19
|
+
sh 'mvn clean'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
##
|
2
|
+
# The Python Rake tasks require the following constants to be defined:
|
3
|
+
#
|
4
|
+
# * PRE_BUILD_REQUIREMENTS: pip requirements to be installed before building
|
5
|
+
# the Gem.
|
6
|
+
# * PRE_INSTALL_REQUIREMENTS: pip requirements to be installed upon Gem
|
7
|
+
# installation.
|
8
|
+
# * PYTHON_SITE_PACKAGES: path to the local site-packages directory, only used
|
9
|
+
# by the `python_packages` task.
|
10
|
+
#
|
11
|
+
|
12
|
+
namespace :python do
|
13
|
+
desc 'Installs Python packages in core/site-packages'
|
14
|
+
task :compile => :requirements do
|
15
|
+
requirements = {
|
16
|
+
PRE_BUILD_REQUIREMENTS => 'pre_build',
|
17
|
+
PRE_INSTALL_REQUIREMENTS => 'pre_install'
|
18
|
+
}
|
19
|
+
|
20
|
+
requirements.each do |file, directory|
|
21
|
+
path = File.join(PYTHON_SITE_PACKAGES, directory)
|
22
|
+
|
23
|
+
if File.file?(file)
|
24
|
+
Opener::BuildTools::Python.install_python_packages(file, path)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :clean do
|
30
|
+
desc 'Removes built Python packages'
|
31
|
+
task :packages do
|
32
|
+
each_file(PYTHON_SITE_PACKAGES) do |group|
|
33
|
+
each_file(group) do |directory|
|
34
|
+
sh("rm -rf #{directory}")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Removes Python bytecode files'
|
40
|
+
task :bytecode do
|
41
|
+
sh('find . -name "*.pyc" -delete')
|
42
|
+
sh('find . -name "*.pyo" -delete')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../lib/opener/build-tools/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'opener-build-tools'
|
5
|
+
gem.version = Opener::BuildTools::VERSION
|
6
|
+
gem.authors = ['development@olery.com']
|
7
|
+
gem.summary = 'Various build tools for OpeNER projects.'
|
8
|
+
gem.description = gem.summary
|
9
|
+
gem.homepage = 'http://opener-project.github.com'
|
10
|
+
|
11
|
+
gem.required_ruby_version = '>= 1.9.2'
|
12
|
+
|
13
|
+
gem.files = Dir.glob([
|
14
|
+
'lib/**/*.*',
|
15
|
+
'*.gemspec',
|
16
|
+
'README.md'
|
17
|
+
])
|
18
|
+
|
19
|
+
gem.add_dependency 'rake'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opener-build-tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- development@olery.com
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Various build tools for OpeNER projects.
|
28
|
+
email:
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- README.md
|
34
|
+
- lib/opener/build-tools.rb
|
35
|
+
- lib/opener/build-tools/files.rb
|
36
|
+
- lib/opener/build-tools/java.rb
|
37
|
+
- lib/opener/build-tools/perl.rb
|
38
|
+
- lib/opener/build-tools/python.rb
|
39
|
+
- lib/opener/build-tools/requirements.rb
|
40
|
+
- lib/opener/build-tools/tasks/clean.rb
|
41
|
+
- lib/opener/build-tools/tasks/java.rb
|
42
|
+
- lib/opener/build-tools/tasks/python.rb
|
43
|
+
- lib/opener/build-tools/version.rb
|
44
|
+
- opener-build-tools.gemspec
|
45
|
+
homepage: http://opener-project.github.com
|
46
|
+
licenses: []
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.9.2
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.2.2
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: Various build tools for OpeNER projects.
|
68
|
+
test_files: []
|
69
|
+
has_rdoc:
|