Greg Ward wrote:
On 21 September 2000, Mike Olson said:
There were a couple of spots were if we could abstract core distutils code into a function call (that we could override) it would make our lives that much nicer. Ex, I needed on little hook into install_lib.run (after the build and before the copy), but I had to reproduce the entire function call...
OK, I've split install_lib.run() up. It's now a three-liner:
self.build() outfiles = self.install() self.bytecompile(outfiles)
and I have no problems with making people cut-n-paste three lines of code in order to insert one. ;-) I *think* this approach is preferable to sticking in "pre_build()" and "post_install()" hooks, which are empty methods by default.
Try this out with the CVS version, but don't count on the interface staying the same -- ie. that 'bytecompile()' method might disappear, if byte-compilation moves to the build phase. Whatever goes out in 0.9.3 should be final.
This looks like it will help, I'll try out the latest CVS version today yet.
another really useful thing for us on copy_file would be if the function told you if the file was copied....
Hmm, every time this comes up I can never remember why I didn't change it the last time around. Or maybe I did change it last time, and now you want the old behaviour back. Argh! Good thing I have CVS here to cover my you-know-what... ah! here we go:
revision 1.4 date: 2000/06/23 01:42:40; author: gward; state: Exp; lines: +6 -7 Bastian Kleineidam: 'copy_file()' now returns the output filename, rather than a boolean indicating whether it did the copy.
This bloody return value has bounced back and forth between "was it copied?" and "output filename", and I'm *not* changing it again! It makes my head hurt, which is not worth it over such a silly, trivial little thing. There is code out there that relies on getting the output filename back, regardless of whether the file was copied or not.
I've noticed the code that relies on copy_file returning the dest file. I also understand the need to have that code in place. However, (even though this could be a futile attmept), what about returning a tuple, best of both worlds, or even better, a new interface that returns the tuple. Rename copy_file to the new interface name and modify it to return the tuple of dest name and a boolean copied flag. Then recreate the function copy_file to work as it does..... def new_copy_file(src,dest,....): return (dest,copied) def copy_file(src,dest,....): return new_copy_file(src,dest,...)[0] We'd also want to do the same for copy_tree where is can return a list of tuples.... Just a thought... Mike
Greg
-- Mike Olson Principal Consultant mike.olson@fourthought.com (303)583-9900 x 102 Fourthought, Inc. http://Fourthought.com Software-engineering, knowledge-management, XML, CORBA, Linux, Python