#!/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()
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',
'-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 'SWFTOOLS_SYSTEM_PREFIX' in os.environ:
+ # Allow overriding the prefix location. This is useful if your
+ # python is compiled in a custom location.
+ PREFIX = os.environ.get('SWFTOOLS_SYSTEM_PREFIX').strip()
+ if not os.path.exists(PREFIX):
+ print 'The SWFTOOLS_SYSTEM_PREFIX location does not exist'
+ sys.exit(1)
+ print 'Using %s as prefix for header files' % PREFIX
+else:
+ # Default to the prefix used for the python interpreter
+ PREFIX = sys.prefix
+
+update_list(cc.include_dirs, [os.path.join(PREFIX, 'include'),
+ os.path.join(PREFIX, 'include/freetype2'),
+ os.path.join(PREFIX, 'include/fontconfig')])
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.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 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"):
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
)
setup(name='SWFTools',
- version='2008-03-26-1351',
+ version='0.9dev',
description='Python wrapper for SWFTools',
author='Matthias Kramm',
author_email='kramm@quiss.org',