diff --git a/build/SConscript.configure b/build/SConscript.configure index 06f934a8..c896f3df 100644 --- a/build/SConscript.configure +++ b/build/SConscript.configure @@ -40,6 +40,9 @@ vars.Add('SHLINKFLAGS', 'Linker flags (dynamic libraries)') vars.Add('BASEINCLUDE', 'Base include path') vars.Add('BASELIB', 'Base libraries') vars.Add('BASELIBDIR', 'Base library search path') +vars.Add('PYTHONINCLUDE', 'Python include path') +vars.Add('PYTHONLIB', 'Python libraries') +vars.Add('PYTHONLIBDIR', 'Python library path') vars.Add('XERCESINCLUDE', 'Xerces-C include path') vars.Add('XERCESLIB', 'Xerces-C libraries') vars.Add('XERCESLIBDIR', 'Xerces-C library path') @@ -81,6 +84,8 @@ except Exception: hasQt = False hasCollada=True +hasPython = True + env.Append(CPPPATH=env['BASEINCLUDE']) env.Append(CPPFLAGS=[]) env.Append(LIBPATH=[]) @@ -137,6 +142,8 @@ if env.has_key('COLLADAINCLUDE'): env.Prepend(CPPPATH=env['COLLADAINCLUDE']) if env.has_key('COLLADALIBDIR'): env.Prepend(LIBPATH=env['COLLADALIBDIR']) +if env.has_key('PYTHONINCLUDE'): + env.Prepend(CPPPATH=env['PYTHONINCLUDE']) if not conf.CheckCXX(): print 'Could not compile a simple C++ fragment, verify that ' + \ @@ -159,6 +166,9 @@ if not conf.CheckCXXHeader('xercesc/dom/DOMLSParser.hpp'): if not conf.CheckCXXHeader('dae.h'): hasCollada = False print 'COLLADA DOM is missing: not building the COLLADA importer' +if not conf.CheckCXXHeader('pyconfig.h'): + hasPython = False + print 'Python is missing: not building the python support library' if not conf.CheckCXXHeader('boost/math/distributions/students_t.hpp'): print 'Boost is missing (install libboost-dev)!' Exit(1) @@ -232,8 +242,6 @@ if hasCollada: env.SConsignFile() -hasPython = True - # MSVC: Embed the manifest into libraries and executables if sys.platform == 'win32': env['LINKCOM'] = [env['LINKCOM'], 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1'] diff --git a/build/config-darwin-universal.py b/build/config-darwin-universal.py index 8b4a1038..192958c6 100644 --- a/build/config-darwin-universal.py +++ b/build/config-darwin-universal.py @@ -25,6 +25,8 @@ GLFLAGS = ['-DGLEW_MX'] BOOSTINCLUDE = ['#dependencies'] BOOSTLIB = ['boost_filesystem', 'boost_system'] BOOSTLIBDIR = ['#dependencies/darwin/libboost.framework/Resources/lib'] +PYTHONINCLUDE = ['/System/Library/Frameworks/Python.framework/Versions/2.5/Headers'] +PYTHONLIBS = ['boost_python', 'boost_system', 'Python'] COLLADAINCLUDE = ['#dependencies/windows/include/colladadom', '#dependencies/windows/include/colladadom/1.4'] COLLADALIB = ['libCollada14Dom'] COLLADALIBDIR = ['#dependencies/darwin/Collada14Dom.framework/Resources/lib'] diff --git a/build/config-darwin-x86.py b/build/config-darwin-x86.py index f9eca9d6..dcbb4dde 100644 --- a/build/config-darwin-x86.py +++ b/build/config-darwin-x86.py @@ -25,6 +25,8 @@ GLFLAGS = ['-DGLEW_MX'] BOOSTINCLUDE = ['#dependencies'] BOOSTLIB = ['boost_filesystem', 'boost_system'] BOOSTLIBDIR = ['#dependencies/darwin/libboost.framework/Resources/lib'] +PYTHONINCLUDE = ['/System/Library/Frameworks/Python.framework/Versions/2.5/Headers'] +PYTHONLIBS = ['boost_python', 'boost_system', 'Python'] COLLADAINCLUDE = ['#dependencies/windows/include/colladadom', '#dependencies/windows/include/colladadom/1.4'] COLLADALIB = ['libCollada14Dom'] COLLADALIBDIR = ['#dependencies/darwin/Collada14Dom.framework/Resources/lib'] diff --git a/build/config-darwin-x86_64.py b/build/config-darwin-x86_64.py index 344e84ab..3c83896b 100644 --- a/build/config-darwin-x86_64.py +++ b/build/config-darwin-x86_64.py @@ -25,6 +25,8 @@ GLFLAGS = ['-DGLEW_MX'] BOOSTINCLUDE = ['#dependencies'] BOOSTLIB = ['boost_filesystem', 'boost_system'] BOOSTLIBDIR = ['#dependencies/darwin/libboost.framework/Resources/lib'] +PYTHONINCLUDE = ['/System/Library/Frameworks/Python.framework/Versions/2.5/Headers'] +PYTHONLIBS = ['boost_python', 'boost_system', 'Python'] COLLADAINCLUDE = ['#dependencies/windows/include/colladadom', '#dependencies/windows/include/colladadom/1.4'] COLLADALIB = ['libCollada14Dom'] COLLADALIBDIR = ['#dependencies/darwin/Collada14Dom.framework/Resources/lib'] diff --git a/build/config-linux-debug.py b/build/config-linux-debug.py index 393ce32b..48b328e6 100644 --- a/build/config-linux-debug.py +++ b/build/config-linux-debug.py @@ -15,6 +15,8 @@ XERCESINCLUDE = [] XERCESLIB = ['xerces-c'] GLLIB = ['GL', 'GLU', 'GLEWmx', 'Xxf86vm', 'X11'] GLFLAGS = ['-DGLEW_MX'] -BOOSTLIB = ['libboost_system', 'libboost_filesystem'] +BOOSTLIB = ['boost_system', 'boost_filesystem'] +PYTHONINCLUDE = ['/usr/include/python2.6'] +PYTHONLIB = ['python2.6', 'boost_python'] COLLADAINCLUDE = ['/usr/include/collada-dom', '/usr/include/collada-dom/1.4'] -COLLADALIB = ['libcollada14dom'] +COLLADALIB = ['collada14dom'] diff --git a/build/config-linux.py b/build/config-linux.py index 00baa7e8..65bebf04 100644 --- a/build/config-linux.py +++ b/build/config-linux.py @@ -15,6 +15,8 @@ XERCESINCLUDE = [] XERCESLIB = ['xerces-c'] GLLIB = ['GL', 'GLU', 'GLEWmx', 'Xxf86vm', 'X11'] GLFLAGS = ['-DGLEW_MX'] -BOOSTLIB = ['libboost_system', 'libboost_filesystem'] +BOOSTLIB = ['boost_system', 'boost_filesystem'] +PYTHONINCLUDE = ['/usr/include/python2.6'] +PYTHONLIB = ['python2.6', 'boost_python'] COLLADAINCLUDE = ['/usr/include/collada-dom', '/usr/include/collada-dom/1.4'] -COLLADALIB = ['libcollada14dom'] +COLLADALIB = ['collada14dom'] diff --git a/data/linux/debian/control b/data/linux/debian/control index 15e1508d..2c195b9c 100644 --- a/data/linux/debian/control +++ b/data/linux/debian/control @@ -6,14 +6,14 @@ Build-Depends: debhelper (>= 7), build-essential, scons, qt4-dev-tools, libpng12-dev, libjpeg62-dev, libilmbase-dev, libopenexr-dev, libxerces-c-dev, libboost-dev, libglewmx1.5-dev, libxxf86vm-dev, collada-dom-dev, libboost-system-dev, libboost-filesystem-dev, - libgl1-mesa-dev, libglu1-mesa-dev, pkg-config + libboost-python-dev, libgl1-mesa-dev, libglu1-mesa-dev, pkg-config Standards-Version: 3.8.3 Homepage: http://www.mitsuba-renderer.org Package: mitsuba Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libqt4-core, libqt4-gui, libqt4-network, libqt4-opengl, libqt4-xml, libpng12-0, libjpeg62, - libilmbase6, libopenexr6, libxerces-c3.1, libboost-filesystem1.42.0, libboost-system1.42.0, libglewmx1.5, libxxf86vm1, collada-dom, + libilmbase6, libopenexr6, libxerces-c3.1, libboost-filesystem1.42.0, libboost-system1.42.0, libboost-python1.42.0, libglewmx1.5, libxxf86vm1, collada-dom, libgl1-mesa-glx, libglu1-mesa Description: Mitsuba renderer Mitsuba is an extensible rendering framework written in portable C++. It implements unbiased as well as biased techniques and contains heavy optimizations targeted towards current CPU architectures. @@ -26,7 +26,8 @@ Package: mitsuba-dev Architecture: any Depends: qt4-dev-tools, libpng12-dev, libjpeg62-dev, libilmbase-dev, libopenexr-dev, libxerces-c-dev, libboost-dev, libglewmx1.5-dev, libxxf86vm-dev, - collada-dom-dev, libboost-system-dev, libboost-filesystem-dev, mitsuba + collada-dom-dev, libboost-system-dev, libboost-filesystem-dev, + libboost-python-dev, mitsuba Description: Mitsuba renderer -- development files Mitsuba is an extensible rendering framework written in portable C++. It implements unbiased as well as biased techniques and contains heavy optimizations targeted towards current CPU architectures. . diff --git a/doc/compiling.tex b/doc/compiling.tex index 3c53f63a..e85bcbe6 100644 --- a/doc/compiling.tex +++ b/doc/compiling.tex @@ -77,7 +77,7 @@ First, run $\text{\$}$ sudo apt-get install build-essential scons mercurial qt4-dev-tools libpng12-dev libjpeg62-dev libilmbase-dev libxerces-c3-dev libboost1.42-all-dev libopenexr-dev libglewmx1.5-dev libxxf86vm-dev libpcrecpp0 - libboost-system-dev libboost-filesystem-dev libboost-dev + libboost-system-dev libboost-filesystem-dev libboost-python-dev libboost-dev \end{shell} Please ensure that the installed version of the boost libraries is 1.42 or later. To get COLLADA support, you will also need to install the \texttt{collada-dom} packages or build it from scratch. Here, we install the \code{x86\_64} binaries and development headers that can be found in the \texttt{dependencies/linux} directory\footnote{The directory also contains source packages in case these binaries don't work for you.}: diff --git a/src/mtspy/SConscript b/src/mtspy/SConscript index 94318bfe..c0912439 100644 --- a/src/mtspy/SConscript +++ b/src/mtspy/SConscript @@ -3,12 +3,12 @@ Import('env', 'sys', 'os', 'hasPython') pythonEnv = env.Clone() pythonEnv.Append(CPPDEFINES = [['MTS_BUILD_MODULE', 'MTS_MODULE_PYTHON']]) pythonEnv['SHLIBPREFIX']='' - - -if sys.platform == 'darwin': - pythonEnv.Append(CXXFLAGS = ['-framework', 'Python'], - CPPPATH=['/System/Library/Frameworks/Python.framework/Versions/2.5/Headers'], - LIBS=['boost_python', 'boost_system', 'Python']) +if pythonEnv.has_key('PYTHONINCLUDE'): + pythonEnv.Prepend(CPPPATH=pythonEnv['PYTHONINCLUDE']) +if pythonEnv.has_key('PYTHONLIBDIR'): + pythonEnv.Prepend(LIBPATH=pythonEnv['PYTHONLIBDIR']) +if pythonEnv.has_key('PYTHONLIB'): + pythonEnv.Prepend(LIBS=pythonEnv['PYTHONLIB']) if hasPython: mtspy = pythonEnv.SharedLibrary('mtspy', ['base.cpp']); diff --git a/src/mtspy/base.cpp b/src/mtspy/base.cpp index e0deafcd..a4f4f0ba 100644 --- a/src/mtspy/base.cpp +++ b/src/mtspy/base.cpp @@ -8,6 +8,6 @@ std::string hello() { return "Hello world!"; } -BOOST_PYTHON_MODULE(mitsuba) { +BOOST_PYTHON_MODULE(mtspy) { def("hello", hello, "Return hello world..."); }