gpsd-dev
[Top][All Lists]
Advanced

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

Re: [gpsd-dev] GPSD and the Python 3 transition


From: Fred Wright
Subject: Re: [gpsd-dev] GPSD and the Python 3 transition
Date: Wed, 23 Mar 2016 18:22:38 -0700 (PDT)

On Tue, 22 Mar 2016, Eric S. Raymond wrote:

> The Python 3 transition is upon us. Fedora rawhide is switching to
> Python 3 as its 'python' default.

Somewhat premature IMO, given the amount of Python3-incompatible code
that's still around (not to mention going against the PEP0394
recommendation), but oh well.

> I have applied this method to most of the GPSD Python code and tested
> the results.  A couple of minor tweaks remain to be done, and there is
> one significant problem; I can't verify that xgps or xgpsspeed work
> under Python 3 because on Ubuntu there are no 3.x packages for gobject
> or pygtk under Ubuntu.

MacPorts has gobject for Python 3, but not pygtk.  If neither OSX nor
Linux have it, it's probably not even worth looking at xBSD.

> If you are a dev or user running a distro that has such packages,
> please try changing the shebang line in these scripts to invoke
> Python 3 and testing them.  They ought to just work (I know the gps
> client library is good under 3) but I want to verify that.  Then we
> could change the shebang line to invoke python (rather than python2)
> and not care what it finds.

You don't need to change the shebang line for testing - just run the
desired Python version:

        $ pythonX.Y <full path to program> <args>
or
        $ pythonX.Y $(which <program>) <args>

> This does mean the floor Python version we can use is now 2.7; 2.6
> is not compatible enough with 3.x for my polyglot trickery to work.

Which specific things don't work in 2.6?

> Current state of the Python code:
>
> gegps, gpscap.py, gpsfake, leapsecond.py, gps/*, maskaudit.py - OK under 2 or 
> 3.

At least one counterexample:

MacPro:gpsd fw$ python2 ./gpsfake -T
sys darwin platform Darwin-13.4.0-x86_64-i386-64bit: WRITE_PAD = 0.03000
MacPro:gpsd fw$ python3 ./gpsfake -T
Traceback (most recent call last):
  File "./gpsfake", line 17, in <module>
    import gps.fake as gpsfake   # The "as" pacifies pychecker
  File "/Volumes/MacPro-Misc/GitHub/gpsd/gps/fake.py", line 231
    raise ValueError, line
                    ^
SyntaxError: invalid syntax

> gpscat, test_maidenhead.py - don't work yet under Python 3, apparently
> due to the clienthelpers C module not being installed where Python 3
> can see it. Probably needs a build-recipe tweak.

I presume you were at least pointing python_libdir at the appropriate
place for the Python 3 you were using, since the default (obtained from
the scons Python) is guaranteed to be inappropriate for Python 3.

In fact, although I'm not a fan of monoversioned shebang lines in general,
given that Python packages are normally installed in a version-specific
location, some means for writing the corresponding shebang lines into the
installed executables should probably exist, at least as an option.

Fred Wright



reply via email to

[Prev in Thread] Current Thread [Next in Thread]