Ticket #350 (closed bug: fixed)

Opened 5 years ago

Last modified 2 months ago

python code is not v3 compatible

Reported by: yellius Assigned to: adi
Priority: minor Milestone: FFADO 2.x
Component: generic Version: FFADO SVN (trunk)
Keywords: python diag static helpers Cc:
The device the bug applies to:

Description

Specifically the command print "..." is depreciated:

http://www.python-forum.org/pythonforum/viewtopic.php?f=3&t=10557&start=0

and the commands module is replaced with subprocess:

http://docs.python.org/library/commands.html

Cheers,

Jelle.

Change History

04/13/12 09:47:46 changed by yellius

  • priority changed from major to minor.

04/14/12 03:32:44 changed by jwoithe

Dealing with these issues is possibly going to require someone who is far more knowledgeable of python than I am. I essentially know just enough to maintain the mixer modules for the devices I maintain in FFADO.

One important question is how these issues can be dealt with while retaining compatilibility with python 2.x which is, as I understand it, still in very wide-spread use.

In relation to the print issue, I was a little confused after reading the above forum conversation. Is the point that we need to replace

print 'foobar'

with

print('foobar')

The forum posts seemed to disagree over whether this was python 2 compatible though. I've just tried both of these statements with python 2.6.6 and they both worked. But I have no idea how applicable this is to other python installations.

The latter issue (the deprecation of the "commands" module) my be harder to work around. Running

import subprocess

in python 2.6.6 worked, but clearly the old "command" functions are not available therein. This means that any FFADO python code will have to adapt to the version of python installed on the system. In practice this probably means that scons will have to do a detection for the version of python. The relevant script *.in sources will need to have separate sections for both cases, with the applicable one selected according to the version detected by scons.

To someone with little python experience such as myself this will be time consuming to implement since I expect I'd have to learn a bunch of python first (and work out how 2.x differs from 3.x). Fortunately there are other FFADO developers who do have an extensive knowledge of python, so I will defer to them for comments as to what - if anything - we can do about this issue.

04/14/12 05:25:50 changed by stefanr

IMO the bug title "python code is not v3 compatible" is unclear. What is the problem with that? Is that that at some point in the future, people will prefer to have only a python 3 runtime environment on their machine? Or is the problem that the current FFADO python scripts don't work properly on a mixed python 2 and 3 installation?

If it is the former, then there are two general ways to perform a transition to pthyon 3:

  • Write the code such that it works likewise in a python 2 or python 3 environment.
  • Rewrite the code for python 3. A part of this process can be automated.

There are various pros and cons to either approach.

Some guidelines on what is involved in one or the other approach: http://readthedocs.org/docs/python/en/latest/howto/pyporting.html

A reference documentation, useful to both approaches: http://docs.pythonsprints.com/python3_porting/py-porting.html

04/14/12 06:30:18 changed by jwoithe

Stefan: thanks for the helpful feedback. Hopefully the original reporter can provide some clarifying comments.

In light of Stefan's points (and any further comments provided by the reporter) what do others think about this issue? I don't think it's a version 2.1 blocker, but what position should we adopt beyond that? Should we wait things out a bit longer to see how the python transition develops, or are there sensible things we can do now to prepare for the transition (and people to do them :-) )?

04/14/12 09:55:04 changed by adi

  • owner set to adi.

JFTR, nedko and me have recently ported jackd2's waf build system to python3 while retaining compatibility with python-2.6 (and above).

ATM, I agree that it's acceptable to require python < 3.0, but I'd volunteer to fix it in a couple of weeks (you know, time is always an issue)...

Rough estimate: maybe two to five hours of work.

04/14/12 17:12:55 changed by jwoithe

Adrian: your plan sounds good - thanks for volunteering. Obviously the precise timing is unimportant, but if you're talking of the order of a few weeks then I expect that this will be in plenty of time make 2.1 (which, I suspect, we'll be in a position to seriously contemplate only in a couple of months).

And yes, I understand completely about the time issue. :-)

So, let's see how things go over the next few weeks in regard to this issue.

06/01/12 04:47:28 changed by jwoithe

This is really just a "bump" about this issue. Adrian, keeping in mind that you have many things on the go at present, are you able to provide an update as to when you may get a chance to look at this python 3 issue?

(follow-up: ↓ 9 ) 08/01/12 02:08:16 changed by adi

Did I mention that scons doesn't support pythonv3? So even if our runtime code is ported, the build system still requires python v2.x.

(in reply to: ↑ 8 ) 08/01/12 16:34:57 changed by jwoithe

Replying to adi:

Did I mention that scons doesn't support pythonv3?

Err, no. :-) This implies that there really isn't much point in urgently making the python code compatible with python3 until scons itself has been made compatible. Based on that, keeping this ticket's milestone at 2.x is probably appropriate and it shouldn't be considered a showstopper for a 2.1 release. In essence it gets done when it gets done. Does this sound about right?

07/13/17 05:22:00 changed by jwoithe

  • status changed from new to closed.
  • resolution set to fixed.

As of r2705 (7 June 2017), FFADO's python code (which is used almost exclusively to implement ffado-mixer) is close to being compatible with python3 while still being usable under Python2. This is thanks in part to Xavier Forestier who posted a large patchset to ffado-devel in November 2016. This was integrated into trunk by myself over the first half of 2017 in a way which preserved compatibility with Python2.

There is almost certainly more refining to be done but the heavy lifting should now be mostly complete, and reports from Xavier after testing indicate that it is workable. Consequently it is appropriate to close this ticket. If Python3 related issues are identified a fresh ticket should be created or the problem reported to the ffado-devel mailing list.

As mentioned by Adrian on 1 Aug 2012 in comment 8, the scons build system is still Python2 only. However, this is really a separate issue.