From 95b75409be44abbfe109ad86e5d38894080b2138 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 6 Sep 2012 19:56:51 +0000 Subject: [PATCH] Include data files with the new Python module --- interfaces/cython/.gitignore | 2 ++ interfaces/cython/cantera/__init__.py | 3 +++ interfaces/cython/cantera/_cantera.pxd | 3 +++ interfaces/cython/cantera/data/__init__.py | 0 interfaces/cython/cantera/utils.pyx | 3 +++ interfaces/cython/setup.py.in | 7 ++++--- src/python/SConscript | 4 ++++ 7 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 interfaces/cython/cantera/data/__init__.py diff --git a/interfaces/cython/.gitignore b/interfaces/cython/.gitignore index 539bab2a9..ad84b9e98 100644 --- a/interfaces/cython/.gitignore +++ b/interfaces/cython/.gitignore @@ -1,3 +1,5 @@ cantera/*.cpp cantera/*.c +cantera/data/*.cti +cantera/data/*.xml setup.py diff --git a/interfaces/cython/cantera/__init__.py b/interfaces/cython/cantera/__init__.py index 4c7ecf935..7b53cde38 100644 --- a/interfaces/cython/cantera/__init__.py +++ b/interfaces/cython/cantera/__init__.py @@ -1 +1,4 @@ from ._cantera import * + +import os as _os +addDirectory(_os.path.join(_os.path.dirname(__file__), 'data')) diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index b7774954a..bbbd13a56 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -11,6 +11,9 @@ cdef extern from "cantera/base/xml.h" namespace "Cantera": cdef extern from "cantera/base/ctml.h" namespace "ctml": XML_Node getCtmlTree(string) except + +cdef extern from "cantera/base/global.h" namespace "Cantera": + cdef void CxxAddDirectory "Cantera::addDirectory" (string) + cdef extern from "cantera/thermo/mix_defs.h": cdef int thermo_type_ideal_gas "Cantera::cIdealGas" cdef int thermo_type_surf "Cantera::cSurf" diff --git a/interfaces/cython/cantera/data/__init__.py b/interfaces/cython/cantera/data/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/interfaces/cython/cantera/utils.pyx b/interfaces/cython/cantera/utils.pyx index 167361c27..e4206d21a 100644 --- a/interfaces/cython/cantera/utils.pyx +++ b/interfaces/cython/cantera/utils.pyx @@ -3,3 +3,6 @@ cdef string stringify(x): # This method works with both Python 2.x and 3.x. tmp = bytes(x.encode()) return string(tmp) + +def addDirectory(directory): + CxxAddDirectory(stringify(directory)) diff --git a/interfaces/cython/setup.py.in b/interfaces/cython/setup.py.in index 331f2c37c..12fdb7758 100644 --- a/interfaces/cython/setup.py.in +++ b/interfaces/cython/setup.py.in @@ -1,5 +1,5 @@ import os -from distutils.core import setup, Extension +from setuptools import setup, find_packages, Extension from distutils.sysconfig import get_config_var from Cython.Distutils import build_ext @@ -26,7 +26,8 @@ setup(name="Cantera", author="Raymond Speth", author_email="speth@mit.edu", url="http://code.google.com/p/cantera", - packages = ["cantera", "cantera.test"], + packages = find_packages(), cmdclass = {'build_ext': build_ext}, ext_modules = exts, - package_data = {'cantera': dataFiles}) + package_data = {'cantera': dataFiles, + 'cantera.data': ['*.xml', '*.cti']}) diff --git a/src/python/SConscript b/src/python/SConscript index 749952c14..5f806fdb8 100644 --- a/src/python/SConscript +++ b/src/python/SConscript @@ -127,6 +127,10 @@ else: localenv['py_extra_link_args'] = repr(['-Wl,-rpath=$$ORIGIN']) localenv['py_extra_compiler_args'] = repr([]) +dataFiles = localenv.RecursiveInstall('#interfaces/cython/cantera/data', + '#data/inputs', ['\\.inp$', '\\.in$']) +build(dataFiles) + make_setup = localenv.SubstFile('#interfaces/cython/setup.py', '#interfaces/cython/setup.py.in') build(make_setup)