# HG changeset patch # User Thomas Arendsen Hein # Date 2006-03-19 20:26:58 # Node ID 7eb694a1c1af6bb8250c84f96ca98ee63e59a33c # Parent df8416346bb76a9154c24a28bfd13af2aa12fcbd Don't forget version at the end of setup.py, write it only if changed. This fixes issue159: "python setup.py install" shouldn't write new files in the working dir if one has done "python setup.py build" first. diff --git a/mercurial/version.py b/mercurial/version.py --- a/mercurial/version.py +++ b/mercurial/version.py @@ -28,8 +28,15 @@ def get_version(): def write_version(version): """Overwrite version file.""" - filename = os.path.join(os.path.dirname(__file__), '__version__.py') - f = open(filename, 'w') + if version == get_version(): + return + directory = os.path.dirname(__file__) + for suffix in ['py', 'pyc', 'pyo']: + try: + os.unlink(os.path.join(directory, '__version__.%s' % suffix)) + except OSError: + pass + f = open(os.path.join(directory, '__version__.py'), 'w') f.write("# This file is auto-generated.\n") f.write("version = %r\n" % version) f.close() diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -72,35 +72,32 @@ class install_package_data(install_data) ('install_lib', 'install_dir')) install_data.finalize_options(self) -try: - mercurial.version.remember_version(version) - cmdclass = {'install_data': install_package_data} - py2exe_opts = {} - if py2exe_for_demandload is not None: - cmdclass['py2exe'] = py2exe_for_demandload - py2exe_opts['console'] = ['hg'] - setup(name='mercurial', - version=mercurial.version.get_version(), - author='Matt Mackall', - author_email='mpm@selenic.com', - url='http://selenic.com/mercurial', - description='Scalable distributed SCM', - license='GNU GPL', - packages=['mercurial', 'hgext'], - ext_modules=[Extension('mercurial.mpatch', ['mercurial/mpatch.c']), - Extension('mercurial.bdiff', ['mercurial/bdiff.c'])], - data_files=[('mercurial/templates', - ['templates/map'] + - glob.glob('templates/map-*') + - glob.glob('templates/*.tmpl')), - ('mercurial/templates/static', - glob.glob('templates/static/*'))], - cmdclass=cmdclass, - scripts=['hg', 'hgmerge'], - options=dict(bdist_mpkg=dict(zipdist=True, - license='COPYING', - readme='contrib/macosx/Readme.html', - welcome='contrib/macosx/Welcome.html')), - **py2exe_opts) -finally: - mercurial.version.forget_version() +mercurial.version.remember_version(version) +cmdclass = {'install_data': install_package_data} +py2exe_opts = {} +if py2exe_for_demandload is not None: + cmdclass['py2exe'] = py2exe_for_demandload + py2exe_opts['console'] = ['hg'] +setup(name='mercurial', + version=mercurial.version.get_version(), + author='Matt Mackall', + author_email='mpm@selenic.com', + url='http://selenic.com/mercurial', + description='Scalable distributed SCM', + license='GNU GPL', + packages=['mercurial', 'hgext'], + ext_modules=[Extension('mercurial.mpatch', ['mercurial/mpatch.c']), + Extension('mercurial.bdiff', ['mercurial/bdiff.c'])], + data_files=[('mercurial/templates', + ['templates/map'] + + glob.glob('templates/map-*') + + glob.glob('templates/*.tmpl')), + ('mercurial/templates/static', + glob.glob('templates/static/*'))], + cmdclass=cmdclass, + scripts=['hg', 'hgmerge'], + options=dict(bdist_mpkg=dict(zipdist=True, + license='COPYING', + readme='contrib/macosx/Readme.html', + welcome='contrib/macosx/Welcome.html')), + **py2exe_opts)