-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
104 lines (85 loc) · 2.96 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python
import os
import sys
from distutils.core import setup, Extension
from distutils.command.build_ext import build_ext
src = ['dnet/dnet.c']
dep = []
Libraries = []
IncludeDirs = []
LibraryDirs = []
include = "#include <dnet.h>"
if sys.platform == 'win32' or sys.platform == "nt":
# XXX this is currently broken.
Libraries = ["ws2_32", "advapi32", "iphlpapi", "ws2_32", "packet"]
class BuildExtension(build_ext):
user_options = (build_ext.user_options +
[("with-dnet=", None,
"directory where dnet is installed"),
("with-winpcap=", None,
"directory where winpcap is installed")])
with_dnet = None
with_winpcap = None
dnet_dlls = ()
dnet_mingw = False
def finalize_options(self):
build_ext.finalize_options(self)
if self.with_dnet is None:
self.find_dnet()
if self.with_winpcap is None:
self.find_winpcap()
self.find_dnet_dlls()
self.add_dnet_compile_info()
def find_dnet(self):
"""
Find dnet's install directory.
TODO get windows machine to implement this.
"""
pass
def find_dnet_dlls(self):
self.dnet_dlls = []
self.find_dnet_dll()
def find_dnet_dll(self):
pass
def find_winpcap_dir(self):
self.winpcap_dir = "/"
def add_dnet_compile_info(self):
self.include_dirs.append(self.with_winpcap + '/Include')
self.library_dirs.append(self.with_winpcap + '/Lib')
# self.include_dirs.append()
# self.library_dirs.append()
# self.libraries.extend(["libdnet"])
def run(self):
build_ext.run(self)
for dllpath, newpath in self.dnet_dlls:
self.copy_file(dllpath, newpath)
def get_outputs(self):
output = [pathpair[1] for pathpair in self.dnet_dlls]
output.extend(build_ext.get_outputs(self))
return output
else:
BuildExtension = build_ext
Libraries = ["dnet"]
if os.path.isfile("/usr/include/dumbnet.h"):
include = "#include <dumbnet.h>"
Libraries = ["dumbnet"]
with open("dnet/dnet.h", "w+") as f:
f.write(include)
dnet_extension = Extension('dnet',
src,
libraries=Libraries,
depends=dep,
include_dirs=IncludeDirs,
library_dirs=LibraryDirs)
setup(
name='pydumbnet',
version='1.12.1',
packages=["dnet"],
package_dir={"dnet": "dnet"},
description='low-level networking library',
author='Dug Song',
author_email='[email protected]',
cmdclass={"build_ext": BuildExtension},
url='http://libdnet.sourceforge.net/',
ext_modules=[dnet_extension]
)