Py3k Port Complete?

94 views
Skip to first unread message

Steven Johnson

unread,
Apr 12, 2011, 11:59:59 PM4/12/11
to python...@googlegroups.com
OK,

I believe the Py3k port of Babel is now complete and operational, at
least as far as the testsuite is concerned.
All doctests, which have been disabled for py3, are replaced with
appropriate unittest cases, and all pass.
On Py2.x both the doctests and the replacement unittests run, which is
redundant testing, but doesn't hurt. It also provides a sanity check
for py3 to ensure the replacement unittests do not regress against the
original doctests.

I have tested on py2.6, py2.7 and py3.2 and babel builds from the same
tree on all of these.

In the process of the port I enhanced pofile reading and the changes i
made close: http://babel.edgewall.org/ticket/255 for both py3.x and 2.x

the ported source is available here:
https://bitbucket.org/felixschwarz/babel-py3k/overview

to build it you need to follow the instructions at:
http://babel.edgewall.org/wiki/SubversionCheckout with regard to
Importing the Locale Data

Importing the cldr data requires running the import_cldr script under
py2.x at the moment, it will not run under py3.x
Also building the docs requires py2.x as some of the prerequisites are
not available for py3.x yet. (namely epydoc and genshi)

Neither of these tasks are normally required by an end user, so I don't
think either of them should be considered an impediment to a Babel Py3.x
supporting release.

Also note that Py3.1 should work, but has not been tested and I do not
think Py3.0 will work as it is missing features I needed for the port.

Strontium

Felix Schwarz

unread,
Apr 17, 2011, 3:08:02 PM4/17/11
to python...@googlegroups.com
Hi Steven,

this is terrific! Currently out of time to review your stuff but I just
wanted to say "Thank You" again.

With the string duality (filename vs. content) I have to think a bit
more about because it doesn't really appeal to me (seems very unpythonic
at the moment) but I have to think about that (and it's also not just
about me!).

fs

Steven Johnson

unread,
Apr 17, 2011, 11:01:20 PM4/17/11
to python...@googlegroups.com
Hi Felix,

On 04/18/2011 03:08 AM, Felix Schwarz wrote:
> Hi Steven,
>
> this is terrific! Currently out of time to review your stuff but I just
> wanted to say "Thank You" again.

No problem. I have played with it on my project, and in the limited
real world testing i've done I have not hit any problems.


> With the string duality (filename vs. content) I have to think a bit
> more about because it doesn't really appeal to me (seems very unpythonic
> at the moment) but I have to think about that (and it's also not just
> about me!).

I'm not concerned about it either way, it was easy enough to do, and is
easy enough to stop doing. I did it because it was mentioned by someone
that polib did it and I tried to make the po interface similar to that
provided by polib. So that, in future if desired, it could optionally
link with polib, instead of using the babel po stuff and the interface
not change. I think it would be reasonably trivial to write a

try import polib
"po lib veneeer"
except
"babel functions"

type of thing in pofile.py and mofile.py, which would give wichert
exactly what he was after, without introducing a hard dependency on
people who didn't want or need it. The only reason I didn't implement
it was because polib currently doesn't work in py3k and my focus was
getting py3k happening for babel, not supporting polib with a py3k port.

If wichert was interested in looking at the improved po file handling
stuff to verify if this is right, that would be good, as I am not a
polib expert and only spent about 20 minutes looking through its code to
come up with an improved interface for bable i think would be easy to
coerce into polib calls.

Steven

Vinay Sajip

unread,
May 26, 2011, 2:38:38 PM5/26/11
to Python Babel
On Apr 13, 4:59 am, Steven Johnson <sjohn...@sakuraindustries.com>
wrote:

> I believe the Py3k port of Babel is now complete and operational, at
> least as far as the testsuite is concerned.
> All doctests, which have been disabled for py3, are replaced with
> appropriate unittest cases, and all pass.
> On Py2.x both the doctests and the replacement unittests run, which is
> redundant testing, but doesn't hurt.  It also provides a sanity check
> for py3 to ensure the replacement unittests do not regress against the
> original doctests.

You and/or others may be interested in an alternative port which I've
been working on. I need something which does not require the use of
2to3, but rather a single code-base which runs on Python 2.x or 3.x
without alteration. The single code-base technique worked well when
porting pip and virtualenv to Python 3.

I was able to arrange the doctests so that they run on 2.x or 3.x,
except for the case of the three which show exception tracebacks
(these failed because Python 3.x shows the fully qualified exception
class name, whereas 2.x doesn't) . I replaced these three with unit
tests.

> I have tested on py2.6, py2.7 and py3.2 and babel builds from the same
> tree on all of these.

Likewise, I've tested my port on Python 2.4, 2.6, 2.7 and 3.2, and all
tests (including doctests) pass in all cases. Results for the 2.7 and
3.2 tests can be seen at

https://gist.github.com/993455

> the ported source is available here:https://bitbucket.org/felixschwarz/babel-py3k/overview
>
> to build it you need to follow the instructions at:http://babel.edgewall.org/wiki/SubversionCheckoutwith regard to
> Importing the Locale Data

And my fork is at

https://bitbucket.org/vinay.sajip/babel3

same instructions apply w.r.t. CLDR setup. (You do need to create the
babel/localedata directory first, if it's not already there.)

> Importing the cldr data requires running the import_cldr script under
> py2.x at the moment, it will not run under py3.x
> Also building the docs requires py2.x as some of the prerequisites are
> not available for py3.x yet. (namely epydoc and genshi)

As I'm not using 2to3, the import_cldr script in my port works fine
under 3.x. In fact I ran the unit tests on both 2.7 and 3.2 after
running import_cldr with both Python 2.7 and 3.2, just for added
sanity checking. The tests passed in both scenarios.

> Neither of these tasks are normally required by an end user, so I don't
> think either of them should be considered an impediment to a Babel Py3.x
> supporting release.

Perhaps, but it's definitely neater if you don't have to rely on
having 2.x available to do the CLDR import.

Regards,

Vinay Sajip

Jayd3e

unread,
May 31, 2011, 6:03:19 PM5/31/11
to Python Babel
Is the Py3 compatible version of Babel available for download under
easy_install yet? I am porting over some dependencies of the Pyramid
web framework, and I am still getting syntax errors under Py3.2.

On Apr 12, 10:59 pm, Steven Johnson <sjohn...@sakuraindustries.com>
wrote:
> OK,
>
> I believe the Py3k port of Babel is now complete and operational, at
> least as far as the testsuite is concerned.
> All doctests, which have been disabled for py3, are replaced with
> appropriate unittest cases, and all pass.
> On Py2.x both the doctests and the replacement unittests run, which is
> redundant testing, but doesn't hurt.  It also provides a sanity check
> for py3 to ensure the replacement unittests do not regress against the
> original doctests.
>
> I have tested on py2.6, py2.7 and py3.2 and babel builds from the same
> tree on all of these.
>
> In the process of the port I enhanced pofile reading and the changes i
> made close:http://babel.edgewall.org/ticket/255for both py3.x and 2.x
>
> the ported source is available here:https://bitbucket.org/felixschwarz/babel-py3k/overview
>
> to build it you need to follow the instructions at:http://babel.edgewall.org/wiki/SubversionCheckoutwith regard to

Vinay Sajip

unread,
Jun 1, 2011, 4:48:24 AM6/1/11
to python...@googlegroups.com
On Tuesday, 31 May 2011 23:03:19 UTC+1, Jayd3e wrote:
Is the Py3 compatible version of Babel available for download under
easy_install yet?  I am porting over some dependencies of the Pyramid
web framework, and I am still getting syntax errors under Py3.2.
 
Perhaps not from PyPI, but you should be able to easy_install using a URL referencing the distribution tarball. For my fork, you'd do

easy_install https://bitbucket.org/vinay.sajip/babel3/get/tip.tar.gz

and I just tested it in a Python3.2 virtualenv, it seems to work:

(bab)vinay@eta-natty:~/projects/scratch$ easy_install https://bitbucket.org/vinay.sajip/babel3/get/tip.tar.gz
Downloading https://bitbucket.org/vinay.sajip/babel3/get/tip.tar.gz
Processing tip.tar.gz
Running repos15-r-265281-5e1b0fd060cc/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ifs0om/repos15-r-265281-5e1b0fd060cc/egg-dist-tmp-ixrqmh
warning: no files found matching 'babel/global.dat'
warning: no files found matching 'babel/localedata/*.dat'
warning: no files found matching 'doc/api/*.*'
warning: no files found matching 'doc/*.html'
Adding Babel 1.0dev to easy-install.pth file
Installing pybabel script to /home/vinay/.virtualenvs/bab/bin

Installed /home/vinay/.virtualenvs/bab/lib/python3.2/site-packages/Babel-1.0dev-py3.2.egg
Processing dependencies for Babel==1.0dev

Regards,

Vinay Sajip
Finished processing dependencies for Babel==1.0dev

Reply all
Reply to author
Forward
0 new messages