fpm 0.2.23 → 0.2.24
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/fpm +1 -1
- data/lib/fpm.rb +1 -0
- data/lib/fpm/builder.rb +2 -1
- data/lib/fpm/source/pyfpm/__init__.py +1 -0
- data/lib/fpm/source/pyfpm/__init__.pyc +0 -0
- data/lib/fpm/source/pyfpm/get_metadata.py +79 -0
- data/lib/fpm/source/pyfpm/get_metadata.pyc +0 -0
- data/lib/fpm/source/python.rb +102 -0
- metadata +8 -3
data/bin/fpm
CHANGED
@@ -72,7 +72,7 @@ def main(args)
|
|
72
72
|
settings.source_type = st
|
73
73
|
end # -s
|
74
74
|
|
75
|
-
opts.on("-S PACKAGE_SUFFIX", "which suffix to append to package and
|
75
|
+
opts.on("-S PACKAGE_SUFFIX", "which suffix to append to package and dependencies") do |sfx|
|
76
76
|
settings.suffix = sfx
|
77
77
|
end # -S
|
78
78
|
|
data/lib/fpm.rb
CHANGED
data/lib/fpm/builder.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
__all__ = [ "list_dependencies" ]
|
Binary file
|
@@ -0,0 +1,79 @@
|
|
1
|
+
from distutils.core import Command
|
2
|
+
import json
|
3
|
+
import re
|
4
|
+
import time
|
5
|
+
|
6
|
+
# Note, the last time I coded python daily was at Google, so it's entirely
|
7
|
+
# possible some of my techniques below are outdated or bad.
|
8
|
+
# If you have fixes, let me know.
|
9
|
+
|
10
|
+
class get_metadata(Command):
|
11
|
+
description = "get package metadata"
|
12
|
+
user_options = []
|
13
|
+
|
14
|
+
def initialize_options(self):
|
15
|
+
pass
|
16
|
+
# def initialize_options
|
17
|
+
|
18
|
+
def finalize_options(self):
|
19
|
+
pass
|
20
|
+
# def finalize_options
|
21
|
+
|
22
|
+
def run(self):
|
23
|
+
#print type(self.distribution)
|
24
|
+
#for i in sorted(dir(self.distribution)):
|
25
|
+
#if i.startswith("_"):
|
26
|
+
#continue
|
27
|
+
###print "%s: %r" % (i, self.__getattr__(i))
|
28
|
+
#print "%s" % i
|
29
|
+
|
30
|
+
data = {
|
31
|
+
"name": self.distribution.get_name(),
|
32
|
+
"version": self.distribution.get_version(),
|
33
|
+
"author": "%s <%s>" % (self.distribution.get_author(),
|
34
|
+
self.distribution.get_author_email()),
|
35
|
+
"description": self.distribution.get_description(),
|
36
|
+
"license": self.distribution.get_license(),
|
37
|
+
"url": self.distribution.get_url(),
|
38
|
+
}
|
39
|
+
|
40
|
+
# If there are python C/extension modules, we'll want to build a native
|
41
|
+
# arch package.
|
42
|
+
if self.distribution.has_ext_modules():
|
43
|
+
data["architecture"] = "native"
|
44
|
+
else:
|
45
|
+
data["architecture"] = "all"
|
46
|
+
# end if
|
47
|
+
|
48
|
+
dependencies = []
|
49
|
+
try:
|
50
|
+
dependencies = self.distribution.install_requires
|
51
|
+
except:
|
52
|
+
pass
|
53
|
+
|
54
|
+
final_deps = []
|
55
|
+
dep_re = re.compile("([^<>= ]+)(?:\s*([<>=]{1,2})\s*(.*))?$")
|
56
|
+
for dep in dependencies:
|
57
|
+
# python deps are strings that look like:
|
58
|
+
# "packagename"
|
59
|
+
# "packagename >= version"
|
60
|
+
# Replace 'packagename' with 'python#{suffix}-packagename'
|
61
|
+
m = dep_re.match(dep)
|
62
|
+
if m is None:
|
63
|
+
print "Bad dep: %s" % dep
|
64
|
+
time.sleep(3)
|
65
|
+
elif m.groups()[1] is None:
|
66
|
+
name, cond, version = m.groups()[0], ">=", 0
|
67
|
+
else:
|
68
|
+
name, cond, version = m.groups()
|
69
|
+
# end if
|
70
|
+
|
71
|
+
final_deps.append("%s %s %s" % (name, cond, version))
|
72
|
+
# end for i in dependencies
|
73
|
+
|
74
|
+
data["dependencies"] = final_deps
|
75
|
+
|
76
|
+
#print json.dumps(data, indent=2)
|
77
|
+
print json.dumps(data, indent=2)
|
78
|
+
# def run
|
79
|
+
# class list_dependencies
|
Binary file
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require "fpm/namespace"
|
2
|
+
require "fpm/source"
|
3
|
+
require "rubygems/package"
|
4
|
+
require "rubygems"
|
5
|
+
require "fileutils"
|
6
|
+
require "tmpdir"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
class FPM::Source::Python < FPM::Source
|
10
|
+
def get_source(params)
|
11
|
+
package = @paths.first
|
12
|
+
if ["setup.py", "."].include?(package)
|
13
|
+
# Assume we're building from an existing python package.
|
14
|
+
# Source already acquired, nothing to do!
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
if !File.exists?(package)
|
19
|
+
download(package, params[:version])
|
20
|
+
else
|
21
|
+
@paths = [ File.expand_path(package) ]
|
22
|
+
end
|
23
|
+
end # def get_source
|
24
|
+
|
25
|
+
def download(package, version=nil)
|
26
|
+
puts "Trying to download #{package} (using easy_install)"
|
27
|
+
@tmpdir = ::Dir.mktmpdir("python-build", ::Dir.pwd)
|
28
|
+
|
29
|
+
if version.nil?
|
30
|
+
want_pkg = "#{package}"
|
31
|
+
else
|
32
|
+
want_pkg = "#{package}==#{version}"
|
33
|
+
end
|
34
|
+
system("easy_install", "--editable", "--build-directory", @tmpdir, want_pkg)
|
35
|
+
|
36
|
+
# easy_install will put stuff in @tmpdir/packagename/, flatten that.
|
37
|
+
# That is, we want @tmpdir/setup.py, and start with
|
38
|
+
# @tmpdir/somepackage/setup.py
|
39
|
+
dirs = ::Dir.glob(File.join(@tmpdir, "*"))
|
40
|
+
if dirs.length != 1
|
41
|
+
raise "Unexpected directory layout after easy_install. Maybe file a bug? The directory is #{@tmpdir}"
|
42
|
+
end
|
43
|
+
@paths = dirs
|
44
|
+
end # def download
|
45
|
+
|
46
|
+
def get_metadata
|
47
|
+
setup_py = @paths.first
|
48
|
+
if File.directory?(setup_py)
|
49
|
+
setup_py = File.join(setup_py, "setup.py")
|
50
|
+
@paths = [setup_py]
|
51
|
+
end
|
52
|
+
|
53
|
+
if !File.exists?(setup_py)
|
54
|
+
raise "Unable to find python package; tried #{setup_py}"
|
55
|
+
end
|
56
|
+
|
57
|
+
pylib = File.expand_path(File.dirname(__FILE__))
|
58
|
+
setup_cmd = "env PYTHONPATH=#{pylib} python #{setup_py} --command-packages=pyfpm get_metadata"
|
59
|
+
output = ::Dir.chdir(File.dirname(setup_py)) { `#{setup_cmd}` }
|
60
|
+
puts output
|
61
|
+
metadata = JSON.parse(output[/\{.*\}/msx])
|
62
|
+
#p metadata
|
63
|
+
|
64
|
+
self[:architecture] = metadata["architecture"]
|
65
|
+
self[:description] = metadata["description"]
|
66
|
+
self[:license] = metadata["license"]
|
67
|
+
self[:version] = metadata["version"]
|
68
|
+
self[:name] = "python#{self[:suffix]}-#{metadata["name"]}"
|
69
|
+
self[:url] = metadata["url"]
|
70
|
+
|
71
|
+
self[:dependencies] = metadata["dependencies"].collect do |dep|
|
72
|
+
name, cmp, version = dep.split
|
73
|
+
"python#{self[:suffix]}-#{name} #{cmp} #{version}"
|
74
|
+
end
|
75
|
+
end # def get_metadata
|
76
|
+
|
77
|
+
def make_tarball!(tar_path, builddir)
|
78
|
+
setup_py = @paths.first
|
79
|
+
dir = File.dirname(setup_py)
|
80
|
+
|
81
|
+
# Some setup.py's assume $PWD == current directory of setup.py, so let's
|
82
|
+
# chdir first.
|
83
|
+
::Dir.chdir(dir) do
|
84
|
+
system("python", "setup.py", "bdist")
|
85
|
+
end
|
86
|
+
|
87
|
+
dist_tar = ::Dir.glob(File.join(dir, "dist", "*.tar.gz")).first
|
88
|
+
puts "Found dist tar: #{dist_tar}"
|
89
|
+
puts "Copying to #{tar_path}"
|
90
|
+
|
91
|
+
@paths = [ "." ]
|
92
|
+
|
93
|
+
system("cp", dist_tar, "#{tar_path}.gz")
|
94
|
+
end # def make_tarball!
|
95
|
+
|
96
|
+
def garbage
|
97
|
+
trash = []
|
98
|
+
trash << @tmpdir if @tmpdir
|
99
|
+
return trash
|
100
|
+
end # def garbage
|
101
|
+
|
102
|
+
end # class FPM::Source::Gem
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 24
|
10
|
+
version: 0.2.24
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jordan Sissel
|
@@ -51,9 +51,14 @@ files:
|
|
51
51
|
- lib/fpm/namespace.rb
|
52
52
|
- lib/fpm/source.rb
|
53
53
|
- lib/fpm/rubyfixes.rb
|
54
|
+
- lib/fpm/source/python.rb
|
54
55
|
- lib/fpm/source/npm.rb
|
55
56
|
- lib/fpm/source/dir.rb
|
56
57
|
- lib/fpm/source/rpm.rb
|
58
|
+
- lib/fpm/source/pyfpm/__init__.pyc
|
59
|
+
- lib/fpm/source/pyfpm/get_metadata.pyc
|
60
|
+
- lib/fpm/source/pyfpm/get_metadata.py
|
61
|
+
- lib/fpm/source/pyfpm/__init__.py
|
57
62
|
- lib/fpm/source/gem.rb
|
58
63
|
- lib/fpm/target/deb.rb
|
59
64
|
- lib/fpm/target/rpm.rb
|