From: Caio S. Souza (caiobiounb_at_gmail.com)
Date: Sat Oct 29 2016 - 10:09:58 CDT

Hi, John
As far as I know, the 2to3 tool can't deal with C/C++ code. That's why I
used it only in the scripts inside the python folder. The majority of
changes I've made are related only to modules declarations. There were few
cases where I changed the implementation of some methods. So unless the
general python API was changed, this code should work as is. I'll try to
compile VMD 1.9.3 as soon as possible to see what happens.

The usual approach adopted by tools that generate C/C++ code compatible
with both versions (like cython) is to use generic macros whose declaration
depends on which version the code is being compiled with. This way it's
possible to suppress all the compile conditionals that are spread
throughout the code. That's sort of what I've done in the
py3_translations.h file for some simple cases. If you are willing to push
all of this into the standard distribution, I may rewrite the code using
this other approach.

Cheers

--
Caio S. Souza
Laboratório de Biologia Teórica e Computacional
Universidade de Brasília
www.lbtc.unb.br
2016-07-14 13:00 GMT-03:00 John Stone <johns_at_ks.uiuc.edu>:
> Hi,
>   Thanks for your efforts.  I took a few minutes to read through some
> of your diffs, and I gather that in general the approach you took was to
> make just the changes necessary to bring the code within range of what the
> 2to3 converter is capable of automatically regenerating, yes?  The VMD
> Python interface has been updated somewhat since VMD 1.9.2, but I would
> think
> that in roughly half of cases, your changes will work as-is, and in the
> other half it should not be too difficult to adapt your previous diffs
> so they are workable with the new VMD code also.
>
> Since the Python C API has changed from 2.x to 3.x, one question I have is
> whether we might want to use the 2to3 tool in advance and have the
> pre-patched 3.x versions of the code included in the VMD source tree using
> some new naming scheme, e.g. instead of "py_filename.C" for Python 2.x
> source,
> we would pre-run the conversion using 2to3 and then checkin the converted
> source as "py3_filename.C" and it would then be part of the standard
> distribution and people compiling from source would not have to
> perform the 2to3 conversion themselves (or expect that it would work
> automatically if we incorporated it into the compilation system).
>
> Regarding the issue with Tkinter, I think that this problem can probably
> be overcome one way or another.  I saw your and other people's previous
> discussions on this topic on stackoverflow.  It seems likely there's a
> solution to this but we can revisit this later on after the major Python3
> updates are included in the VMD tree in a useful way.
>
> Let me know what you think.
>
> Cheers,
>   John Stone
>   vmd_at_ks.uiuc.edu
>
>
> On Tue, Jul 12, 2016 at 07:03:21PM -0300, Caio S. Souza wrote:
> >    Hi!
> >    I've made the necessary changes to allow compiling VMD (1.9.2) with
> python
> >    versions 2.7.x and 3.x. I tested it on versions 2.7, 3.3, 3.4 and
> 3.5, and
> >    everything is working well. The only drawback is that tkinter is not
> >    usable under versions 3.x. This is due to the removal of the function
> >    Tkinter.tkinter.dooneevent which VMD relies on (file
> PythonTextInterp.C).
> >    I couldn't find a replacement to this code. So, don't create tkinter
> UI
> >    when using version 3+. On version 2 tkinter works as expected.
> >
> >    To compile, simply place the modified files
> >    ([1]www.lbtc.unb.br/software/downloads/vmd-1.9.2-python3-
> modifications.zip)
> >    into the "src" folder. To use python 3+, run the 2to3 tool on the
> files
> >    inside the "python" folder.
> >
> >    Cheers
> >    --
> >    Caio S. Souza
> >    LaboratA^3rio de Biologia TeA^3rica e Computacional
> >    Universidade de BrasAlia
> >    [2]www.lbtc.unb.br
> >
> > References
> >
> >    Visible links
> >    1. http://www.lbtc.unb.br/software/downloads/vmd-1.9.2-
> python3-modifications.zip
> >    2. http://www.lbtc.unb.br/
>
> --
> NIH Center for Macromolecular Modeling and Bioinformatics
> Beckman Institute for Advanced Science and Technology
> University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> http://www.ks.uiuc.edu/~johns/           Phone: 217-244-3349
> http://www.ks.uiuc.edu/Research/vmd/
>