#!/usr/bin/python from distutils.core import setup from distutils.extension import Extension import Pyrex.Distutils, time, re, sys, os from version import * LONG_DESC = '''\ This is ClamAV native support for python via libclamav for SAGATOR, but may be used for any python script. Script "example.py" is a part of this package. ''' # update spec file if re.compile('^[0-9]+$').search(RELEASE): UNSTABLE_RELEASE='' else: UNSTABLE_RELEASE='-'+RELEASE open(PROJECT+'.spec','w').write( open(PROJECT+'.spec.in','r').read( ).replace( '%VERSION%', VERSION ).replace( '%RELEASE%', RELEASE ).replace( '%UNSTABLE_RELEASE%', UNSTABLE_RELEASE ) ) # update debian changelog file open('debian/changelog','w').write('''\ %s (%s-%s) unstable; urgency=low * This file is automatically generated by sagator's configure script. -- Jan ONDREJ (SAGATOR) %s ''' % (PROJECT,VERSION,RELEASE,time.strftime('%a, %d %b %Y %H:%M:%S %z')) ) # update gentoo ebuild rel_path='%s-%s-%s.tar.bz2' % (PROJECT, VERSION, RELEASE) if ('beta' in RELEASE) or ('rc' in RELEASE): rel_path='unstable/' + rel_path eb_name='%s-%s.ebuild' % (PROJECT, VERSION) #re.compile('^[0-9]*').sub('_', RELEASE)) else: eb_name='%s-%s.ebuild' % (PROJECT, VERSION) open(eb_name, 'w').write( open(PROJECT+'.ebuild.in').read() % rel_path ) # check clamav.h version for prefix in ('/usr/local', '/usr', ''): clamav_h = os.path.join(prefix, 'include/clamav.h') if os.path.isfile(clamav_h): break clamav_h = None if not clamav_h: print "Clamav header file (clamav.h) not found!" sys.exit(1) elif 'CL_SUCCESS' not in open(clamav_h).read(): print "Please update to clamav 0.90 or higher!" sys.exit(2) setup( name=PROJECT, version=VERSION, description="ClamAV module for python, created for SAGATOR project", long_description=LONG_DESC, author="Jan ONDREJ (SAL)", author_email="ondrejj(at)salstar.sk", url="http://www.salstar.sk/sagator/", license="LGPLv2+", ext_modules=[ Extension( "libclamav", ["libclamav.pyx"], include_dirs=[os.path.join(prefix, 'include')], library_dirs=[os.path.join(prefix, 'lib')], libraries=['clamav'] ) ], cmdclass = {'build_ext': Pyrex.Distutils.build_ext} )