[Numpy-discussion] Adding a delete flag to make_svn_version_py() in distutils
Tim Leslie
tim.leslie at gmail.com
Sun Mar 4 04:15:58 EST 2007
Hi All,
I've got a small patch which I thought I'd run past the list before
checking in. While working on the NIPY project
(http://neuroimaging.scipy.org/) we spend a lot of time working from a
local source install, rather than a version installed in
site-packages. The mechanism which lets you do things like
numpy.__version__ and neuroimaging.__version__ and have it show the
svn version e.g.
In [3]: neuroimaging.__version__
Out[3]: '0.1.2.dev1570'
requires the file __svn_version__.py to be in the tree. Currently this
file is deleted automatically. The patch adds a flag which makes
deleting this file optional (with delete=True being default). This
makes the svn version magic work for us and shouldn't break any
existing code for anyone, Is there any reason why this shouldn't go
in? I'm happy to make the checkin once it gets the OK from someone.
Cheers,
Tim Leslie
Index: numpy/distutils/misc_util.py
===================================================================
--- numpy/distutils/misc_util.py (revision 3567)
+++ numpy/distutils/misc_util.py (working copy)
@@ -1304,7 +1304,7 @@
return version
- def make_svn_version_py(self):
+ def make_svn_version_py(self, delete=True):
""" Generate package __svn_version__.py file from SVN revision number,
it will be removed after python exits but will be available
when sdist, etc commands are executed.
@@ -1326,10 +1326,12 @@
import atexit
def rm_file(f=target,p=self.info):
- try: os.remove(f); p('removed '+f)
- except OSError: pass
- try: os.remove(f+'c'); p('removed '+f+'c')
- except OSError: pass
+ if delete:
+ try: os.remove(f); p('removed '+f)
+ except OSError: pass
+ try: os.remove(f+'c'); p('removed '+f+'c')
+ except OSError: pass
+
atexit.register(rm_file)
return target
More information about the NumPy-Discussion
mailing list