X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=setup.py;h=a9de6a2076c571fc8f0a8983c7d9148882188c8b;hb=941796b434a093d72b8b87035eb25ecd5f3bd0c6;hp=7be9a26a9054d3a26e8fbba484b35b20f1c49c35;hpb=6ced072c3d49530b72af0ab8d39c7643395f4846;p=swftools.git diff --git a/setup.py b/setup.py index 7be9a26..a9de6a2 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,12 @@ #!/usr/bin/env python + +from distutils import ccompiler +from distutils.core import CompileError + try: - from distutils.core import setup,Extension,CompileError - from distutils import ccompiler -except: - from setuptools import setup, Extension, ccompiler, CompileError + from setuptools import setup, Extension +except ImportError: + from distutils.core import setup, Extension cc = ccompiler.new_compiler() @@ -13,10 +16,15 @@ import stat DATADIR = "/usr/share/swftools/" +def update_dirs(list1, list2): + for v in list2: + if v not in list1 and os.path.isdir(v): + list1.append(v) + def update_list(list1, list2): for v in list2: if v not in list1: - list1 += [v] + list1.append(v) COMPILER_OPTIONS = ['-fPIC', '-Wparentheses', '-Wimplicit', '-Wreturn-type', '-O3', '-fomit-frame-pointer', '-Winline', @@ -24,14 +32,23 @@ COMPILER_OPTIONS = ['-fPIC', '-Wparentheses', '-Wimplicit', '-Wreturn-type', '-DSWFTOOLS_DATADIR="'+DATADIR+'"'] INCLUDE=['lib/lame/', 'lib/pdf/xpdf', 'lib/pdf'] -update_list(cc.include_dirs, [os.path.join(sys.prefix,"include"), - os.path.join(sys.prefix,'include/freetype2'), - os.path.join(sys.prefix,'include/fontconfig')]) +if 'library_dirs' in os.environ: + update_dirs(cc.library_dirs, [path.strip() for path in os.environ.get('library_dirs').strip().split(":")]) +else: + update_dirs(cc.library_dirs, [os.path.join(sys.prefix, 'lib'), + os.path.join(sys.prefix, 'local/lib')]) + if sys.platform == "darwin": + update_list(cc.library_dirs, ["/sw/lib", "/opt/local/lib"]) + +if 'include_dirs' in os.environ: + update_dirs(cc.include_dirs, [path.strip() for path in os.environ.get('include_dirs').strip().split(":")]) +else: + update_dirs(cc.include_dirs, [os.path.join(sys.prefix, 'include'), + os.path.join(sys.prefix, 'include/freetype2'), + os.path.join(sys.prefix, 'include/fontconfig')]) + if sys.platform == "darwin": + update_dirs(cc.include_dirs, ["/sw/include/freetype2", "/sw/lib/freetype2/include", "/sw/include", "/opt/local/include"]) -update_list(cc.library_dirs, ["/usr/lib", "/usr/local/lib"]) -if sys.platform == "darwin": - update_list(cc.include_dirs, ["/sw/include/freetype2", "/sw/lib/freetype2/include", "/sw/include", "/opt/local/include"]) - update_list(cc.library_dirs, ["/sw/lib", "/opt/local/lib"]) class ConfigScript: def __init__(self): @@ -104,6 +121,21 @@ class ConfigScript: def system_has_property(self,name): if name.startswith("STD"): return 1 + elif name.startswith("HAVE_") and name.endswith("_H"): + header = name[5:].lower() + c = header.rfind("_") + if c>=0: + header = header[0:c]+"."+header[c+1] + header = header.replace("_","/") + ok = 0 + for dir in cc.include_dirs: + if os.path.isfile(os.path.join(dir,header)): + ok = 1 + break + if ok and self.test_code("#include <"+header+">", ""): + if header.startswith("sys"): + self.includefiles += [header] + return 1 elif name.startswith("HAVE_LIB") \ or name.startswith("HAVE_FONTCONFIG") \ or name.startswith("HAVE_FREETYPE"): @@ -133,21 +165,6 @@ class ConfigScript: if self.test_code("", "static int test_array [%d+1-sizeof(%s)];\ntest_array [0] = 0;" % (i,t)): return i return None - elif name.startswith("HAVE_") and name.endswith("_H"): - header = name[5:].lower() - c = header.rfind("_") - if c>=0: - header = header[0:c]+"."+header[c+1] - header = header.replace("_","/") - ok = 0 - for dir in cc.include_dirs: - if os.path.isfile(os.path.join(dir,header)): - ok = 1 - break - if ok and self.test_code("#include <"+header+">", ""): - if header.startswith("sys"): - self.includefiles += [header] - return 1 elif name.startswith("USE_FREEETYPE"): # TODO: run a test here? return 1 @@ -211,7 +228,7 @@ if "freetype" not in config.libraries: sys.exit(1) base_sources = [ -"lib/q.c", "lib/utf8.c", "lib/png.c", "lib/wav.c", "lib/mp3.c", "lib/os.c", "lib/bitio.c", "lib/log.c", "lib/mem.c", +"lib/q.c", "lib/utf8.c", "lib/png.c", "lib/jpeg.c", "lib/wav.c", "lib/mp3.c", "lib/os.c", "lib/bitio.c", "lib/log.c", "lib/mem.c", ] rfxswf_sources = [ "lib/modules/swfabc.c", "lib/modules/swfaction.c", "lib/modules/swfbits.c", "lib/modules/swfbutton.c", @@ -257,9 +274,13 @@ libgfx_sources = [ "lib/art/art_svp_render_aa.c", "lib/art/art_svp_vpath.c", "lib/art/art_svp_vpath_stroke.c", "lib/art/art_svp_wind.c", "lib/art/art_uta.c", "lib/art/art_uta_ops.c", "lib/art/art_uta_rect.c", "lib/art/art_uta_svp.c", "lib/art/art_uta_vpath.c", "lib/art/art_vpath.c", "lib/art/art_vpath_bpath.c", -"lib/art/art_vpath_dash.c", "lib/art/art_vpath_svp.c", +"lib/art/art_vpath_dash.c", "lib/art/art_vpath_svp.c", "lib/gocr/box.c", +"lib/gocr/database.c", "lib/gocr/detect.c", "lib/gocr/job.c", "lib/gocr/lines.c", "lib/gocr/list.c", +"lib/gocr/ocr0.c", "lib/gocr/ocr0n.c", "lib/gocr/ocr1.c", "lib/gocr/otsu.c", "lib/gocr/output.c", +"lib/gocr/pgm2asc.c", "lib/gocr/pixel.c", "lib/gocr/progress.c", "lib/gocr/remove.c", "lib/gocr/unicode.c", +"lib/devices/ocr.c", ] -gfxswf_sources = ["lib/devices/swf.c"] +gfxswf_sources = ["lib/devices/swf.c", "lib/readers/swf.c", "lib/readers/image.c"] swf_module = Extension( name='SWF', @@ -284,7 +305,7 @@ gfx_module = Extension( ) setup(name='SWFTools', - version='2008-03-26-1351', + version='0.9dev', description='Python wrapper for SWFTools', author='Matthias Kramm', author_email='kramm@quiss.org',