Commit c28922e0 by plusvic

Fix a few issues with setup.py

parent 7360bf2e
...@@ -55,6 +55,7 @@ def muted(*streams): ...@@ -55,6 +55,7 @@ def muted(*streams):
def has_function(function_name, libraries=None): def has_function(function_name, libraries=None):
"""Checks if a given functions exists in the current platform."""
compiler = distutils.ccompiler.new_compiler() compiler = distutils.ccompiler.new_compiler()
with muted(sys.stdout, sys.stderr): with muted(sys.stdout, sys.stderr):
result = compiler.has_function( result = compiler.has_function(
...@@ -92,12 +93,16 @@ class BuildCommand(build): ...@@ -92,12 +93,16 @@ class BuildCommand(build):
'--enable-cuckoo must be used with --static') '--enable-cuckoo must be used with --static')
def run(self): def run(self):
sources = ['./yara-python.c'] """Execute the build command."""
os.chdir(os.path.dirname(__file__))
sources = ['yara-python.c']
exclusions = ['yara/libyara/modules/pe_utils.c'] exclusions = ['yara/libyara/modules/pe_utils.c']
libraries = ['yara'] libraries = ['yara']
include_dirs = [] include_dirs = []
library_dirs = [] library_dirs = []
compile_args = [] compile_args = ['-O3']
macros = [] macros = []
if self.plat_name in ('win32','win-amd64'): if self.plat_name in ('win32','win-amd64'):
...@@ -108,7 +113,14 @@ class BuildCommand(build): ...@@ -108,7 +113,14 @@ class BuildCommand(build):
libraries.append('user32') libraries.append('user32')
else: else:
building_for_windows = False 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')
else:
building_for_osx = False
if has_function('memmem'): if has_function('memmem'):
macros.append(('HAVE_MEMMEM', '1')) macros.append(('HAVE_MEMMEM', '1'))
if has_function('strlcpy'): if has_function('strlcpy'):
...@@ -130,7 +142,7 @@ class BuildCommand(build): ...@@ -130,7 +142,7 @@ class BuildCommand(build):
if building_for_windows: if building_for_windows:
macros.append(('HASH', '1')) macros.append(('HASH', '1'))
libraries.append('libeay%s' % bits) libraries.append('libeay%s' % bits)
elif (has_function('MD5_Init', libraries=['crypto']) and elif (has_function('MD5_Init', libraries=['crypto']) and
has_function('SHA256_Init', libraries=['crypto'])): has_function('SHA256_Init', libraries=['crypto'])):
macros.append(('HASH', '1')) macros.append(('HASH', '1'))
libraries.append('crypto') libraries.append('crypto')
...@@ -173,7 +185,7 @@ class BuildCommand(build): ...@@ -173,7 +185,7 @@ class BuildCommand(build):
setup( setup(
name='yara-python', name='yara-python',
version='3.4.1', version='3.4.2',
author='Victor M. Alvarez', author='Victor M. Alvarez',
author_email='plusvic@gmail.com;vmalvarez@virustotal.com', author_email='plusvic@gmail.com;vmalvarez@virustotal.com',
url='https://github.com/plusvic/yara-python', url='https://github.com/plusvic/yara-python',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment