[Rivet] python2 change

Frank Siegert frank.siegert at cern.ch
Tue Jun 10 15:48:12 BST 2014


Just for the record, I have temporarily given up on adding Python3
compatibility to YODA/Rivet. Parts of the necessary changes are
already on the python3 repos, but I noticed that quite a bit more work
is necessary in the cython source files... explicitly
encoding/decoding strings and bytes within Python and to/from C++. I
have tried for a few days to get this working, and even though I now
understand a lot more cython than I used (and wanted) to, I still
haven't figured out an elegant solution, in particular not one that is
maintainable in parallel for Python 2 and 3.

For the time being, I'm resorting to building with (the non-default)
python2 even in Archlinux, which is relatively simple with a few sed
replacements in our build systems:
https://aur.archlinux.org/packages/yo/yoda/PKGBUILD
https://aur.archlinux.org/packages/ri/rivet/PKGBUILD

Once python3 is becoming more widespread we can revisit the porting,
in particular once somebody more familiar with cython needs python3
compatibility themselves ;-)

Cheers,
Frank



On 15 May 2014 11:45, David Grellscheid <david.grellscheid at durham.ac.uk> wrote:
>
>> Does anybody have experience with the __future__ compatibility layer?
>
> They change the behaviour of features, so that a python2 interpreter
> does the right thing with python3 code:
>
> As the first lines in the file write:
>
> from __future__ import print_function # works from 2.6
> from __future__ import division # from 2.5
> from __future__ import with_statement # from 2.5
> from __future__ import # ... whatever else you need, see ...
>
> # https://docs.python.org/2/library/__future__.html
>
>   David


More information about the Rivet mailing list