[PATCH] setup: get version number using pure Python modules

Pascal Quantin pascal.quantin at gmail.com
Thu Jan 29 15:12:11 CST 2009


Hi

your patch fails on my windows box (Win XP, python 2.5).
The code os.path.join('.', 'hg') produces the following command line:
.\hg id -it
which returns nothing (empty string) as ".\hg" is an invalid command on windows.

I propose to apply the following diff that should work for everybody:
-    cmd = '%s id -it' % os.path.join('.', 'hg')
+    if os.name == 'nt':
+        cmd = 'hg id -it'
+    else:
+        cmd = '%s id -it' % os.path.join('.', 'hg')

I know it's more a workaround than a real fix, but at least it works for me. :)

Pascal.

2009/1/28 Martin Geisler <mg at daimi.au.dk>:
> # HG changeset patch
> # User Martin Geisler <mg at daimi.au.dk>
> # Date 1233100890 -3600
> # Node ID e7588c67df41df7a15fe42c24284ccd9addf963a
> # Parent  5d25b2f59adeca72930be5a8f30f785e1edabb3d
> setup: get version number using pure Python modules
>
> diff --git a/setup.py b/setup.py
> --- a/setup.py
> +++ b/setup.py
> @@ -96,7 +96,14 @@
>     pass
>
>  try:
> -    l = os.popen('hg id -it').read().split()
> +    # execute hg out of this directory with a custom environment which
> +    # includes the pure Python modules in mercurial/pure
> +    pypath = os.environ.get('PYTHONPATH', '')
> +    purepath = os.path.join('mercurial', 'pure')
> +    os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath])
> +    cmd = '%s id -it' % os.path.join('.', 'hg')
> +    l = os.popen(cmd).read().split()
> +    os.environ['PYTHONPATH'] = pypath
>     while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
>         l.pop()
>     version = l and l[-1] or 'unknown' # latest tag or revision number
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>


More information about the Mercurial-devel mailing list