On 04/16/2013 08:44 PM, Gene Czarcinski wrote: > 1. The added suffix is in the form YYYYMMDD and that is all. > > 2. Code is added to classes my_sdist and my_rpm to check if > a snapshot id is requested (--snapshot or -s) and, if > requested, to append the id to the value of cliconfig.__version__ > > 3. The added suffix only applies to the name of the sdist-tarball > and the rpm spec file it includes ... the "internal" version > remains unchanged. > . > Signed-off-by: Gene Czarcinski <gene@xxxxxxxxx> > --- > setup.py | 41 +++++++++++++++++++++++++++++++++-------- > virtcli/cliconfig.py | 2 ++ > 2 files changed, 35 insertions(+), 8 deletions(-) > > diff --git a/setup.py b/setup.py > index 167caf6..54d8299 100644 > --- a/setup.py > +++ b/setup.py > @@ -8,6 +8,7 @@ import fnmatch > import os > import sys > import unittest > +from datetime import date > > from distutils.core import Command, setup > from distutils.command.sdist import sdist > @@ -181,19 +182,40 @@ class my_install(install): > > install.finalize_options(self) > > -class my_sdist(sdist_auto, sdist): > - user_option = [] > +# Note: cliconfig.__snapshot__ by default is 0, it can be set to 1 by > +# either sdist or rpm and then the snapshot suffix is appended. > + > +class my_sdist(sdist_auto): > + user_options=sdist.user_options + [ > + ("snapshot", "s", "add snapshot id to version")] > + > + boolean_options=sdist.boolean_options + ["snapshot"] > + > description = "Update virt-manager.spec; build sdist-tarball." > > + def initialize_options(self): > + self.snapshot = None > + sdist.initialize_options(self) > + > + def finalize_options(self): > + if self.snapshot is not None: > + self.snapshot = 1 > + cliconfig.__snapshot__ = 1 > + sdist.finalize_options(self) > + > def run(self): > ver = cliconfig.__version__ > + if cliconfig.__snapshot__ == 1: > + ver = ver + '.' + date.today().isoformat().replace('-', '') > + cliconfig.__version__ = ver > + setattr(self.distribution.metadata, 'version', ver) > f1 = open('virt-manager.spec.in', 'r') > f2 = open('virt-manager.spec', 'w') > for line in f1: > f2.write(line.replace('@VERSION@', ver)) > f1.close() > f2.close() > - sdist.run(self) > + sdist_auto.run(self) > Thanks Gene, I applied this series. There's still a little weirdness here though, subclassing sdist_auto but calling sdist.finalize_options, etc. I pushed an addon commit that fixed that up, and fixed up some 'python setup.py pylint' output as well. rpm building with and without --snapshot seem to work fine, but please confirm. https://git.fedorahosted.org/cgit/virt-manager.git/commit/?id=52d9436c3b35a7d46f5110a2d035362c0c3cd9cc Thanks, Cole _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list