Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed for MYMETA files in cpan source #573

Merged
merged 3 commits into from
Dec 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/fpm/package/cpan.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this python change intended? Based on the PR description, this PR should only contain cpan changes, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I could not figure out how to do separate pull requests per
commit. The python change was intentional but I don't think it is ready for
production use based on a few side effects I found. There are two commits
for the cpan source, one for mymeta and one to build from a local dir
instead of always reaching out to download. Both of the cpab changes are
solid as far as I can tell. I can revert the python commit for now if
needed, just let me know. Thanks
On Oct 29, 2013 4:50 PM, "Jordan Sissel" notifications@github.com wrote:

In lib/fpm/package/python.rb:

@@ -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))

Is this python change intended? Based on the PR description, this PR
should only contain cpan changes, right?


Reply to this email directly or view it on GitHubhttps://github.com//pull/573/files#r7294204
.

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