Skip to content

Commit

Permalink
Merge pull request #573 from miked63017/master
Browse files Browse the repository at this point in the history
Allowed for MYMETA files in cpan source
  • Loading branch information
jordansissel committed Dec 6, 2013
2 parents 8c6393a + d4708f4 commit 2166746
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 16 deletions.
15 changes: 12 additions & 3 deletions lib/fpm/package/cpan.rb
Expand Up @@ -40,16 +40,25 @@ def input(package)
require "net/http"
require "json"

result = search(package)
tarball = download(result, version)
moduledir = unpack(tarball)
if (attributes[:cpan_local_module?])
moduledir = package
else
result = search(package)
tarball = download(result, version)
moduledir = unpack(tarball)
end

# Read package metadata (name, version, etc)
if File.exists?(File.join(moduledir, "META.json"))
metadata = JSON.parse(File.read(File.join(moduledir, ("META.json"))))
elsif File.exists?(File.join(moduledir, ("META.yml")))
require "yaml"
metadata = YAML.load_file(File.join(moduledir, ("META.yml")))
elsif File.exists?(File.join(moduledir, "MYMETA.json"))
metadata = JSON.parse(File.read(File.join(moduledir, ("MYMETA.json"))))
elsif File.exists?(File.join(moduledir, ("MYMETA.yml")))
require "yaml"
metadata = YAML.load_file(File.join(moduledir, ("MYMETA.yml")))
else
raise FPM::InvalidPackageConfiguration,
"Could not find package metadata. Checked for META.json and META.yml"
Expand Down
49 changes: 36 additions & 13 deletions lib/fpm/package/python.rb
Expand Up @@ -75,20 +75,46 @@ class FPM::Package::Python < FPM::Package
# * The path to a setup.py
def input(package)
path_to_package = download_if_necessary(package, version)
if (attributes[:python_pip] and path_to_package.kind_of?(Array))
path_to_package.each do |path|
if File.directory?(path)
setup_py = File.join(path, "setup.py")
else
setup_py = path
end

if !File.exists?(setup_py)
@logger.error("Could not find 'setup.py'", :path => setup_py)
raise "Unable to find python package; tried #{setup_py}"
end

if File.directory?(path_to_package)
setup_py = File.join(path_to_package, "setup.py")
load_package_info(setup_py)
install_to_staging(setup_py)
end
else
setup_py = path_to_package
end
path = path_to_package.first
# not sure why this was needed since download_if_needed only returned dirs.first
# moved here anyway, should never fail since .first
if path.length != 1
raise "Unexpected directory layout after easy_install. Maybe file a bug?"
end

if File.directory?(path)
setup_py = File.join(path, "setup.py")
else
setup_py = path
end

if !File.exists?(setup_py)
@logger.error("Could not find 'setup.py'", :path => setup_py)
raise "Unable to find python package; tried #{setup_py}"
end

load_package_info(setup_py)
install_to_staging(setup_py)

if !File.exists?(setup_py)
@logger.error("Could not find 'setup.py'", :path => setup_py)
raise "Unable to find python package; tried #{setup_py}"
end

load_package_info(setup_py)
install_to_staging(setup_py)
end # def input

# Download the given package if necessary. If version is given, that version
Expand Down Expand Up @@ -128,10 +154,7 @@ def download_if_necessary(package, version=nil)
# easy_install will put stuff in @tmpdir/packagename/, so find that:
# @tmpdir/somepackage/setup.py
dirs = ::Dir.glob(File.join(target, "*"))
if dirs.length != 1
raise "Unexpected directory layout after easy_install. Maybe file a bug? The directory is #{build_path}"
end
return dirs.first
return dirs
end # def download

# Load the package information like name, version, dependencies.
Expand Down

0 comments on commit 2166746

Please sign in to comment.