|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
SLOOW setup.py... now fasterHi there, I've been using Gourmet on and off for a while and there are a couple of wrinkles I'd love to have a go at fixing. So I cloned the latest git tree (ye gods, there are some big files in there!) and, as instructed, ran setup.py. And waited. On this (debian) box at least, intltool-merge is more than a little slow. And it's called once per plugin on each update. So I've put together a little patch that avoids re-merging stuff we've done already. I realise that it doesn't check for whether the locale has changed from last time we ran. If that matters, we could cache that info, I suppose? Anyway, here it is. Hope it's some use. Rupert PS. Is this the correct place to post this message? PPS. I'm new to python, coming from a lisp background, so please point out stylistic no-no's! From 1717bdb71042bb3da50f6f9f16afb2321dea921c Mon Sep 17 00:00:00 2001 From: Rupert Swarbrick <rswarbrick@...> Date: Fri, 29 May 2009 17:21:25 +0100 Subject: [PATCH] Cache the results of intltool-merge to avoid taking so long in setup.py. --- setup.py | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 33e0496..17d0ae3 100644 --- a/setup.py +++ b/setup.py @@ -7,13 +7,21 @@ import sys import glob import os.path import os +from stat import ST_MTIME -for desktop_file in ['gourmet.desktop.in'] + glob.glob('src/lib/plugins/*plugin.in') + glob.glob('src/lib/plugins/*/*plugin.in'): - #print 'intltool-merge -d i18n/ %s %s'%(desktop_file, - # desktop_file[:-3]) - os.system('intltool-merge -d i18n/ %s %s'%(desktop_file, - desktop_file[:-3]) - ) +def maybe_intltool(fname): + '''Check whether the file at fname has been updated since + intltool-merge was last used on it. If it has, then use + intltool-merge to update the output file.''' + to_name = fname[:-3] + if ( (not os.path.exists(to_name)) or + os.stat(to_name)[ST_MTIME] < os.stat(fname)[ST_MTIME] ): + os.system('intltool-merge -d i18n/ %s %s'%(fname, to_name)) + + +map(maybe_intltool, ['gourmet.desktop.in'] + \ + glob.glob('src/lib/plugins/*plugin.in') + \ + glob.glob('src/lib/plugins/*/*plugin.in')) #from distutils.core import setup from tools.gourmet_distutils import setup -- 1.6.3.1 ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Grecipe-manager-devel mailing list Grecipe-manager-devel@... https://lists.sourceforge.net/lists/listinfo/grecipe-manager-devel |
|
|
Re: SLOOW setup.py... now fasterAnyway, here it is. Hope it's some use. Definitely saves some time when testing the installation -- thanks!
This is a fine place to post it. You can also post patches to SF here: http://sourceforge.net/tracker/?group_id=108118&atid=649654 PPS. I'm new to python, coming from a lisp background, so please point The only no-no's I saw were pretty minor... 1. Conventionally, you leave a space before the parentheses in a function definition, which differentiates it from a function call. def foo (bar, baz): ... but foo(bar, baz) 2. map(...) is a lisp import to python and not really "pythonic" (Guido's said to not like them and be planning to axe them). In this case, I just changede it back to a for loop for more clarity (to a python eye, anyway). When you need to handle lists in a compact way in python, you usually just use list comprehension instead... for example, [foo(a) for a in lst] instead of map(foo,lst) I'll be applying your patch momentarily! Thanks! Tom
------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Grecipe-manager-devel mailing list Grecipe-manager-devel@... https://lists.sourceforge.net/lists/listinfo/grecipe-manager-devel |
| Free embeddable forum powered by Nabble | Forum Help |