Changeset 1675589 in git


Ignore:
Timestamp:
2012-03-13T02:42:54Z (13 years ago)
Author:
Zooko O'Whielacronx <zooko@…>
Branches:
master
Children:
4e43e1c
Parents:
6b21e80
git-author:
Zooko O'Whielacronx <zooko@…> (2012-03-12 02:01:26)
git-committer:
Zooko O'Whielacronx <zooko@…> (2012-03-13 02:42:54)
Message:

don't run versioneer at runtime

don't run versioneer whenever importing pycryptopp at runtime, instead depend on a fixed version number in _version.py.
This means the _version.py can be stale between when you change something in git (including dirtying the working directory tree) and when you next run "python setup.py update_version" or any of the setup.py commands which setup.cfg links to update_version.
This is less functionality, but there was at least one bug in the more functional version that I don't want to work on right now (why wasn't the _version.py inside the ./build/ directory not getting updated on "python setup.py install"), and also I'm a bit uncomfortable with all of that Python code and that interaction with the system (invoking git) at runtime.

Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified .gitignore

    r6b21e80 r1675589  
    55# extraversion.h is generated at build time, and never checked in
    66/src-cryptopp/extraversion.h
     7/src/pycryptopp/_version.py
    78
    89# the .egg-info is mostly generated during 'setup.py bdist_egg' ..
  • TabularUnified setup.py

    r6b21e80 r1675589  
    247247data_files = [(doc_loc, data_fnames)]
    248248
    249 commands = versioneer.get_cmdclass().copy()
     249commands = {}
    250250
    251251###### Version updating code
     
    271271    return normalized_version
    272272
     273def read_version_py(infname):
     274    try:
     275        verstrline = open(infname, "rt").read()
     276    except EnvironmentError:
     277        return None
     278    else:
     279        VSRE = r"^verstr = ['\"]([^'\"]*)['\"]"
     280        mo = re.search(VSRE, verstrline, re.M)
     281        if mo:
     282            return mo.group(1)
     283
     284VERSION_BODY = '''
     285# This is the version of this tree, as created by %(versiontool)s from the darcs patch
     286# information: the main version number is taken from the most recent release
     287# tag. If some patches have been added since the last release, this will have a
     288# -NN "build number" suffix, or else a -rNN "revision number" suffix. Please see
     289# pyutil.version_class for a description of what the different fields mean.
     290
     291__pkgname__ = "%(pkgname)s"
     292verstr = "%(pkgversion)s"
     293try:
     294    from pyutil.version_class import Version as pyutil_Version
     295    __version__ = pyutil_Version(verstr)
     296except (ImportError, ValueError):
     297    # Maybe there is no pyutil installed.
     298    from distutils.version import LooseVersion as distutils_Version
     299    __version__ = distutils_Version(verstr)
     300'''
    273301
    274302class UpdateVersion(Command):
     
    291319                  "full": versions["full"] })
    292320        f.close()
    293         print "git-version: wrote '%s' into '%s'" % (versions["version"], fn)
     321        self.write_version_py(get_normalized_version(), os.path.join('src', 'pycryptopp', '_version.py'), "pycryptopp's setup.py", VERSION_BODY, 'pycryptopp')
     322        print "git-version: wrote '%s' into '%s' and '%s'" % (versions["version"], fn, os.path.join('src', 'pycryptopp', '_version.py'))
     323
     324    def write_version_py(self, verstr, outfname, EXE_NAME, version_body, pkgname):
     325        f = open(outfname, "wb+")
     326        f.write(version_body % {
     327                'versiontool': EXE_NAME,
     328                'pkgversion': verstr,
     329                'pkgname': pkgname,
     330                })
     331        f.close()
     332
    294333commands["update_version"] = UpdateVersion
    295334
     
    318357
    319358setup(name=PKG,
    320       version=get_normalized_version(),
     359      version=read_version_py(os.path.join('src', 'pycryptopp', '_version.py')),
    321360      description='Python wrappers for a few algorithms from the Crypto++ library',
    322361      long_description=readmetext,
  • TabularUnified src/pycryptopp/__init__.py

    r6b21e80 r1675589  
    22pycryptopp - Python wrappers for Crypto++
    33"""
    4 
    5 def _build_versions():
    6     from pycryptopp._version import get_versions
    7     versions = get_versions()
    8     # versions_from_git (as copied from python-versioneer) returns strings
    9     # like "1.9.0-25-gb73aba9-dirty", which means we're in a tree with
    10     # uncommited changes (-dirty), the latest checkin is revision b73aba9,
    11     # the most recent tag was 1.9.0, and b73aba9 has 25 commits that weren't
    12     # in 1.9.0 . The narrow-minded NormalizedVersion parser that takes our
    13     # output (meant to enable sorting of version strings) refuses most of
    14     # that, but accepts things like "1.9.0.post25", or "1.9.0.post25.dev0",
    15     # so dumb down our output to match.
    16     pieces = versions["version"].split("-")
    17     if len(pieces) == 1:
    18         normalized_version = pieces[0]
    19     else:
    20         normalized_version = "%s.post%s" % (pieces[0], pieces[1])
    21     if pieces[-1] == "dirty":
    22         normalized_version += ".dev0"
    23     # this returns e.g.:
    24     #  0.5.29.post51,
    25     #  0.5.29-51-ga81fad1,
    26     #  a81fad1d4afae353a40cf56fe88aa6ef0eea31a8
    27     return versions["version"], normalized_version, versions["full"]
    28 __real_version__, __version__, __full_version__ = _build_versions()
    29 del _build_versions
    304
    315# we import our glue .so here, and then other modules use the copy in
     
    348import _pycryptopp
    359__doc__ = _pycryptopp.__doc__
     10__version__ = _pycryptopp.__version__
    3611
    3712def _import_my_names(thismodule, prefix):
Note: See TracChangeset for help on using the changeset viewer.