From 5691e17738646b74086e09cd776212a2f55ad346 Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Fri, 25 Feb 2011 17:51:32 -0300 Subject: [PATCH] better sdist, use command for generating gitrev --- setup.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 41771618..7c52b7ef 100644 --- a/setup.py +++ b/setup.py @@ -3,9 +3,6 @@ from distutils.sysconfig import get_python_lib import os, os.path import sys -if 'sdist' in sys.argv and sys.platform != "win32" and os.path.isdir('.git'): - assert os.system("git show-ref -s HEAD > .gitrev") == 0 - if sys.platform == "darwin": # Don't create resource files on OS X tar. os.environ['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true' @@ -18,6 +15,15 @@ def add_command_class(name, cls): cmdclasses[name] = cls setup_args['cmdclass'] = cmdclasses +from distutils.command.sdist import sdist as sdist_orig +class sdist(sdist_orig): + def run(self): + if (sys.platform != "win32" and + os.path.isdir('.git')): + assert os.system("git show-ref -s HEAD > .gitrev") == 0 + sdist_orig.run(self) +add_command_class('sdist', sdist) + if sys.version_info[0] >= 3: import lib2to3.refactor from distutils.command.build_py \ -- 2.26.2