From a2d9ab4087b6485f1495ddc935337228675dbb13 Mon Sep 17 00:00:00 2001 From: Christophe Alexandre Date: Wed, 23 Apr 2008 14:37:45 +0000 Subject: [PATCH] bug in Library creation, still a problem in Python object management --- hurricane/src/pyext/CMakeLists.txt | 1 + hurricane/src/pyext/PyExtensionBuild.conf.in | 5 -- hurricane/src/pyext/PyLibrary.cpp | 10 +-- hurricane/src/pyext/setup.py | 69 -------------------- 4 files changed, 6 insertions(+), 79 deletions(-) delete mode 100644 hurricane/src/pyext/PyExtensionBuild.conf.in delete mode 100755 hurricane/src/pyext/setup.py diff --git a/hurricane/src/pyext/CMakeLists.txt b/hurricane/src/pyext/CMakeLists.txt index 35f08161..23663b60 100644 --- a/hurricane/src/pyext/CMakeLists.txt +++ b/hurricane/src/pyext/CMakeLists.txt @@ -35,3 +35,4 @@ SET_TARGET_PROPERTIES(Hurricane TARGET_LINK_LIBRARIES(Hurricane isobar hurricane ${PYTHON_LIBRARIES}) INSTALL(TARGETS isobar DESTINATION /lib) +INSTALL(TARGETS Hurricane DESTINATION /lib/python) diff --git a/hurricane/src/pyext/PyExtensionBuild.conf.in b/hurricane/src/pyext/PyExtensionBuild.conf.in deleted file mode 100644 index f9917fe3..00000000 --- a/hurricane/src/pyext/PyExtensionBuild.conf.in +++ /dev/null @@ -1,5 +0,0 @@ -src_dir=${HURRICANE_SOURCE_DIR}/src/pyext -build_dir=${HURRICANE_BINARY_DIR}/src/pyext -sources=@sources@ -include_dirs=@include_dirs@ -library_dirs=@library_dirs@ diff --git a/hurricane/src/pyext/PyLibrary.cpp b/hurricane/src/pyext/PyLibrary.cpp index 75e31123..d7a2bd2d 100644 --- a/hurricane/src/pyext/PyLibrary.cpp +++ b/hurricane/src/pyext/PyLibrary.cpp @@ -66,14 +66,14 @@ using namespace Hurricane; extern "C" { -# define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Library,lib,function) +#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Library,lib,function) // x=================================================================x // | "PyLibrary" Python Module Code Part | // x=================================================================x -# if defined(__PYTHON_MODULE__) +#if defined(__PYTHON_MODULE__) // x-------------------------------------------------------------x @@ -180,7 +180,7 @@ extern "C" { DataBase* db = PYDATABASE_O(arg0); library = Library::create(db, *PYNAME_O(arg1)); HCATCH - } else if (ParseTwoArg("Library.new", args, ":db:name", &arg0, &arg1)) { + } else if (ParseTwoArg("Library.new", args, ":library:name", &arg0, &arg1)) { HTRY Library* masterLibrary = PYLIBRARY_O(arg0); library = Library::create(masterLibrary, *PYNAME_O(arg1)); @@ -197,7 +197,7 @@ extern "C" { PyTypeObjectConstructor(Library) -# else // End of Python Module Code Part. +#else // End of Python Module Code Part. // x=================================================================x @@ -217,7 +217,7 @@ extern "C" { PyTypeRootObjectDefinitions(Library) -# endif // End of Shared Library Code Part. +#endif // End of Shared Library Code Part. } // End of extern "C". diff --git a/hurricane/src/pyext/setup.py b/hurricane/src/pyext/setup.py deleted file mode 100755 index b435747e..00000000 --- a/hurricane/src/pyext/setup.py +++ /dev/null @@ -1,69 +0,0 @@ -import sys - -class BuildConfigurationFileReader: - def __init__(self): - src_dir="" - self.sources = "" - self.include_dirs = "" - self.library_dirs = "" - def load(self): - f = open("PyExtensionBuild.conf") - try: - for line in f: - if (line == "\n"): - continue - args = line.split("=", 1) - if (len(args) > 0): - if (len(args) != 2): - print "Error in configuration file" - print args - sys.exit(55) - if (args[0]=="src_dir"): - self.src_dir = args[1].strip("\n") - if (args[0]=="sources"): - self.sources = args[1].strip("\n").split(";") - self.sources = map(lambda s : self.src_dir + "/" + s, self.sources) - elif (args[0]=="include_dirs"): - self.include_dirs=[args[1].strip("\n")] - print self.include_dirs - elif (args[0]=="library_dirs"): - self.library_dirs=args[1].strip("\n").split(":") - finally: - f.close() - if (len(self.sources)==0 or len(self.include_dirs)==0 or len(self.library_dirs)==0): - print "Error in configuration file" - print self.sources - print self.include_dirs - print self.library_dirs - sys.exit(55) - -class PyBuilder: - def __init__(self, sources, library_dirs, include_dirs): - self.sources = sources - self.libraryDirs = library_dirs - self.libraries = ['isobar', 'hurricane'] - self.includeDirs = include_dirs - def build(self, build=False): - from distutils.core import setup, Extension - hurricane = Extension('Hurricane', - include_dirs=self.includeDirs, - libraries=self.libraries, - library_dirs=self.libraryDirs, - sources=self.sources, - define_macros=[('__PYTHON_MODULE__', '1')]) - - build = ('build' in sys.argv) - - if (build): - setup(name='Hurricane', - version='2.0', - description = "Python Module for Hurricane", - author='Coriolis Team', - ext_modules=[hurricane]) - -if (__name__=='__main__'): - r = BuildConfigurationFileReader() - r.load() - b = PyBuilder(r.sources, r.library_dirs, r.include_dirs) - build = ('build' in sys.argv) - b.build(build)