[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IMP-dev] Python 3 support



Just FYI, latest IMP in git should now configure and build successfully if your 'python' binary is actually Python 3 (as with any nonstandard Python, you may need to set the cmake PYTHON_INCLUDE_DIR and PYTHON_LIBRARY variables to tell it where the associated headers and library are).

Note that IMP itself doesn't fully work yet (there are still some issues with string typemaps, most likely because in Python 3 all strings are Unicode).

The plan is to have our Python code run both in Python 2 and Python 3 (as opposed to maintaining a Python 2 version and a Python 3 version). This isn't too onerous since we don't support ancient versions of Python (older than 2.6) any more anyway.

If you have Python code in IMP, I've modified it to work with both Python 2 and 3. You'll notice the major change is that "print" is no longer a statement in Python 3 (it's a function). So you have to say print("foo") rather than print "foo". I added "from __future__ import print_function" in IMP Python modules that use print so this will behave identically in Python 2 and 3. Other differences are fairly minor (e.g. 'xrange' is no more - use 'range' instead; some functions return iterators rather than lists in Python 3 so you have to wrap them with list() if you explicitly want the Python 2 behavior).

	Ben
--
                      http://salilab.org/~ben/
"It is a capital mistake to theorize before one has data."
	- Sir Arthur Conan Doyle