Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yara-python
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
yara-python
Commits
b3e80a1b
Commit
b3e80a1b
authored
Jul 02, 2016
by
Victor M. Alvarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve setup.py script
parent
6a4b7ed8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
41 deletions
+30
-41
setup.py
setup.py
+30
-41
No files found.
setup.py
View file @
b3e80a1b
...
...
@@ -75,7 +75,7 @@ class BuildCommand(build):
(
'enable-profiling'
,
None
,
'enable profiling features'
)]
boolean_options
=
build
.
boolean_options
+
[
'dynamic'
,
'enable-cuckoo'
,
'enable-magic'
,
'enable-profiling'
]
'dynamic
-linking
'
,
'enable-cuckoo'
,
'enable-magic'
,
'enable-profiling'
]
def
initialize_options
(
self
):
build
.
initialize_options
(
self
)
...
...
@@ -96,74 +96,68 @@ class BuildCommand(build):
def
run
(
self
):
"""Execute the build command."""
module
=
self
.
distribution
.
ext_modules
[
0
]
base_dir
=
os
.
path
.
dirname
(
__file__
)
if
base_dir
:
os
.
chdir
(
base_dir
)
sources
=
[
'yara-python.c'
]
exclusions
=
[
'yara/libyara/modules/pe_utils.c'
]
libraries
=
[
'yara'
]
include_dirs
=
[]
library_dirs
=
[]
compile_args
=
[]
macros
=
[]
if
self
.
plat_name
in
(
'win32'
,
'win-amd64'
):
building_for_windows
=
True
bits
=
'64'
if
self
.
plat_name
==
'win-amd64'
else
'32'
macros
.
append
((
'_CRT_SECURE_NO_WARNINGS'
,
'1'
))
libraries
.
append
(
'advapi32'
)
libraries
.
append
(
'user32'
)
module
.
define_macros
.
append
((
'_CRT_SECURE_NO_WARNINGS'
,
'1'
))
module
.
include_dirs
.
append
(
'yara/windows/include'
)
module
.
libraries
.
append
(
'advapi32'
)
module
.
libraries
.
append
(
'user32'
)
else
:
building_for_windows
=
False
if
'macosx'
in
self
.
plat_name
:
building_for_osx
=
True
include_dirs
.
append
(
'/opt/local/include'
)
library_dirs
.
append
(
'/opt/local/lib'
)
module
.
include_dirs
.
append
(
'/opt/local/include'
)
module
.
library_dirs
.
append
(
'/opt/local/lib'
)
else
:
building_for_osx
=
False
if
has_function
(
'memmem'
):
macros
.
append
((
'HAVE_MEMMEM'
,
'1'
))
m
odule
.
define_m
acros
.
append
((
'HAVE_MEMMEM'
,
'1'
))
if
has_function
(
'strlcpy'
):
macros
.
append
((
'HAVE_STRLCPY'
,
'1'
))
m
odule
.
define_m
acros
.
append
((
'HAVE_STRLCPY'
,
'1'
))
if
has_function
(
'strlcat'
):
macros
.
append
((
'HAVE_STRLCAT'
,
'1'
))
m
odule
.
define_m
acros
.
append
((
'HAVE_STRLCAT'
,
'1'
))
if
self
.
enable_profiling
:
macros
.
append
((
'PROFILING_ENABLED'
,
'1'
))
if
not
self
.
dynamic_linking
:
libraries
.
remove
(
'yara'
)
include_dirs
.
extend
([
'yara/libyara/include'
,
'yara/libyara/'
,
'.'
])
module
.
define_macros
.
append
((
'PROFILING_ENABLED'
,
'1'
))
if
self
.
dynamic_linking
:
module
.
libraries
.
append
(
'yara'
)
else
:
if
building_for_windows
:
include_dirs
.
append
(
'yara/windows/include'
)
library_dirs
.
append
(
'yara/windows/lib'
)
module
.
library_dirs
.
append
(
'yara/windows/lib'
)
if
building_for_windows
:
macros
.
append
((
'HASH_MODULE'
,
'1'
))
libraries
.
append
(
'libeay
%
s'
%
bits
)
m
odule
.
define_m
acros
.
append
((
'HASH_MODULE'
,
'1'
))
module
.
libraries
.
append
(
'libeay
%
s'
%
bits
)
elif
(
has_function
(
'MD5_Init'
,
libraries
=
[
'crypto'
])
and
has_function
(
'SHA256_Init'
,
libraries
=
[
'crypto'
])):
macros
.
append
((
'HASH_MODULE'
,
'1'
))
libraries
.
append
(
'crypto'
)
m
odule
.
define_m
acros
.
append
((
'HASH_MODULE'
,
'1'
))
module
.
libraries
.
append
(
'crypto'
)
else
:
exclusions
.
append
(
'yara/libyara/modules/hash.c'
)
if
self
.
enable_magic
:
macros
.
append
((
'MAGIC_MODULE'
,
'1'
))
m
odule
.
define_m
acros
.
append
((
'MAGIC_MODULE'
,
'1'
))
else
:
exclusions
.
append
(
'yara/libyara/modules/magic.c'
)
if
self
.
enable_cuckoo
:
macros
.
append
((
'CUCKOO_MODULE'
,
'1'
))
m
odule
.
define_m
acros
.
append
((
'CUCKOO_MODULE'
,
'1'
))
if
building_for_windows
:
libraries
.
append
(
'jansson
%
s'
%
bits
)
module
.
libraries
.
append
(
'jansson
%
s'
%
bits
)
else
:
libraries
.
append
(
'jansson'
)
module
.
libraries
.
append
(
'jansson'
)
else
:
exclusions
.
append
(
'yara/libyara/modules/cuckoo.c'
)
...
...
@@ -173,16 +167,7 @@ class BuildCommand(build):
for
x
in
files
:
x
=
os
.
path
.
normpath
(
os
.
path
.
join
(
directory
,
x
))
if
x
.
endswith
(
'.c'
)
and
x
not
in
exclusions
:
sources
.
append
(
x
)
self
.
distribution
.
ext_modules
=
[
Extension
(
name
=
'yara'
,
sources
=
sources
,
include_dirs
=
include_dirs
,
library_dirs
=
library_dirs
,
libraries
=
libraries
,
define_macros
=
macros
,
extra_compile_args
=
compile_args
)]
module
.
sources
.
append
(
x
)
build
.
run
(
self
)
...
...
@@ -200,4 +185,8 @@ setup(
author_email
=
'plusvic@gmail.com;vmalvarez@virustotal.com'
,
url
=
'https://github.com/VirusTotal/yara-python'
,
zip_safe
=
False
,
cmdclass
=
{
'build'
:
BuildCommand
})
cmdclass
=
{
'build'
:
BuildCommand
},
ext_modules
=
[
Extension
(
name
=
'yara'
,
include_dirs
=
[
'yara/libyara/include'
,
'yara/libyara/'
,
'.'
],
sources
=
[
'yara-python.c'
])])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment