Skip to content

Loading…

Add python hachoir-metadata #31044

Closed
wants to merge 10 commits into from

3 participants

@spk

Added formula to install hachoir.

@mikemcquaid
Homebrew member

I think these should be a single formula that installs all the parts.

@spk

Ok I think then only hachoir-metadata is needed

@adamv adamv added the new formula label
@spk spk changed the title from Add hachoir core parser regex and metadata to Add python hachoir-metadata
@spk

I updated this PR to have one commit and install only hachoir-metadata

@mikemcquaid
Homebrew member

@BrewTestBot test this please

@mikemcquaid mikemcquaid commented on an outdated diff
Library/Formula/hachoir-metadata.rb
@@ -0,0 +1,41 @@
+require "formula"
+
+class HachoirMetadata < Formula
+ homepage "https://bitbucket.org/haypo/hachoir/wiki/Home"
+ url "http://cheeseshop.python.org/packages/source/h/hachoir-metadata/hachoir-metadata-1.3.3.tar.gz"
+ sha1 "6f44f2f15a5d24866636117901d0b870137d8af7"
+
+ depends_on :python if MacOS.version <= :snow_leopard
+
+ resource 'hachoir-core' do
@mikemcquaid Homebrew member

Use double-quotes everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mikemcquaid mikemcquaid commented on an outdated diff
Library/Formula/hachoir-metadata.rb
((24 lines not shown))
+ ENV["PYTHONPATH"] = lib+"python2.7/site-packages"
+ ENV.prepend_create_path 'PYTHONPATH', libexec+'lib/python2.7/site-packages'
+ ENV.prepend_create_path 'PYTHONPATH', prefix+'lib/python2.7/site-packages'
+
+ install_args = [ "setup.py", "install", "--prefix=#{libexec}" ]
+ res = %w[hachoir-core hachoir-parser hachoir-regex]
+ res.each do |r|
+ resource(r).stage { system "python", *install_args }
+ end
+
+ system "python", "setup.py", "install", "--prefix=#{prefix}"
+ bin.env_script_all_files(libexec+'bin', :PYTHONPATH => ENV['PYTHONPATH'])
+ end
+
+ test do
+ system "#{bin}/hachoir-metadata", "--version"
@mikemcquaid Homebrew member

Can this test be modified to do something more substantial then e.g. --version or --help? See cmake.rb for an example of a formula with a good test. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mikemcquaid
Homebrew member

Looking much better! A few suggestions.

@spk

Hope you will like it !

@mikemcquaid mikemcquaid commented on an outdated diff
Library/Formula/hachoir-metadata.rb
((25 lines not shown))
+ ENV["PYTHONPATH"] = lib+"python2.7/site-packages"
+ ENV.prepend_create_path "PYTHONPATH", libexec+"lib/python2.7/site-packages"
+ ENV.prepend_create_path "PYTHONPATH", prefix+"lib/python2.7/site-packages"
+
+ install_args = [ "setup.py", "install", "--prefix=#{libexec}" ]
+ res = %w[hachoir-core hachoir-parser hachoir-regex]
+ res.each do |r|
+ resource(r).stage { system "python", *install_args }
+ end
+
+ system "python", "setup.py", "install", "--prefix=#{prefix}"
+ bin.env_script_all_files(libexec+"bin", :PYTHONPATH => ENV["PYTHONPATH"])
+ end
+
+ test do
+ output = `#{bin}/hachoir-metadata --version`
@mikemcquaid Homebrew member

This is still just checking the version. Could you do something to actually run the tool on some input?

@spk
spk added a note

Ah ok ! Yes I do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@spk

I'm creating a one sized pixel png file and test the mime type is equal to image/png

@mikemcquaid
Homebrew member

Seems that brew test and brew audit are failing, I'm afraid :sob:

@spk

It's working fine locally I'm under 10.9.4 OS X, can I have some help ?

@mikemcquaid
Homebrew member

It's failing under 10.7 and 10.8. Perhaps you should add a failure message to the assertions so we can see which one is failing.

@spk

@mikemcquaid It's the mime test that failing but no output... Do you have an idea ? I'm new to OS X environment.

@mikemcquaid mikemcquaid commented on an outdated diff
Library/Formula/hachoir-metadata.rb
@@ -0,0 +1,57 @@
+require "formula"
+
+class HachoirMetadata < Formula
+ VERSION = '1.3.3'
@mikemcquaid Homebrew member

Remove this; just use version in the formula where you need to access it instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mikemcquaid
Homebrew member

@spk I'm not sure what's going on there. We could perhaps limit it to Mavericks and add a comment if someone else wants to fix it in future? @mistydemeo @adamv @jacknagel Any thoughts?

@spk

If people don't want to debug my stuff I can understand. I limit then to Mavericks. Thanks for the helps !

@mikemcquaid
Homebrew member

In fact, I've got an idea of what it might be. Those versions are running Ruby 1.8 so the unicode output may be different. I think it might be better to just create a PNG and put it in the Homebrew repo. @jacknagel @mistydemeo @adamv any objections to me putting a single, small image in the repo to use as test data? It would also help with formulae like imagemagick.

@spk

Ah ok cool, where can I put it ?

@mikemcquaid
Homebrew member

@spk Hold off for a bit while I wait for the other maintainers to weigh in.

@adamv

A small png in the test folder seems fine.

@spk

@mikemcquaid Sorry ! I'm waiting for GO !

@mikemcquaid
Homebrew member

@spk Can you put a 1x1 PNG file in Library/Homebrew/test/fixtures/test.png and modify the test to use that? Thanks!

@spk

Roger o>

@spk

\o/

@mikemcquaid
Homebrew member

Thanks for all your work here!

@spk spk deleted the unknown repository branch
@sheurich sheurich added a commit that referenced this pull request
@mikemcquaid mikemcquaid hachoir-metadata: add 1.3.3 bottle.
Closes #31044.
e2a23c9
@aerickson aerickson added a commit to aerickson/homebrew that referenced this pull request
@mikemcquaid mikemcquaid hachoir-metadata: add 1.3.3 bottle.
Closes #31044.
43c9e25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 55 additions and 0 deletions.
  1. +55 −0 Library/Formula/hachoir-metadata.rb
  2. BIN Library/Homebrew/test/fixtures/test.png
View
55 Library/Formula/hachoir-metadata.rb
@@ -0,0 +1,55 @@
+require "formula"
+
+class HachoirMetadata < Formula
+ homepage "https://bitbucket.org/haypo/hachoir/wiki/Home"
+ url "http://cheeseshop.python.org/packages/source/h/hachoir-metadata/hachoir-metadata-1.3.3.tar.gz"
+ sha1 "6f44f2f15a5d24866636117901d0b870137d8af7"
+
+ depends_on :python if MacOS.version <= :snow_leopard
+
+ resource "hachoir-core" do
+ url "http://cheeseshop.python.org/packages/source/h/hachoir-core/hachoir-core-1.3.3.tar.gz"
+ sha1 "e1d3b5da7d57087c922942b7653cb3b195c7769f"
+ end
+ resource "hachoir-parser" do
+ url "http://cheeseshop.python.org/packages/source/h/hachoir-parser/hachoir-parser-1.3.4.tar.gz"
+ sha1 "8433e1598b1e8d9404e6978117a203775e68c075"
+ end
+ resource "hachoir-regex" do
+ url "http://cheeseshop.python.org/packages/source/h/hachoir-regex/hachoir-regex-1.0.5.tar.gz"
+ sha1 "98a3c7e8922f926fdb6c1dec92e093d75712eb3b"
+ end
+
+ def install
+ ENV["PYTHONPATH"] = lib+"python2.7/site-packages"
+ ENV.prepend_create_path "PYTHONPATH", libexec+"lib/python2.7/site-packages"
+ ENV.prepend_create_path "PYTHONPATH", prefix+"lib/python2.7/site-packages"
+
+ install_args = [ "setup.py", "install", "--prefix=#{libexec}" ]
+ res = %w[hachoir-core hachoir-parser hachoir-regex]
+ res.each do |r|
+ resource(r).stage { system "python", *install_args }
+ end
+
+ system "python", "setup.py", "install", "--prefix=#{prefix}"
+ bin.env_script_all_files(libexec+"bin", :PYTHONPATH => ENV["PYTHONPATH"])
+ end
+
+ test do
+ print "Testing hachoir-metadata version (#{version}) ... "
+ output = `#{bin}/hachoir-metadata --version`
+ puts "#{output.chomp}."
+ assert output.include?(version), 'hachoir version error.'
+ assert_equal 0, $?.exitstatus, 'exitstatus error.'
+
+ print "Testing png file mime type ..."
+ png_file_path = (HOMEBREW_LIBRARY / 'Homebrew' / 'test' / 'fixtures' / 'test.png')
+ output = `#{bin}/hachoir-metadata --mime #{png_file_path}`
+ puts "#{output.chomp}."
+ assert output.include?('image/png'), 'hachoir mime error.'
+ assert_equal 0, $?.exitstatus, 'exitstatus error.'
+
+ puts "Cleanup ..."
+ rm png_file_path
+ end
+end
View
BIN Library/Homebrew/test/fixtures/test.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Something went wrong with that request. Please try again.