Closed josephsl closed 5 years ago
Python's 2to3 script can be used for this request. Its developers included 2to3 into Python 3.
Hi,
A few years ago, I tried this approach and it produced mixed results. Although 2to3 did work to some extent, the resulting code needed corrections. Also, this is just not as easy as letting the current code run through this script: dependencies must be satisfied, and we need just two more dependencies in order to even start transition planning, namely SCons and wxPython (wxPython is another story, which is covered in #7077).
Thanks.
Hi,
Although the actual transition plan is a bit cloudy at the moment, @JCSTeh suggests via IRC that next year would be a good timeframe, and @LeonardDer concurring with this thinking. A tentative plan is thus:
Prerequisites: wxPython 4 testing must be completed i.e. merged into master and tested in at least two NVDA stable releases. For the purposes of this plan, N refers to NVDA release with wxPython 4, N+1 referring to next one and so on.
The above plan is subject to change. Thanks.
Is it possible to build a NVDA distribution, which contains selectable Python 2.7 runtime and Python 3.x runtime simultaneously? If single version of NVDA can be switchable between Python 2.7 mode and Python 3.x mode during the migration period (for several official releases), possible benefits are:
Thanks for your thoughts. I don't think having both versions in the same distribution is feasible/workable:
Would you maybe consider that by the time Python 3 versions are stable that it be only a 64 bit app? Or can it be made to install in both 64 and 32 bit systems. It would get rid of the issue of people attempting to install it in xp, as will I am sure happen otherwise. Brian
Ideally, for maximum market availability, Python 3.4 should be targeted as it is the last version to support Windows XP.
I don't want to start the whole Xp discussion over again (#6718), but I disagree with this. When moving to Python 3, we should target the last version available at the time of the switch.
Hi, hence the “ideal” case. In reality, 3.5 or higher should be targeted (3.6 is optimal), hence we can officially start working on #6718 as well. Thanks.
Thanks for your clarification.
Just for reference, one major argument for not targetting 3.4 is this overview. Note that the EOL date for Python 3.4 is 2019-03-16. After this date, major security risks won't be patched any more.
Hi,
Laying the initial foundation in an internal branch (located at a personal fork of NVDA source code):
The trivial case at this time is winreg versus _winreg compatibility. Because API's and side effects are the same, this is perhaps the easiest milestone: import winreg, and if not, use _winreg and rename it to winreg. I'm intentionally using the newer winreg.* methods to incorporate forward thinking principles.
For future reference: if anyone wants to investigate Python 3 compatibility (for personal research purposes), or wish to test and send PR's, please do NOT send them to NV Access yet (there are higher priority works to be done, hence I propose p3 for this year). Instead, use josephsl/NVDA branch py3000 for now.
In doing this, I recommend folks to follow the below advice and guidelines:
Note: the above procedure is for those who're thinking about tackling this issue for personal research purposes. During this process, someone should write a report to be sent to NV Access, collecting our data and findings.
When meeting ambiguous code or code paths that could work well on both 2 and 3: try either strict compliance or compatibility approach. The following winreg and dictionary key iteration gives examples of these approaches:
Strict: import winreg and use winreg. Compatibility: import _winreg as winreg and use winreg., or use import winreg as _winreg and use existing code paths without modifications.
Strict: for key in dict.keys(): pass Compatibility: Have a flag that checks sys.version.startswith("3") and: for key in dict.keys() if py3 else dict.iterkeys(): pass
Once you choose an approach, please do not be tempted to switch methods, otherwise you'll end up with more headaches than before.
Thanks.
I am concerned about the long tail of addons that will either never be ported or will require community intervention or otherwise will be slow to Python 3 and recommend moving up the timeline for pushing addon developers into at least using the subset of Python that is compatible with both versions to as early as possible. I further recommend including something like Python Future in core to ease the porting process.
To @CToth: As for add-ons, I'm taking your advice by making sure future versions of my add-ons are source-compatible with both 2 and 3. Sometime this year, I'll advise others to follow suit. Thanks.
Follow-up to SCons: see #7520 for an update. With that in place, we're ready to start researching. Thanks.
Waiting for #7546 to come to master branch before continuing. Thanks.
As noted on #7520, SCons 3 is out, and #7546 is part of master, so let's start researching. Thanks.
Update: Once #7568 is part of NVDA master, that's when I propose code should be checked in. Thanks.
I belief that first, all dependencies for Python 3 should be satisfied, so this includes the update to WX Python Phoenix 4.0 being incorporated into Master.
Hi, yep, that’ll be done as part of a pull request once wxPython 4 officially ships (now up to beta 2). Thanks.
If I may make a users comment here, using my idiot head.." There sould, in my opinion be a new snapshot branch that we can test. Also when thinking about add ons, maybe some kind of protection should be put into the loading of add ons so nobody can load the old ones, only the new ones in the new code versions of nvda.
As you will want testing to at least be done by as many basic users as possible when the major issues are corrected, it is then when it can be put out in a master. Also, because of changes in syntax, does this mean app modules already in nvda will possibly need to be rewritten? If yes, could I ask that we still support legacy software aslong as people have it running on at least windows 7. That will stop a lot of problems trying to solve things later on. I and others do use such software, but I'm not sure how many of these use specific app modules or just work m in nvda anyway. Outlook Express/live mail is one, andprobably older versions of Office like 2007, and several third party apps as well.
As I've said before, I'm OK to test at present with portable versions of new builds in my bog standard windows 7. I'm expecting to get some more modern machines soon so will be up to speed then, but do have a history of using legacy software simply cos it works.
Lastly in this issue, there are comments about xp, but as you have already dropped support there, don't let it mean that you also drop support for legacy software as well. I think blind people on average do hang on to older software longer than most simply to avoid the learning curve. I am now 67, and find my learning curve is somewhat harder to climb than when I was 25!
Hi, I’ll make sure all app modules that ships with NVDA are properly ported, or if not completely, at least made compatible with both 2 and 3. Thanks.
How about the liblouis python bindings? According to tests by @roelvdwal, these are not yet py3 ready.
Hi, uh oh, another setback for us. CC @JCSTeh, @DKager
Turns out Python 3 x64 was used for that test with an x86 dll, so no, that does not work indeed. :P Still a thing that should be tested.
Some thoughts and questions:
bytes(cells)
instead of "".join(chr(cell) for cell in cells)
. Furthermore, when getting the int value from a byte string, you can just index the byte string, so ord(packet[3]) can be changed to just packet[3]. Many constants used in braille display drivers are saved as one byte strings, converted to ordinals when required, I propose changing byte constants to integers as much as possible, as with the new bytes class, it is much easier in the end to deliver them as bytes to the display.@josephsl commented on 25 aug. 2017 04:15 CEST:
... making sure future versions of my add-ons are source-compatible with both 2 and 3.
Hi, since most add-ons use Python standard library, it can be checked via 2to3 and runtime checks (the code, that is) by running the affected code in Python 3 interpreter first. As for compatibility, eventually, only Python 3 should be supported, but for sake of ease of transition, compatibility should be maintained for about six months (two NVDA releases). Thanks.
Not sure if this has been asked for before, but it would I think be very handy to have an archive section for add ons that work on 2017.3 so that xp users can still get hold of them. I was asked this the other day, and really could say no more than try one and see if it works.
I realise that the suitability of add ons is not strictly a version of the language issue and is also a change of support issue in the main nvda system, but thought it worth noting here as well as in the other thread about add ons. Brian
Update: wxPython 4 is out (at least it is now up to 4.0.1), and given that #7104 is planned for 2018.2, I'd say let us designate 2018.2 as N release (start of transition). This means:
Comments are appreciated. Thanks.
From what' I've seen, it looks like that py2exe does not support Python 3.6. Honestly, Pyinstaller never impressed me that much. Cx_Freeze looks promising though.
@Josephsl: Do you have any ideas or comments on this topic?
I'm not really an expert on these. Sorry.
I did some quick tets with both pyinstaller and cx_Freeze, and it seems that the latter is prefered. Pyinstaller doesn't integrate into distutils, whereas cx_Freeze does.
The version of use would be version 5.1.1. Version 6 is currently in beta and targets Python 3.5+.
I see. Can we create a new issue that references this one so we can do more research? I’m battling a problem with inability to add items in speech dictionaries at the moment. Thanks.
July 2018 updates:
As for my role: due to various reasons, I might not be able to provide active contributions for this one. But I'm sure there are many in the NVDA community who are ready to take this on and make it happen.
How can i start contribution to this project. I have almost one year of experience in python 3X.
Please see contributing guide in wiki. https://github.com/nvaccess/nvda/wiki/Contributing Then you can help nvaccess process issues and pull requests. This group may also be helpful. https://nvda.groups.io/g/devlearning @Jitender46559
Update as of April 15, 2019: several add-ons are Python 3 ready or are being ported to Python 3. Broad transition won't begin until NV Access officially declares start of Python 3 transition phase.
We will be targeting python 3.7, at this stage we expect to do at least one more releases of NVDA (possibly two) before we do a python 3 release of NVDA. We want to make it as simple as possible to find and fix issues caused bt high risk changes. So the aim is to have the minimal changes, just those related to python 3 and the speech refactor PR.
There has been investigation into the packaging tool, and some success with py2exe. See #8375
Some thought is currently being put into how to keep the threshold branch python 3 compatible. We need to be able to stay on top of changes coming from master (bug fixes, new features). There are also many PR's that will not be merged. Some way to detect problems in these changes sets (and ideally automatically rectify) will save a lot of time and mistakes.
2to3 (From python 3.7) to automatically apply updates has been considered, but has not shown much promise. The changes need to be inspected carefully. Running the tool a second time seems to further modify the code making unnecessary changes. This is problematic, since we need to be able to merge another branch then run the tool again. Perhaps if we could get it to run just on a diff / patch?
We are considering adding the -3
argument to our python 2 build, this should highlight problems in master which can be made compatible with both 2 and 3. This will reduce the burden of merges, however it is likely to push some risk back into prior releases.
We are considering adding the
-3
argument to our python 2 build, this should highlight problems in master which can be made compatible with both 2 and 3. This will reduce the burden of merges, however it is likely to push some risk back into prior releases.
Hmm, this seems like an interesting idea, though I wonder whether py2exe can deal wit this while freezing the code. That needs to be found out. It is probably very trivial to add the -3 flag to test builds only, so release builds don't get affected.
I'm going to close this issue now, as I think it has served it's purpose. It has been superceded by the Python 3 project board
Hi,
This issue serves as an umbrella issue for several related issues, one of them being #7077.
Python 3 introduces changes to syntax and inner workings of Python. Some of the changes include:
Upgrading to Python 3 will require huge coordination, as NVDA developers, add-on writers, translators, users and others will need to adapt new attitudes, assumptions and so on. In terms of dependencies, the only thing left is SCons (wxPython is discussed in #7077).
Thanks.