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 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#
# Copyright (C) 2005-2020 CS GROUP - France. All Rights Reserved.
# Author: Yoann Vandoorselaere <yoann.v@prelude-ids.com>
#
# This file is part of the Prelude library.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import sys, os
from os.path import abspath, exists
import shutil
from distutils.sysconfig import get_python_lib
from distutils.core import setup, Extension
FILES_TO_BE_COPIED = ("_prelude.cxx", "prelude.py")
def split_args(s):
import re
return re.split("\s+", s.strip())
def get_prefix():
try:
return sys.argv[sys.argv.index("--prefix") + 1]
except ValueError:
return None
def get_root():
try:
return sys.argv[sys.argv.index("--root") + 1]
except ValueError:
return ""
def is_system_wide_install():
return os.access(get_python_lib(), os.W_OK)
def builddir_is_srcdir():
return abspath("@top_srcdir@") == abspath("@top_builddir@")
def pre_install():
if not is_system_wide_install():
sys.argv.extend(["--prefix", "@prefix@"])
def pre_build():
if not builddir_is_srcdir():
for file in FILES_TO_BE_COPIED:
src = "@top_srcdir@/bindings/python/" + file
dst = "@top_builddir@/bindings/python/" + file
if not exists(dst):
shutil.copy(src, dst)
def pre_clean():
if not builddir_is_srcdir():
for file in FILES_TO_BE_COPIED:
exists(file) and os.remove(file)
def uninstall():
if is_system_wide_install():
prefix = get_prefix()
else:
prefix = "@prefix@"
for f in "prelude.py", "prelude.pyc", "_prelude.so":
file = get_root() + "/" + get_python_lib(prefix=prefix) + "/" + f
exists(file) and os.remove(file)
file = get_root() + "/" + get_python_lib(plat_specific=True, prefix=prefix) + "/" + f
exists(file) and os.remove(file)
sys.exit(0)
commands = {
"install": pre_install,
"build": pre_build,
"clean": pre_clean,
"uninstall": uninstall,
}
if len(sys.argv) > 1 and sys.argv[1] in commands:
commands[sys.argv[1]]()
setup(name="prelude",
version="@VERSION@",
description="Python bindings for the Prelude Library",
author="CS GROUP - France",
url="https://www.prelude-siem.org",
license="LGPL V2.1",
package_dir={'prelude': '@top_srcdir@/bindings/python'},
py_modules=["prelude"],
ext_modules=[Extension("_prelude",
["_prelude.cxx"],
extra_compile_args=split_args("-I@top_builddir@ -I@top_srcdir@/src/include -I@top_builddir@/src/include -I@top_builddir@/src/libprelude-error -I@top_srcdir@/bindings/c++/include"),
library_dirs=[ "@top_builddir@/src/.libs/", "@top_builddir@/bindings/c++/.libs/" ],
extra_link_args=split_args("-lpreludecpp -lprelude @LIBPRELUDE_LIBS@ @LIBADD_DL@ @LTLIBTHREAD@"))])
|