3

We are deploying Plone add-ons as development eggs with buildout. The eggs are pushed to the production as source code checkouts using Mr. Developer buildout recipe and .egg packaging is not done in any point.

What would be best way to automatically update setup.py version stamp on every SVN commit to SVN release number or timestamp? This would give some quick info of tracking of different packages.

Distutils seem to offer some kind of magic version stamping mechanism, but I did not found any reference documentation how this should be used.

jsbueno
  • 99,910
  • 10
  • 151
  • 209
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • 1
    Duplicate of [getting-svn-revision-number-into-a-program-automatically](http://stackoverflow.com/questions/1449935/getting-svn-revision-number-into-a-program-automatically) ?! – gecco Dec 13 '11 at 10:16

3 Answers3

6

Add something like this in setup.cfg:

[egg_info]
tag_build = .dev
tag_svn_revision = 1

This only works for subversion of course; not sure if there are alternatives for other vcs. This file may still be added by default by some of the ZopeSkel templates. Some plone packages have it too; Wichert Akkerman is/was a fan of it.

Note that you do need to run bin/buildout or python setup.py egg_info every time to commit something, else the version info in the egg-info directory is not updated.

maurits
  • 2,355
  • 13
  • 16
  • Watch out, though, when releasing the package to pypi if you use this method. Don't forget to remove the lines from setup.cfg before releasing. There are too many mypackage-1.2-r1234.tar.gz packages... – Reinout van Rees Dec 13 '11 at 12:39
1

You can use simply the SVN Keywords, like

__version__ = "$Rev:$"

SVN automatically changes with this keyword the version on every filechange respectively commit.

gecco
  • 17,969
  • 11
  • 51
  • 68
Themerius
  • 1,861
  • 1
  • 19
  • 33
  • 2
    This will work fine for every commit to setup.py (assuming you put this line into setup.py). It won't update itself when you commit another file. – Reinout van Rees Dec 13 '11 at 12:37
  • 1 - Use correct SVN-keyword, for revision it's **$Revision$**, not your scrap 2 - expanded revision keyword *isn't pure numeric revision* only, it seems like such `$Revision: 1132 $` and **require post-processing** 3 - Keyword show file's last-change revision, not repo-wide last-commit revision. *Bad, you must redone your homework and RTFM* – Lazy Badger Dec 13 '11 at 15:16
0

What would be best way to automatically update setup.py version stamp on every SVN commit to SVN release number or timestamp?

If

  • build process can execute some actions (I'm too lazy to read buildout recipe)
  • using additional Windows-only tools isn't strong "no-no" for you

you can consider to use SubWCRev cli-tool from TortoiseSVN package. It (slightly) change current workflow:

  • instead of real setup.py repository store template of setup.py, where dynamic part of data replaced by SubWCRev-keywords (they can handle revision, date in free form)
  • Every build-process have to regenerate actual setup.py by calling subwcrev against (local) working copy with predefined setup-template
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110