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

pHash: init at 0.9.4 #42546

Merged
merged 1 commit into from Jun 27, 2018
Merged

pHash: init at 0.9.4 #42546

merged 1 commit into from Jun 27, 2018

Conversation

imalsogreg
Copy link
Contributor

Motivation for this change

pHash is a useful c library with several small quirks in its build process and increasing numbers of workarounds for building on other systems.

We also have phash Haskell bindings in nixpkgs which is broken due to lack of packaging of the c library.

Things done
  • Tested using sandboxing (nix.useSandbox on 14.3.4. Tested compilation of all pkgs that depend on this change using nox-review
    NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/) (N/A)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

Additional testing

C
Wrote a small c program depending on pHash which passes a CLI argument to the library and prints the hash. This works on NixOS and Darwin.

Haskell
The phash Haskell library with modifications to the cabal file, to use pkgconfig-depends field. This doesn't quite work out of the box, for reasons I am still trying to understand (and which may be due to problems with pHash, my nix packaging, cabal, or pkg-config, or any combination of the above). I can get the library to compile only if I add a second fake pkg-config dependency (I chose libzmq randomly). With two entries in pkgconfig-depends field, the phash bindings can successfully hash an image from a filepath. However when using only the true dependency, configure phase fails:

Setup: Missing dependency on a foreign library:
* Missing C library: pHash
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
builder for '/nix/store/larbzl42wciih3ac4ffd1cd02blpw2gc-phash-0.0.6.drv' failed with exit code 1
error: build of '/nix/store/larbzl42wciih3ac4ffd1cd02blpw2gc-phash-0.0.6.drv' failed

Copy link
Contributor

@jb55 jb55 left a comment

Choose a reason for hiding this comment

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

ah I've been meaning to try this library, thanks! I have a few changes to suggest.

@@ -1717,6 +1717,11 @@
github = "ilya-kolpakov";
name = "Ilya Kolpakov";
};
imalsogreg = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Welcome!

Needs rebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:)

src = fetchFromGitHub {
owner = "clearscene";
repo = "pHash";
rev = "0.9.4";
Copy link
Contributor

Choose a reason for hiding this comment

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

rev = version


meta = {
inherit version;
description = ''Compute the perceptual hash of an image'';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: '' '' is for multi-line string, you can just use "Compute the perceptual hash of an image" here

sha256 = "0y4gknfkns5sssfaj0snyx29752my20xmxajg6xggijx0myabbv0";
};

meta = {
Copy link
Contributor

Choose a reason for hiding this comment

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

style nit: common pattern is to do:

meta = with stdenv.lib; { }

so you don't have to fully qualify everything in the meta

@imalsogreg
Copy link
Contributor Author

@jb55 Thank you for the pointers! I've made those changes and rebased on master.

meta = with stdenv.lib; {
inherit version;
description = "Compute the perceptual hash of an image";
license = icenses.gpl3;
Copy link
Contributor

Choose a reason for hiding this comment

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

oops: icenses -> licenses

Fix style and redundancy issues pointed out by @jb55
@imalsogreg
Copy link
Contributor Author

@jb55 Hah, how embarrassing. I assumed the meta fields are checked by nix build, which is how I test locally before checking in. Fixed, and noted for next time!

@xeji
Copy link
Contributor

xeji commented Jun 27, 2018

@GrahamcOfBorg build phash

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: phash

Partial log (click to expand)

make[2]: Leaving directory '/build/source'
make[1]: Leaving directory '/build/source'
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/c1d2k0szbs4srwpm0pswsxzfawzwb514-pHash-0.9.4
shrinking /nix/store/c1d2k0szbs4srwpm0pswsxzfawzwb514-pHash-0.9.4/lib/libpHash.so.0.0.0
/nix/store/c1d2k0szbs4srwpm0pswsxzfawzwb514-pHash-0.9.4
strip is /nix/store/4qvrxzxa535y8304mk195x50b6p9607d-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/c1d2k0szbs4srwpm0pswsxzfawzwb514-pHash-0.9.4/lib
patching script interpreter paths in /nix/store/c1d2k0szbs4srwpm0pswsxzfawzwb514-pHash-0.9.4
checking for references to /build in /nix/store/c1d2k0szbs4srwpm0pswsxzfawzwb514-pHash-0.9.4...

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: phash

Partial log (click to expand)

 /nix/store/5q51r2d0xzs4hi8rb661drpf83mhm4b4-coreutils-8.29/bin/install -c -m 644 pHash-config.h '/nix/store/ypm86zijipijsyy67dkbcmyly6fwns8x-pHash-0.9.4/include'
test -z "/nix/store/ypm86zijipijsyy67dkbcmyly6fwns8x-pHash-0.9.4/lib/pkgconfig" || /nix/store/5q51r2d0xzs4hi8rb661drpf83mhm4b4-coreutils-8.29/bin/mkdir -p "/nix/store/ypm86zijipijsyy67dkbcmyly6fwns8x-pHash-0.9.4/lib/pkgconfig"
 /nix/store/5q51r2d0xzs4hi8rb661drpf83mhm4b4-coreutils-8.29/bin/install -c -m 644 pHash.pc '/nix/store/ypm86zijipijsyy67dkbcmyly6fwns8x-pHash-0.9.4/lib/pkgconfig'
make[2]: Leaving directory '/private/tmp/nix-build-pHash-0.9.4.drv-0/source'
make[1]: Leaving directory '/private/tmp/nix-build-pHash-0.9.4.drv-0/source'
post-installation fixup
strip is /nix/store/7ddbq63v97nk8gkbf7gcsfmby37h6gbl-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/ypm86zijipijsyy67dkbcmyly6fwns8x-pHash-0.9.4/lib
patching script interpreter paths in /nix/store/ypm86zijipijsyy67dkbcmyly6fwns8x-pHash-0.9.4
/nix/store/ypm86zijipijsyy67dkbcmyly6fwns8x-pHash-0.9.4

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: phash

Partial log (click to expand)

make[2]: Leaving directory '/build/source'
make[1]: Leaving directory '/build/source'
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/29xsx57fwrq4rdmasslsx57frr30xkl9-pHash-0.9.4
shrinking /nix/store/29xsx57fwrq4rdmasslsx57frr30xkl9-pHash-0.9.4/lib/libpHash.so.0.0.0
strip is /nix/store/0pjsgkxz0rp5baycq5sp2s72lrr5q9sg-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/29xsx57fwrq4rdmasslsx57frr30xkl9-pHash-0.9.4/lib
patching script interpreter paths in /nix/store/29xsx57fwrq4rdmasslsx57frr30xkl9-pHash-0.9.4
checking for references to /build in /nix/store/29xsx57fwrq4rdmasslsx57frr30xkl9-pHash-0.9.4...
/nix/store/29xsx57fwrq4rdmasslsx57frr30xkl9-pHash-0.9.4

@xeji
Copy link
Contributor

xeji commented Jun 27, 2018

Thank you!

@xeji xeji merged commit 98c1ad8 into NixOS:master Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants