-
Notifications
You must be signed in to change notification settings - Fork 14
/
setup.py
66 lines (56 loc) · 2.08 KB
/
setup.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /usr/bin/env python
from distutils.core import setup, Extension
from distutils.command.build import build
from distutils.spawn import spawn
import os, os.path
pathjoin = os.path.join
GITVER = '0.5.31'
PKGNAME = 'libhtp-' + GITVER
PKGTAR = PKGNAME + '.tar.gz'
BUILDDIR = 'libhtp-' + GITVER
INCLUDE_DIRS = ['/usr/local/include', '/opt/local/include', '/usr/include']
LIBRARY_DIRS = ['/usr/lib', '/usr/local/lib']
EXTRA_OBJECTS = ['-lz']
class htpyMaker(build):
HTPTAR = PKGTAR
HTPDIR = BUILDDIR
include_dirs = [ HTPDIR, pathjoin(HTPDIR, 'htp') ]
library_dirs = []
extra_objects = [ pathjoin(HTPDIR, 'htp/.libs', 'libhtp.a') ]
libhtp = pathjoin(HTPDIR, 'htp/.libs', 'libhtp.a')
uname = os.uname()[0]
if uname != 'Linux':
EXTRA_OBJECTS.append('-liconv')
def buildHtp(self):
# extremely crude package builder
try:
os.stat(self.libhtp)
return None # assume already built
except OSError:
pass
spawn(['tar', '-zxf', self.HTPTAR], search_path = 1)
os.chdir(self.HTPDIR)
spawn([pathjoin('.','autogen.sh')], '-i')
spawn([pathjoin('.','configure'), 'CFLAGS=-fPIC'])
spawn(['make'], search_path = 1)
os.chdir('..')
def run(self):
self.buildHtp()
build.run(self)
INCLUDE_DIRS = htpyMaker.include_dirs + INCLUDE_DIRS
EXTRA_OBJECTS = htpyMaker.extra_objects + EXTRA_OBJECTS
setup (# Distribution meta-data
name = "htpy",
version = "0.26",
description = "python bindings for libhtp",
author = "Wesley Shields",
author_email = "[email protected]",
license = "BSD",
long_description = "Python bindings for libhtp",
cmdclass = {'build': htpyMaker},
ext_modules = [Extension("htpy",
sources=["htpy.c"],
include_dirs = INCLUDE_DIRS,
library_dirs = LIBRARY_DIRS,
extra_objects = EXTRA_OBJECTS)],
url = "http://github.com/MITRECND/htpy")