Half a nop

Compiling Ssdeep and Pydeep on Mac OS X 10.9+

macosx, ssdeep

I decided to finally give a try to a couple neat projects, first one is a modification of VXCage by mboman (originally by @botherder), second one was viper itself.

It got a tidbit complicated installing pydeep, a dependency for both projects. Googling around did not help much.

I like to keep my things tidy, for this I use a mix of brew, virtualenv and other tricks in order to keep python modules and other libs/software as isolated as possible.

First things first, If you just try to brew install ssdeep from brew, it will fetch an old version, you can fix the formula yourself:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ cat <<'EOF' >/usr/local/Library/Formula/ssdeep.rb
require "formula"

class Ssdeep < Formula
  homepage "http://ssdeep.sourceforge.net/"
  url "https://downloads.sourceforge.net/project/ssdeep/ssdeep-2.11.1/ssdeep-2.11.1.tar.gz"
  sha256 "a632ac30fca29ad5627e1bf5fae05d9a8873e6606314922479259531e0c19608"

  def install
    system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}"
    system "make install"
  end
end
EOF

$ brew install ssdeep
==> Downloading https://downloads.sourceforge.net/project/ssdeep/ssdeep-2.11.1/ssdeep-2.11.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/ssdeep-2.11.1.tar.gz
==> ./configure --prefix=/usr/local/Cellar/ssdeep/2.11.1
==> make install
  /usr/local/Cellar/ssdeep/2.11.1: 12 files, 168K, built in 11 seconds

Then if you just:

1
2
$ workon viper # note, for this to work, you need a virtualenv named viper ;)
(viper)$ pip install pydeep

you will be greeted with something along these lines:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Downloading/unpacking pydeep
Downloading pydeep-0.2.tar.gz
Running setup.py egg_info for package pydeep

Installing collected packages: pydeep
  Running setup.py install for pydeep
    building 'pydeep' extension
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pydeep.c -o build/temp.macosx-10.9-intel-2.7/pydeep.o
    pydeep.c:2:10: fatal error: 'fuzzy.h' file not found
    #include <fuzzy.h>
             ^
    1 error generated.
    error: command 'cc' failed with exit status 1
    Complete output from command /Users/wzr/.envs/viper/bin/python -c "import setuptools;__file__='/Users/wzr/.envs/viper/build/pydeep/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/t6/l7f8_fz50dj2lt_r5z4wkhbh0000gn/T/pip-UF4gSb-record/install-record.txt --single-version-externally-managed --install-headers /Users/wzr/.envs/viper/include/site/python2.7:
    running install

running build

running build_ext

building 'pydeep' extension

creating build

creating build/temp.macosx-10.9-intel-2.7

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pydeep.c -o build/temp.macosx-10.9-intel-2.7/pydeep.o

pydeep.c:2:10: fatal error: 'fuzzy.h' file not found

#include <fuzzy.h>

         ^

1 error generated.

error: command 'cc' failed with exit status 1

----------------------------------------
Command /Users/wzr/.envs/viper/bin/python -c "import setuptools;__file__='/Users/wzr/.envs/viper/build/pydeep/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/t6/l7f8_fz50dj2lt_r5z4wkhbh0000gn/T/pip-UF4gSb-record/install-record.txt --single-version-externally-managed --install-headers /Users/wzr/.envs/viper/include/site/python2.7 failed with error code 1 in /Users/wzr/.envs/viper/build/pydeep
Storing complete log in /Users/wzr/.pip/pip.log

Well, that isn’t quite working. Fear not, the compiler just doesn’t know where to find the includes and libs for building the pydeep bindings. This should fix it:

1
2
3
4
5
6
7
8
9
10
11
(viper)$ export LDFLAGS="-L/usr/local/lib"
(viper)$ export C_INCLUDE_PATH=/usr/local/include
(viper)$ pip install pydeep
Downloading/unpacking pydeep
  Running setup.py egg_info for package pydeep

Installing collected packages: pydeep
  Running setup.py install for pydeep

Successfully installed pydeep
Cleaning up...

Comments