Support for Python 3.3?

1,474 views
Skip to first unread message

Christopher Ostrouchov

unread,
Mar 11, 2014, 9:16:02 PM3/11/14
to hoomd...@googlegroups.com
For Ubuntu 13.10 (I understand that 13.10 is not supported as it is an "unstable release")

libboost 1.54

When I try to install with python3 I run into several errors (some of which I managed to work around and get it to almost completely compile! reason I stopped detailed bellow)

The first issue I got from the CMake Boost configuration file. It was requesting boost_python3 which should really be boost_python 

Next CMake was unable to find my libpython3.3m.so file. I had to manually point PYTHON_LIBRARY to /usr/lib/x86_64-linux-gnu/libpython3.3m.so

The CMake configuration worked! And **almost** completely compiled.

 [100%] Building CXX object python-runner/CMakeFiles/hoomd.dir/hoomd.cc.o
Linking CXX executable hoomd
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyString_Size'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_FromEncodedObject'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyFile_FromString'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyString_Type'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyInt_Type'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyString_FromString'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_AsWideChar'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyString_FromStringAndSize'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `Py_InitModule4_64'
../libhoomd/hoomd.so: undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyString_FromFormat'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyNumber_Divide'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyNumber_InPlaceDivide'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyInt_AsLong'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyString_InternFromString'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyClass_Type'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyString_AsString'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyInt_FromLong'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_python.so: undefined reference to `PyFile_AsFile'
collect2: error: ld returned 1 exit status
make[2]: *** [python-runner/hoomd] Error 1
make[1]: *** [python-runner/CMakeFiles/hoomd.dir/all] Error 2
make: *** [all] Error 2

This is obviously due to python2.7 and python3.3 having different function names for their interface....

Joshua Anderson

unread,
Mar 11, 2014, 9:27:58 PM3/11/14
to hoomd...@googlegroups.com
On Mar 11, 2014, at 9:16 PM, Christopher Ostrouchov wrote:

> For Ubuntu 13.10 (I understand that 13.10 is not supported as it is an "unstable release")
>
> libboost 1.54


I'm happy to support Ubuntu 13.10 for builds from source, as long as it doesn't involve issues with CUDA, driver, or nvcc compatibility issues. Those are for NVIDIA to support.

> When I try to install with python3 I run into several errors (some of which I managed to work around and get it to almost completely compile! reason I stopped detailed bellow)
>
> The first issue I got from the CMake Boost configuration file. It was requesting boost_python3 which should really be boost_python

hoomd searches for various things. It will search for libboost_python-X.Y first (gentoo installs multiple boost_python libs in this way). Then it will search for libboost_python3 if you are using python3 and libboost_python if python2. This is now every other distro that I'm aware of installs the boost python libraries, and how the source builds of boost install when built by hand.

> Next CMake was unable to find my libpython3.3m.so file. I had to manually point PYTHON_LIBRARY to /usr/lib/x86_64-linux-gnu/libpython3.3m.so

This auto-detection should be extremely robust and not require user intervention. What version of python is on your PATH? hoomd will search for python3 first and then python. It will ask the interpreter it finds on the PATH where to find the proper include and library files. The interpreter should never get that wrong :)

You can override a path search for python with: "cmake ../ -DPYTHON_EXECUTABLE=/usr/bin/python3".
Since you force a link to the python3 library and libboost_python, are you 100% certain that libboost_python.so is built against python3? It would seem that maybe you also have a python2 install in the system and libboost_python.so is compiled against python2.

- Josh

Christopher Ostrouchov

unread,
Mar 11, 2014, 9:50:41 PM3/11/14
to hoomd...@googlegroups.com
Josh,

Thanks for the quick reply. Yes I believe that you are right that my boost was compiled against python 2.7.

I ran the cmake this time as:
cmake -DPYTHON_EXECUTABLE=/usr/lib/python

Thus forcing it to use python 2.7. This compiled fine on Ubuntu 13.10 with libboost 1.54 and I am quite happy with this setup for now .. thus delaying even more my adoption of python 3 :) 

I understand that compiling boost against python 3 should be an issue for me to solve and is outside the scope of HOOMD. I normally use apt-get for installing packages and understand that I would just need to compile the boost source and link it to my /usr/local/lib directory and make sure it uses these libraries. If I do this I will make sure to update this forum.

I am a fairly new user to HOOMD but must say that I love the hoomd approach to MD simulations! No more gigantic input files that make version control impossible! And overall great documentation

Thanks,
Chris

Joshua Anderson

unread,
Mar 12, 2014, 7:31:54 AM3/12/14
to hoomd...@googlegroups.com
Thanks for letting me know that works. I'll add a quick note to the documentation that ubuntu's boost package does not provide compatibility with python3. I checked the ubuntu package list and didn't see any mention of boost-python3. We do have some documentation on building boost against python3 in your home directory (http://codeblue.umich.edu/hoomd-blue/doc-master/page_compile_guide_linux_generic.html) to support users on clusters where the administrators do not provide boost+python with header files (like Stampede). Getting boost to build against a specific version of python is a frustrating experience, it usually takes me 2 or 3 tries before I finally get it to build. Annoyingly, it will continue building even if it cannot find the python headers and doesn't make it obvious that it failed to build certain libraries.

I'm glad you like hoomd. If you have an feature requests or suggestions, just let us know.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
Phone: 734-647-8244
http://www-personal.umich.edu/~joaander/
> --
> You received this message because you are subscribed to the Google Groups "hoomd-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.
> To post to this group, send email to hoomd...@googlegroups.com.
> Visit this group at http://groups.google.com/group/hoomd-users.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages