1#!/usr/bin/env python 2 3""" 4PETSc for Python 5================ 6 7Python bindings for PETSc libraries. 8""" 9 10 11## try: 12## import setuptools 13## except ImportError: 14## pass 15 16 17# -------------------------------------------------------------------- 18# Metadata 19# -------------------------------------------------------------------- 20 21from conf import metadata 22 23name = 'petsc4py' 24version = open('VERSION.txt').read().strip() 25descr = __doc__.strip().split('\n'); del descr[1:3] 26devstat = ['Development Status :: 3 - Alpha'] 27url = 'http://%s.googlecode.com/' % name 28download = 'http://%s.googlecode.com/files/%s-%s.tar.gz' 29download = download % (name, name, version) 30 31metadata['name'] = name 32metadata['version'] = version 33metadata['description'] = descr.pop(0) 34metadata['long_description'] = '\n'.join(descr) 35metadata['classifiers'] += devstat 36metadata['url'] = url 37metadata['download_url'] = download 38 39# -------------------------------------------------------------------- 40# Extension modules 41# -------------------------------------------------------------------- 42 43def get_ext_modules(Extension): 44 from os import walk, path 45 from glob import glob 46 depends = [] 47 for pth, dirs, files in walk('src'): 48 depends += glob(path.join(pth, '*.h')) 49 for pth, dirs, files in walk(path.join('src', 'source')): 50 depends += glob(path.join(pth, '*.h')) 51 depends += glob(path.join(pth, '*.c')) 52 return [Extension('petsc4py.lib.PETSc', 53 sources=['src/PETSc.c', 54 'src/source/libpetsc4py.c',], 55 include_dirs=['src/include', 56 'src/source',], 57 depends=depends, language='c'), 58 Extension('petsc4py.lib.PETSc', 59 sources=['src/PETSc.cpp', 60 'src/source/libpetsc4py.cpp',], 61 include_dirs=['src/include', 62 'src/source',], 63 depends=depends, language='c++'), 64 ] 65# -------------------------------------------------------------------- 66# Setup 67# -------------------------------------------------------------------- 68 69from conf.core import setup, Extension 70from conf.core import config, build, build_py, build_ext 71 72def main(): 73 setup(packages = ['petsc4py', 74 'petsc4py.lib',], 75 package_dir = {'petsc4py' : 'src', 76 'petsc4py.lib' : 'src/lib'}, 77 package_data = {'petsc4py' : ['include/petsc4py/*.h', 78 'include/petsc4py/*.i', 79 'include/petsc4py/*.pxd', 80 'include/petsc4py/*.pxi', 81 'include/petsc4py/*.pyx',], 82 'petsc4py.lib' : ['petsc.cfg'],}, 83 ext_modules = get_ext_modules(Extension), 84 cmdclass = {'config' : config, 85 'build' : build, 86 'build_py' : build_py, 87 'build_ext' : build_ext}, 88 **metadata) 89 90if __name__ == '__main__': 91 import sys, os 92 C_SOURCE = os.path.join('src', 'petsc4py_PETSc.c') 93 def cython_help(): 94 if os.path.exists(C_SOURCE): return 95 warn = lambda msg='': sys.stderr.write(msg+'\n') 96 warn("*"*70) 97 warn() 98 warn("You need to generate C source files with Cython !!!") 99 warn("Please execute in your shell:") 100 warn() 101 warn("$ python ./conf/cythonize.py") 102 warn() 103 warn("*"*70) 104 warn() 105 ## from distutils import log 106 ## log.set_verbosity(log.DEBUG) 107 cython_help() 108 main() 109 110# -------------------------------------------------------------------- 111