-
Notifications
You must be signed in to change notification settings - Fork 15
/
setup.py
105 lines (90 loc) · 3.28 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
from setuptools import setup
import re
import platform
import os
import sys
if 'test' in sys.argv:
# Setup test unloads modules after the tests have completed. This causes an
# error in atexit's exit calls because the registered modules no longer
# exist. This hack resolves this issue by disabling the register func
import atexit
atexit.register = lambda be_gone_nasty_traceback: True
def load_version(filename='yara/version.py'):
"""Parse a __version__ number from a source file"""
with open(filename) as source:
text = source.read()
match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", text)
if not match:
msg = "Unable to find version number in {}".format(filename)
raise RuntimeError(msg)
version = match.group(1)
return version
#build the yara package data (shipped yar files)
yara_package_data = []
for path, _, files in os.walk(os.path.join('yara', 'rules')):
rootpath = path[len('yara') + 1:]
for f in files:
if f.endswith('.yar'):
yara_package_data.append(os.path.join(rootpath, f))
#see if we have a pre-built libyara for this platform
arch, exetype = platform.architecture()
system = platform.system().lower()
machine = platform.machine().lower()
if machine in ['i686', 'x86']:
machine = 'x86_32'
if machine in ['amd64']:
machine = 'x86_64'
if system == 'windows':
ext = '.dll'
else:
ext = '.so'
libyara_path = os.path.join('.', 'libs', system, machine, "libyara" + ext)
data_files = []
if os.path.exists(libyara_path):
if system == 'windows':
install_libdir = os.path.join(sys.prefix, 'DLLs')
else:
install_libdir = os.path.join(sys.prefix, 'lib')
data_files.append((install_libdir, [libyara_path]))
setup(
name="yara",
version=load_version(),
packages=['yara'],
package_data=dict(yara=yara_package_data),
data_files=data_files,
zip_safe=False,
author="Michael Dorman",
author_email="[email protected]",
url="http://code.google.com/p/yara-project/",
description="Compile YARA rules to test against files or strings",
long_description=open('README.rst').read(),
license="Apache Software Licence",
install_requires = [],
entry_points={
'console_scripts': [
'yara-ctypes = yara.cli:entry'
]
},
platforms=['cygwin', 'win', 'linux'],
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Other Audience',
'License :: OSI Approved :: Apache Software License',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Security',
'Topic :: System :: Monitoring'
],
test_suite="tests"
)
if not data_files:
print("\nWARNING: Could not find %s" % libyara_path)
print("You need to 'make install' libyara for this system/machine")
print("See http://pythonhosted.org/yara/ for help")