[Biopython-dev] Plan for upgrade

Peter biopython at maubp.freeserve.co.uk
Tue Oct 26 04:43:48 EDT 2010


On Tue, Oct 26, 2010 at 8:24 AM, Dragoslav Zaric
<zaricdragoslav at gmail.com> wrote:
> Dear Peter,
>
> This is what I found on python 3 web pages:
> ----------------------------------------------------------------------------------------------------------------
> Porting To Python 3.0
> For porting existing Python 2.5 or 2.6 source code to Python 3.0, the
> best strategy is the following:
>
> (Prerequisite:) Start with excellent test coverage.
> Port to Python 2.6. This should be no more work than the average port
> from Python 2.x to Python 2.(x+1). Make sure all your tests pass.
> (Still using 2.6:) Turn on the -3 command line switch. This enables
> warnings about features that will be removed (or change) in 3.0. Run
> your test suite again, and fix code that you get warnings about until
> there are no warnings left, and all your tests still pass.
> Run the 2to3 source-to-source translator over your source code tree.
> (See 2to3 - Automated Python 2 to 3 code translation for more on this
> tool.) Run the result of the translation under Python 3.0. Manually
> fix up any remaining issues, fixing problems until all tests pass
> again.
> It is not recommended to try to write source code that runs unchanged
> under both Python 2.6 and 3.0; you’d have to use a very contorted
> coding style, e.g. avoiding print statements, metaclasses, and much
> more. If you are maintaining a library that needs to support both
> Python 2.6 and Python 3.0, the best approach is to modify step 3 above
> by editing the 2.6 version of the source code and running the 2to3
> translator again, rather than editing the 3.0 version of the source
> code.
> ----------------------------------------------------------------------------------------------------------------
>
> And this is page for 2to3 translator:
>
> http://docs.python.org/release/3.0.1/library/2to3.html#to3-reference
>
> So can we start to agree on approach and tactics.
>
> Kind regards

Hi Dragoslav,

Yes, that is basically what we are doing for the pure python code.
We still write our code for Python 2.x (currently Python 2.4 to 2.7),
and then use 2to3 convert it to work on Python 3.x (currently
testing on 3.1, at the end of the year we'll be trying the planned
Python 3.2 beta as well). That is the easy part - its the C code
we need to handle now for our extension modules (and the 2to3
script does not do this). Perhaps I was too concise earlier.
http://lists.open-bio.org/pipermail/biopython-dev/2010-October/008311.html

Peter



More information about the Biopython-dev mailing list