MCPcopy Create free account
hub / github.com/numpy/numpy / make_svn_version_py

Method make_svn_version_py

numpy/distutils/misc_util.py:2027–2066  ·  view source on GitHub ↗

Appends a data function to the data_files list that will generate __svn_version__.py file to the current package directory. Generate package __svn_version__.py file from SVN revision number, it will be removed after python exits but will be available when sdist, etc

(self, delete=True)

Source from the content-addressed store, hash-verified

2025 return version
2026
2027 def make_svn_version_py(self, delete=True):
2028 """Appends a data function to the data_files list that will generate
2029 __svn_version__.py file to the current package directory.
2030
2031 Generate package __svn_version__.py file from SVN revision number,
2032 it will be removed after python exits but will be available
2033 when sdist, etc commands are executed.
2034
2035 Notes
2036 -----
2037 If __svn_version__.py existed before, nothing is done.
2038
2039 This is
2040 intended for working with source directories that are in an SVN
2041 repository.
2042 """
2043 target = njoin(self.local_path, '__svn_version__.py')
2044 revision = self._get_svn_revision(self.local_path)
2045 if os.path.isfile(target) or revision is None:
2046 return
2047 else:
2048 def generate_svn_version_py():
2049 if not os.path.isfile(target):
2050 version = str(revision)
2051 self.info('Creating %s (version=%r)' % (target, version))
2052 with open(target, 'w') as f:
2053 f.write('version = %r\n' % (version))
2054
2055 def rm_file(f=target,p=self.info):
2056 if delete:
2057 try: os.remove(f); p('removed '+f)
2058 except OSError: pass
2059 try: os.remove(f+'c'); p('removed '+f+'c')
2060 except OSError: pass
2061
2062 atexit.register(rm_file)
2063
2064 return target
2065
2066 self.add_data_files(('', generate_svn_version_py()))
2067
2068 def make_hg_version_py(self, delete=True):
2069 """Appends a data function to the data_files list that will generate

Callers 1

configurationFunction · 0.95

Calls 3

_get_svn_revisionMethod · 0.95
add_data_filesMethod · 0.95
njoinFunction · 0.85

Tested by

no test coverage detected