您打算如何处理向Python 3的迁移? [英] How are you planning on handling the migration to Python 3?

查看:70
本文介绍了您打算如何处理向Python 3的迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到Python 3即将问世,我确定这是大多数python开发人员都想到的主题.一些使我们朝正确方向前进的问题:

  1. 您将同时维护python 2和python 3版本,还是在完成后仅拥有python 3版本?

    • 您是否已经开始或计划很快开始?还是您打算等到最终版本全面推出为止?

解决方案

以下是Twisted的总体规划.我原本打算为此写博客,但后来我想:为什么我可以为此获得,为什么还要为此博客呢?

  1. 等待直到有人关心.

    现在,没有人拥有Python3.在至少有一个实际用户说我需要Python 3.0支持"之前,我们不会花费很多精力,除了有充分的理由之外, 3.0看起来很有光泽.

  2. 等待,直到我们的依赖项迁移完毕.

    像Twisted这样的大型系统具有许多依赖性.首先,我们的产品包括:

    其中一些项目具有自己的依赖项数组,因此我们也必须等待这些依赖项.

  3. 等待,直到有人关心足够的来帮助.

    慈善地,有5个人从事Twisted的工作-我说慈善"是因为这很重要,而我几个月来都没有做出承诺.我们现在有超过1000张公开门票,而实际上可以解决其中的一些问题将是一件很不错的事情-修复错误,添加功能,并通常使Twisted本身成为更好的产品-在花时间将其移植到该语言的实质性新版本之前.

    这可能包括赞助商足够支付我们这样做的费用,但我希望会有大量的志愿者关心3.0的支持,并希望帮助推动社区向前发展.

  4. 按照Guido的建议.

    这意味着 我们不会不兼容地更改我们的API ,我们将遵循过渡开发Guido去年发布的准则.首先要进行单元测试,然后在Twisted代码库上运行 2to3转换工具. /p>

  5. 报告针对2to3工具的错误和文件补丁.

    当我们到达实际使用的地步时,我预计将来运行2to3会遇到很多问题.现在在Twisted上运行它需要花费很长时间,并且(最后一次检查,是我前一段时间)无法解析Twisted存储库中的一些文件,因此不会导入结果.我认为,在小型项目对我们真正起作用之前,必须有大量来自小型项目的成功案例,并且需要大量投入.

    但是,Python开发团队在响应我们的错误报告方面非常有帮助,并且对这些问题的早期响应令人鼓舞,因此我希望所有这些问题都将得到及时解决.

  6. 保持2.x兼容性几年.

    目前,Twisted支持python 2.3至2.5.目前,我们正在开发2.6支持(显然,我们必须在3.0之前完成!).我们的计划是基于 Ubuntu 的长期受支持版本,修订受支持的Python版本. -包含Python 2.5的8.04版将在2013年之前得到支持.根据Guido的建议,我们需要放弃对2.5的支持才能支持3.0,但我希望我们可以找到解决方法(版本兼容性黑客).

    因此,我们计划至少在2013年之前支持Python 2.5.在两年内,Ubuntu将发布另一个受长期支持的Ubuntu版本:如果它们仍然存在并按计划进行,则将为10.04.我个人认为这将随Python 2.x(也许是python 2.8)一起以/usr/bin/python的形式提供,因为该发行版中打包了大量的Python软件,并且要花很长时间才能全部更新.因此,距 then 的五年时间,即2015年,我们可以开始考虑放弃2.x支持.

    在此期间,我们将继续遵循Guido关于迁移的建议:在我们的2.x代码库上运行2to3,并修改2.x代码库以使其测试在两个版本中均通过.

    其结果是,直到我35岁生日后,Python 3.x才成为Twisted的语言-这将是目标运行时(以及一系列准则和限制)用于我的python 2.x代码.我希望在未来十年左右的时间内使用Python 2.x编写程序.

所以,这就是计划.我希望它可以在一年左右的时间里变得保守起来可笑. 3.x过渡很容易,每个人都可以快速升级.其他事情也可能发生:2.x和3.x分支可能会收敛,有人可能最终写了3to2,或者另一个运行时(想到PyPy)可能允许运行2.x和3.x代码.直接在同一过程中进行,使我们的转换过程更加容易.

但是,我们暂时假设,多年来,我们将拥有正在维护的具有大型代码库的人(或者正在编写要使用 other 库的新代码的人)尚未迁移的人),他们仍然需要Twisted中的新功能和错误修复.很快我希望我们还会有一些尖端的用户,他们希望在python 3上使用Twisted.我希望为所有这些人提供尽可能长的积极体验.

I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction:

  1. Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished?

    • Have you already started or plan on starting soon? Or do you plan on waiting until the final version comes out to get into full swing?

解决方案

Here's the general plan for Twisted. I was originally going to blog this, but then I thought: why blog about it when I could get points for it?

  1. Wait until somebody cares.

    Right now, nobody has Python 3. We're not going to spend a bunch of effort until at least one actual user has come forth and said "I need Python 3.0 support", and has a good reason for it aside from the fact that 3.0 looks shiny.

  2. Wait until our dependencies have migrated.

    A large system like Twisted has a number of dependencies. For starters, ours include:

    Some of these projects have their own array of dependencies so we'll have to wait for those as well.

  3. Wait until somebody cares enough to help.

    There are, charitably, 5 people who work on Twisted - and I say "charitably" because that's counting me, and I haven't committed in months. We have over 1000 open tickets right now, and it would be nice to actually fix some of those — fix bugs, add features, and generally make Twisted a better product in its own right — before spending time on getting it ported over to a substantially new version of the language.

    This potentially includes sponsors caring enough to pay for us to do it, but I hope that there will be an influx of volunteers who care about 3.0 support and want to help move the community forward.

  4. Follow Guido's advice.

    This means we will not change our API incompatibly, and we will follow the transitional development guidelines that Guido posted last year. That starts with having unit tests, and running the 2to3 conversion tool over the Twisted codebase.

  5. Report bugs against, and file patches for, the 2to3 tool.

    When we get to the point where we're actually using it, I anticipate that there will be a lot of problems with running 2to3 in the future. Running it over Twisted right now takes an extremely long time and (last I checked, which was quite a while ago) can't parse a few of the files in the Twisted repository, so the resulting output won't import. I think there will have to be a fair amount of success stories from small projects and a lot of hammering on the tool before it will actually work for us.

    However, the Python development team has been very helpful in responding to our bug reports, and early responses to these problems have been encouraging, so I expect that all of these issues will be fixed in time.

  6. Maintain 2.x compatibility for several years.

    Right now, Twisted supports python 2.3 to 2.5. Currently, we're working on 2.6 support (which we'll obviously have to finish before 3.0!). Our plan is to we revise our supported versions of Python based on the long-term supported versions of Ubuntu - release 8.04, which includes Python 2.5, will be supported until 2013. According to Guido's advice we will need to drop support for 2.5 in order to support 3.0, but I am hoping we can find a way around that (we are pretty creative with version-compatibility hacks).

    So, we are planning to support Python 2.5 until at least 2013. In two years, Ubuntu will release another long-term supported version of Ubuntu: if they still exist, and stay on schedule, that will be 10.04. Personally I am guessing that this will ship with Python 2.x, perhaps python 2.8, as /usr/bin/python, because there is a huge amount of Python software packaged with the distribution and it will take a long time to update it all. So, five years from then, in 2015, we can start looking at dropping 2.x support.

    During this period, we will continue to follow Guido's advice about migration: running 2to3 over our 2.x codebase, and modifying the 2.x codebase to keep its tests passing in both versions.

    The upshot of this is that Python 3.x will not be a source language for Twisted until well after my 35th birthday — it will be a target runtime (and a set of guidelines and restrictions) for my python 2.x code. I expect to be writing programs in Python 2.x for the next ten years or so.

So, that's the plan. I'm hoping that it ends up looking laughably conservative in a year or so; that the 3.x transition is easy as pie, and everyone rapidly upgrades. Other things could happen, too: the 2.x and 3.x branches could converge, someone might end up writing a 3to2, or another runtime (PyPy comes to mind) might allow for running 2.x and 3.x code in the same process directly, making our conversion process easier.

For the time being, however, we're assuming that, for many years, we will have people with large codebases they're maintaining (or people writing new code who want to use other libraries which have not yet been migrated) who still want new features and bug fixes in Twisted. Pretty soon I expect we will also have bleeding-edge users that want to use Twisted on python 3. I'd like to provide all of those people with a positive experience for as long as possible.

这篇关于您打算如何处理向Python 3的迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆