There are two issues here. One is about building the bindings for
different Pythons. The other is about installing them simultaneously.

1. Building them. You need to specify PYTHON_LIBRARY and
PYTHON_INCLUDE_DIR. You will know if you have gotten it correct if you
grep PYTHON in CMakeCache.txt after running cmake. On my Linux system,
if I don't specify anything it picks up Python2.7. If I want to use
another Python, I can for example use

 cmake ../openbabel-2.3.2 -DCMAKE_INSTALL_PREFIX=`pwd`/tree
-DPYTHON_BINDINGS=ON -DPYTHON_INCLUDE_DIR=/usr/include/python3.2
-DPYTHON_LIBRARY=/usr/lib/libpython3.2mu.so

2. Regarding installing them simultaneously, it's true that "make
install" copies all the files to the install folder. So the Python 3.2
bindings will overwrite the Python 2.7 bindings if you use the same
install folder for both. If this is a problem, you can either (a) use
different install folders via -DCMAKE_INSTALL_PREFIX or (b) copy
_openbabel.so and the associated .py files to a different location,
e.g. Python 2.7's site-packages folder.

Note that we don't use Python's distutils to automatically copy the
files to the standard Python install folder. We used to, through a
variety of approaches, but I just found it too difficult to maintain
as it needs to (a) preserve the functionality of "DESTDIR=wherever
make" which is used by package distributors to stage a build, (b) work
for local builds without root access and (c) work for system installs.
The downside is that the user needs to set PYTHONPATH themselves, or
that they need to copy the files somewhere else for multiple Python
installations.

- Noel


On 22 October 2013 02:35, David Hall <li...@cowsandmilk.net> wrote:
> Hi Baris,
>
> To install bindings for python2 and python3 simultaneously, I had to make
> some edits to CMakeLists.txt, which can be seen at
> https://github.com/openbabel/openbabel/pull/33
>
> After making those edits, I was able to do the below on my mac (10.8):
>
> #build for python2.7
> cmake -DRUN_SWIG=ON -DPYTHON_BINDINGS=ON  ..
> make -j12 && make install
>
> #delete cmake cache, build for python3.3
> rm CMakeCache.txt
> cmake -DRUN_SWIG=ON -DPYTHON_BINDINGS=ON
> -DPYTHON_EXECUTABLE=/usr/local/bin/python3.3
> -DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.3/lib/libpython3.3.dylib
> -DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.3/Headers
> ..
> make -j12 && make install
>
> #test 2.7 and 3.3 packages, should not show any import errors
> PYTHONPATH=/usr/local/lib/python2.7/site-packages/ /usr/bin/python -c
> 'import pybel'
> PYTHONPATH=/usr/local/lib/python3.3/site-packages/ /usr/local/bin/python3.3
> -c 'import pybel'
>
>
> -David
>
>
>
> On Mon, Oct 21, 2013 at 4:29 AM, O. Baris Malcioglu
> <baris.malcio...@gmail.com> wrote:
>>
>> Dear all,
>>
>> MacOS has a different standard for placing libraries. After a bit of
>> digging, I found out where the python libraries are, and modified the
>> suggestion of David Hall accordingly.
>>
>> However, python 3 bindings are still not installed. (installer still
>> installs the python 2.7 bindings, but skips the python3 bindings)
>>
>>
>>
>>
>>
>> cmake -DPYTHON_BINDINGS=ON
>>
>> -DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.3/lib/libpython3.3.dylib
>>
>> -DPYTHON_INCLUDE_PATH=/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m/
>> -DPYTHON_EXECUTABLE=/usr/local/bin/python3 ../openbabel-2.3.1
>> -- Using included inchi library.
>> -- Could NOT find wxWidgets (missing:  wxWidgets_FOUND)
>> -- checking for module 'cairo'
>> --   package 'cairo' not found
>> -- Could NOT find Cairo. PNG output will NOT be supported.
>> -- Attempting to build the GUI
>> --    wxWidgets not found => GUI will not be built
>> -- Found PythonInterp: /usr/local/bin/python3 (found version "3.3.2")
>> -- Configuring done
>> -- Generating done
>> CMake Warning:
>>   Manually-specified variables were not used by the project:
>>
>>     PYTHON_INCLUDE_PATH
>>     PYTHON_LIBRARY
>>
>>
>>
>> On Sat, Oct 19, 2013 at 9:27 PM, Noel O'Boyle <baoille...@gmail.com>
>> wrote:
>> > Open Babel should work fine with Python 3.
>> >
>> > - Noel
>> >
>> > On 19 October 2013 19:17, David Hall <li...@cowsandmilk.net> wrote:
>> >> I would try something like this, but modified for the mac:
>> >> cmake -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
>> >> -DPYTHON_LIBRARY=/usr/lib/python3.2/config/libpython3.2.so
>> >> -DPYTHON_INCLUDE_PATH=/usr/include/python3.2
>> >> -DPYTHON_EXECUTABLE=/usr/bin/python3.2 ../openbabel-2.3.1
>> >>
>> >> I don't actually know whether openbabel works with python3, so buyer
>> >> beware.
>> >>
>> >> -David
>> >>
>> >>
>> >> On Sat, Oct 19, 2013 at 6:23 AM, O. Baris Malcioglu
>> >> <baris.malcio...@gmail.com> wrote:
>> >>>
>> >>> Hi everyone,
>> >>>
>> >>> I have installed python3 to my Mac from the official distribution,
>> >>>
>> >>> However, when I try to install openbabel with python bindings using
>> >>> cmake ../openbabel-2.3.1 -DPYTHON_BINDINGS=ON -DBUILD_GUI=ON
>> >>>
>> >>> only bindings for python 2.7 are installed.
>> >>>
>> >>>
>> >>>
>> >>> is there a way I can make openbabel install python3 bindings as well?
>> >>> Simple aliasing does not work.
>> >>>
>> >>> Googling the problem did not help. (Is there a way to search archives
>> >>> of this mailing list?)
>> >>>
>> >>> best,
>> >>> Baris
>> >>>
>> >>>
>> >>>
>> >>> ------------------------------------------------------------------------------
>> >>> October Webinars: Code for Performance
>> >>> Free Intel webinars can help you accelerate application performance.
>> >>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the
>> >>> most
>> >>> from
>> >>> the latest Intel processors and coprocessors. See abstracts and
>> >>> register >
>> >>>
>> >>>
>> >>> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
>> >>> _______________________________________________
>> >>> OpenBabel-discuss mailing list
>> >>> OpenBabel-discuss@lists.sourceforge.net
>> >>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>> >>
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> October Webinars: Code for Performance
>> >> Free Intel webinars can help you accelerate application performance.
>> >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the
>> >> most
>> >> from
>> >> the latest Intel processors and coprocessors. See abstracts and
>> >> register >
>> >>
>> >> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
>> >> _______________________________________________
>> >> OpenBabel-discuss mailing list
>> >> OpenBabel-discuss@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>> >>
>
>

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to