From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 330971381F3 for ; Mon, 20 May 2013 21:06:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3D1F8E080C; Mon, 20 May 2013 21:06:15 +0000 (UTC) Received: from mpv2.tis.cwru.edu (mpv2.tis.CWRU.Edu [129.22.105.37]) (using TLSv1 with cipher DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AC60DE0805 for ; Mon, 20 May 2013 21:06:14 +0000 (UTC) Received: from mpv6.tis.CWRU.Edu (EHLO mpv6.cwru.edu) ([129.22.104.221]) by mpv2.tis.cwru.edu (MOS 4.3.5-GA FastPath queued) with ESMTP id ALN80123; Mon, 20 May 2013 17:06:09 -0400 (EDT) Received: from mail-qa0-f42.google.com (EHLO mail-qa0-f42.google.com) ([209.85.216.42]) by mpv6.cwru.edu (MOS 4.3.3-GA FastPath queued) with ESMTP id BQJ73383; Mon, 20 May 2013 17:06:13 -0400 (EDT) Received: by mail-qa0-f42.google.com with SMTP id bs12so1787009qab.8 for ; Mon, 20 May 2013 14:06:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-received:message-id:date:from:user-agent:mime-version :to:subject:content-type:content-transfer-encoding :x-gm-message-state; bh=vvcNJBkXYiH0lJ71oUGyvJRo/jOT8w8P/JS8S9Y8rO0=; b=exW2XF+mN5qNso+87kSyU9byh+rzICjLv8tq9Ey4ZirBdBiJb1AZkkHVQRMfd95PHV HaqD8Bon/9zXAGx6bXtczR6Lyp4eyAX4SltUQnWd2ztoRVDz1izVRlFYF5BKjf52JWjP npx2QQa80t05ARoQrIwMber+43XtL+BRd/Mk7R4frxR6f8jYq79fKopxc3GHg6wsi8s9 1xFiI466dHV0bGU1/gXpnW7+RiUpwrmLjGywqQZuI6duADkmM1SsmdQ9zMIknibZHyJ0 G9wlJsFwS5TNjCvJMdq1O2mHwjocq/a3/kAWhJIeqHngyJBndoP34Q+7jqivxjxgVIAa Cfig== X-Received: by 10.224.34.198 with SMTP id m6mr50109406qad.39.1369083973629; Mon, 20 May 2013 14:06:13 -0700 (PDT) X-Received: by 10.224.34.198 with SMTP id m6mr50109398qad.39.1369083973544; Mon, 20 May 2013 14:06:13 -0700 (PDT) Received: from [129.22.151.147] (giygas.STUDENT.CWRU.Edu. [129.22.151.147]) by mx.google.com with ESMTPSA id d5sm7951514qel.4.2013.05.20.14.06.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 May 2013 14:06:12 -0700 (PDT) Message-ID: <519A9044.2050104@case.edu> Date: Mon, 20 May 2013 17:06:12 -0400 From: Matthew Ruffalo User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org MIME-Version: 1.0 To: gentoo-catalyst@lists.gentoo.org Subject: [gentoo-catalyst] Python 3 support Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnmsA7CoXFvrj+70z1a7oHJRU7fuFbXX/03Zzo/MRoJd99RZ3pbWFwTs/3+yvWY5aT6aTM3WpDr3jiLHyNJ+dlB4YlzJ7JO8DTGbRuV2PD+GU9BgODz/2pxqg0tnuh8a/CyWLELHTtLezQEjVCts/tyZCtFwBYmSEhrbPrIN104o8p6uG4= X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu) X-Archives-Salt: b496897f-8182-48a9-a4c8-4c4207a4782a X-Archives-Hash: 0cac9f2b5f394e460855738843d4b647 Hi all- First, thanks for the great tool. I've been using Gentoo for about 10 years, and I use Catalyst to build custom Gentoo live CDs that contain extra software (e.g. netcat6, rsync, ddrescue, etc.). At some point in the past the stage3 tarballs only contained Python 3, though it looks like the 20130516 amd64 stage3 contains both 2.7 and 3.2. It's reasonable to assume that any current Gentoo system has a Python 3.2+ interpreter, so is there any objection to making Catalyst work on Python 3? The fewer things in the world that depend on Python 2, the better (in my opinion). Portage has supported Python 3 for some time and it makes sense for Catalyst to follow suit. I use Python 3 for all of my own work and have a reasonable amount of experience porting projects to Python 3. This typically involves a lot of code churn even when there aren't any logic changes -- every print statement has to be converted to calling the print function, for instance. Explicit conversion between bytes and str can require a bit more thought but isn't difficult. This conversion might require other miscellaneous cleanup, including some whitespace-only commits. Python 3 does not allow mixing tabs and spaces for indentation, and (e.g.) catalyst_support.py is a *mess* with indentation. PyCharm also notices things like unnecessary "\" line continuation characters, unused variables, mutable default arguments (e.g. catalyst_support.spawn's "env"), equality comparisons against None, and unreachable code (lines 183 - 220 of catalyst_lock.py). It looks like the project has mostly standardized on using tabs for indentation, so that's what I'll use when changing indentation is necessary. In any case, over the next few weeks/months I'll prepare a series of patches in decreasing order of priority: 1. Changes required to run 2to3, like changing string exceptions (e.g. catalyst_lock.py:34) to 'raise Exception("message")' 2. Automated 2to3 conversion 3. Minimal indentation changes required for Python 3 to parse the code (as I mentioned, the diff of catalyst_support.py will still be quite large) 4. Any required bytes/str fixes and other things that 2to3 isn't smart enough to do on its own 5. Miscellaneous style tweaks (some of which are suggested by PEP 8), like: 1. using os.path.join where appropriate (e.g. grp_target.py:38, catalyst_lock.py:80) 2. using context managers ("with open(filename) as f:") 3. replacing mutable default function arguments 4. using argparse instead of getopt in the main catalyst script (maybe) 5. catching Exception instead of using a raw 'except:' -- probably don't want to catch SystemExit, StopIteration and KeyboardInterrupt in a lot of these places 6. Other PEP 8-inspired changes like using spaces around operators and function arguments The intention is that categories 1 through 4 would be the minimum set of changes required to make Catalyst run on Python 3. Categories 5 and 6 would be a mix of PEP 8 and newer Python idioms and applying these would be optional. I'm not a Gentoo developer and I'll be making a lot of small commits, so sharing my changes will probably be easiest by publishing a clone of the Catalyst repository on GitHub. (I plan to make/test/release all of these changes whether or not they'll make it in to Catalyst in the near future. Even if the Gentoo releng team doesn't care about supporting Python 3 now, having a working port available might make it easier to justify that change in the future :) ) Thanks for your time and any feedback, MMR... -- Matthew Ruffalo Department of Electrical Engineering and Computer Science Case Western Reserve University