-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·89 lines (77 loc) · 2.82 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
#!/usr/bin/env python
"""
Installs the ofequivalence library
The script automatically downloads the required CUDD BDD library dependency.
If you wish to work offline, or are developing the library it is recommended
that you download CUDD into this folder to avoid downloading it again.
"""
import os
try:
from urllib import urlretrieve
except ImportError:
from urllib.request import urlretrieve
import tarfile
import subprocess
from setuptools import setup, Extension
CUDD_URL = "https://github.com/ivmai/cudd/archive/cudd-3.0.0.tar.gz"
CUDD_DIR = "cudd-cudd-3.0.0" # The dir name within the tar
C_FLAGS = ["-Wall", "-Wextra", "-g3", "-ggdb", "-O3"]
with open('README.md') as f:
README = f.read()
with open('LICENSE') as f:
LICENSE = f.read()
_cbdd = Extension('ofequivalence._cbdd', sources=['c_src/cbddmodule.cpp'],
extra_compile_args=C_FLAGS + ["-std=c++11"])
_utils = Extension('ofequivalence._utils', sources=['c_src/utils.c'],
extra_compile_args=C_FLAGS + ["-mbmi2"])
_cudd = Extension(
'ofequivalence._cudd',
sources=['c_src/cuddmodule.c'],
include_dirs=[CUDD_DIR + '/cudd',
CUDD_DIR,
CUDD_DIR + '/st',
CUDD_DIR + '/mtr',
CUDD_DIR + '/epd'],
library_dirs=[CUDD_DIR + '/cudd/.libs'],
extra_compile_args=['-fPIC'] + C_FLAGS,
extra_link_args=['-fPIC', '-Wl,-Bstatic', '-lcudd', '-Wl,-Bdynamic'],)
# If CUDD is not already downloaded, download and unzip CUDD.
if not os.path.exists("cudd-3.0.0.tar.gz"):
urlretrieve(CUDD_URL, "cudd-3.0.0.tar.gz")
if not os.path.isdir(CUDD_DIR):
with tarfile.open("cudd-3.0.0.tar.gz", "r:gz") as tar:
tar.extractall()
if not os.path.exists(CUDD_DIR + "/cudd/.libs/libcudd.so"):
# Build CUDD
subprocess.call(["./configure", "--enable-shared",
"CFLAGS=-fPIC -O3 -g3 -ggdb"], cwd=CUDD_DIR)
subprocess.call(["make", "-j4"], cwd=CUDD_DIR)
setup(
name='ofequivalence',
version='1.0.0',
description=('A python library which can check the equivalence of '
'OpenFlow 1.3 rulesets.'),
long_description=README,
author='Richard Sanger',
author_email='[email protected]',
url='https://github.com/wandsdn/ofequivalence',
license=LICENSE,
packages=['ofequivalence'],
install_requires=[
"ryu",
"lru-dict",
"tqdm",
"gmpy2",
"six",
"networkx"
],
ext_modules=[_cbdd, _cudd, _utils],
entry_points={
"console_scripts": [
"check_equivalence = ofequivalence.check_equivalence:main",
"compress_ruleset = ofequivalence.compress_ruleset:main",
"graph_ruleset_deps = ofequivalence.graph_ruleset_deps:main",
"convert_ruleset = ofequivalence.convert_ruleset:main"
]
}
)