automaticly update `__version__` with mercurial? [duplicate]
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 开发者_StackOverflowwork 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.
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
精彩评论