2

Possible Duplicate:
How to display current working copy version of an hg repository on a PHP page

Similar to How can I rewrite python __version__ with git?, what it is the best method to store an automatically updated version number inside a python file?

How good is my method of embedding version numbers into my application using Mercurial hooks? and the Mercurial keyword plan make it clear the svn-style method of automatically updating $Revision$ or $Id$ is not desirable and that the build system should do that work instead. This is python though, there is no build system and this is for a small program wholly contained in one file, so there is no packaging.

Community
  • 1
  • 1
matt wilkie
  • 17,268
  • 24
  • 80
  • 115
  • 1
    You're using Python, but I asked [a similar question](http://stackoverflow.com/questions/6005751/how-to-display-current-working-copy-version-of-an-hg-repository-on-a-php-page) for PHP and got what I thought was a pretty good answer, it should be usable for what you're trying. – Jimmy Sawczuk Sep 15 '11 at 05:48
  • well that's what a I get for making my search language specific when the problem was really language agnostic ;-) Thanks. – matt wilkie Sep 19 '11 at 22:09

1 Answers1

2

You can always add a build system, no matter which language you write your program in. You might say "but language X doesn't need a build system", but this question shows that it does: it needs it for those repetitive tasks that needs to be done before any release. This is tasks like building the documentation, running tests, and uploading the result somewhere.

A simple Makefile or a shell script is enough:

all: version

version:
    hg id > __version__

test: version
    @echo -n "running tests... "
    @sleep 1
    @echo " done."

doc: version
    @echo -n "building documentation... "
    @sleep 1
    @echo "done."

upload: test doc
    @echo -n "creating tarball... "
    @sleep 1
    @echo "done."
    @echo -n "publishing on website... "
    @sleep 1
    @echo "done."

.PHONY: version test upload doc
Martin Geisler
  • 72,968
  • 25
  • 171
  • 229