#!/usr/bin/env python import distutils.core as dic import distutils.dir_util as dut import distutils.file_util as fut import os import sys cam_version = '0.5.4' # Notes: # on Fedora Core 5 module is compiled with 'gcc -g' - why -g? # later: replace os.popen() with subprocess module, new in Python 2.4 def pkg_config (opt, pkg): fo = os.popen ('pkg-config %s %s' % (opt, pkg)) return fo.read(), fo.close() def pkg_config_version_check (pkg, version): output, status = pkg_config ('--atleast-version=%s' % version, pkg) if status is None: print '%s version >= %s detected' % (pkg, version) else: raise SystemExit ('Error: %s version >= %s not found' % (pkg, version)) def pkg_config_parse (opt, pkg): output, status = pkg_config (opt, pkg) opt = opt[-2:] return [x.lstrip(opt) for x in output.split()] if sys.platform == 'win32': runtime_library_dirs = [] else: runtime_library_dirs = [] # pkg_config_parse('--libs-only-L', 'cam') pkgconfig_file='cam.pc' print 'creating %s' % pkgconfig_file fo = open (pkgconfig_file, 'w') fo.write ("""\ prefix=%s Name: cam Description: Python bindings for cellular automata machine engine. Version: %s Requires: pycairo Cflags: Libs: """ % (sys.prefix, cam_version) ) fo.close() cam = dic.Extension( name = 'cam._cam', sources = ['cam/cammodule.c', ], include_dirs = pkg_config_parse('--cflags-only-I', 'cam'), library_dirs = pkg_config_parse('--libs-only-L', 'cam'), libraries = pkg_config_parse('--libs-only-l', 'cam'), runtime_library_dirs = runtime_library_dirs, ) dic.setup( name = "cam", version = cam_version, description = "Python interface for cellular automata machine engine", packages = ['cam'], ext_modules = [cam], data_files=[('include/cam',['cam/cam.h']), ('lib/pkgconfig',[pkgconfig_file])] )