开发者

automaticly update `__version__` with mercurial? [duplicate]

开发者 https://www.devze.com 2023-04-05 04:26 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: How to display current working copy version of an hg repository on a PHP page
This question already has an answer here: Closed 11 years ago.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号