annotate setup.py @ 11715:4f9dfb54c8b5 stable

qpush --move: move the right patch even with comment lines 88fc876a4833 caused that we find the index of the moving patch in self.series but look it up in self.full_series. The difference between these is that full_series also contains comment lines, and we thus moved the wrong patch. Use back self.full_series to find the moving patch, but take care of striping the patch guard markers before comparing the patch name. Test cases have been added for comments and empty lines in self.full_series, and for the case of guarded patches. Original patch contributed by Mads Kiilerich <mads@kiilerich.com>
author Gilles Moris <gilles.moris@free.fr>
date Sat, 10 Jul 2010 21:23:00 +0200
parents 1c1126b1d919
children f3732ab1149f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
1 #!/usr/bin/env python
575
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
2 #
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
3 # This is the mercurial setup script.
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
4 #
4816
c10d3bc05a8d setup.py not executable: change instructions at beginning of file
Christian Ebert <blacktrash@gmx.net>
parents: 4628
diff changeset
5 # 'python setup.py install', or
c10d3bc05a8d setup.py not executable: change instructions at beginning of file
Christian Ebert <blacktrash@gmx.net>
parents: 4628
diff changeset
6 # 'python setup.py --help' for more options
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
7
1873
205f04b04ec6 Added check for minimal python version to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1777
diff changeset
8 import sys
8286
707bc82ba0d7 setup: require Python 2.4
Martin Geisler <mg@lazybytes.net>
parents: 8283
diff changeset
9 if not hasattr(sys, 'version_info') or sys.version_info < (2, 4, 0, 'final'):
707bc82ba0d7 setup: require Python 2.4
Martin Geisler <mg@lazybytes.net>
parents: 8283
diff changeset
10 raise SystemExit("Mercurial requires Python 2.4 or later.")
1873
205f04b04ec6 Added check for minimal python version to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1777
diff changeset
11
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
12 # Solaris Python packaging brain damage
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
13 try:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
14 import hashlib
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
15 sha = hashlib.sha1()
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
16 except:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
17 try:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
18 import sha
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
19 except:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
20 raise SystemExit(
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
21 "Couldn't import standard hashlib (incomplete Python install).")
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
22
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
23 try:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
24 import zlib
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
25 except:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
26 raise SystemExit(
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
27 "Couldn't import standard zlib (incomplete Python install).")
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
28
10761
16a13fdb4b36 setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10521
diff changeset
29 try:
10768
95b7a15b2f05 setup.py: don't use tabs
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10761
diff changeset
30 import bz2
10761
16a13fdb4b36 setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10521
diff changeset
31 except:
10768
95b7a15b2f05 setup.py: don't use tabs
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10761
diff changeset
32 raise SystemExit(
95b7a15b2f05 setup.py: don't use tabs
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10761
diff changeset
33 "Couldn't import standard bz2 (incomplete Python install).")
10761
16a13fdb4b36 setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10521
diff changeset
34
8547
548fd7a05373 setup.py: subprocess instead of os.popen, sys.stderr.write instead of print
Christian Ebert <blacktrash@gmx.net>
parents: 8494
diff changeset
35 import os, subprocess, time
6251
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
36 import shutil
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
37 import tempfile
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
38 from distutils import log
72
4a6ab4d80dc4 Add an O(m + nlog n) patching extension
mpm@selenic.com
parents: 67
diff changeset
39 from distutils.core import setup, Extension
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
40 from distutils.dist import Distribution
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
41 from distutils.command.build import build
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
42 from distutils.command.build_ext import build_ext
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
43 from distutils.command.build_py import build_py
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
44 from distutils.spawn import spawn, find_executable
6245
0d0939b2d272 setup.py: skip inotify if there's no inotify_add_watch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6241
diff changeset
45 from distutils.ccompiler import new_compiler
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
46 from distutils.errors import CCompilerError
157
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
47
6513
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
48 scripts = ['hg']
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
49 if os.name == 'nt':
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
50 scripts.append('contrib/win32/hg.bat')
3893
070628929e1f Fix setup.py warning
Matt Mackall <mpm@selenic.com>
parents: 3892
diff changeset
51
6251
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
52 # simplified version of distutils.ccompiler.CCompiler.has_function
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
53 # that actually removes its temporary files.
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
54 def hasfunction(cc, funcname):
6251
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
55 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
6373
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
56 devnull = oldstderr = None
6251
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
57 try:
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
58 try:
6373
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
59 fname = os.path.join(tmpdir, 'funcname.c')
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
60 f = open(fname, 'w')
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
61 f.write('int main(void) {\n')
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
62 f.write(' %s();\n' % funcname)
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
63 f.write('}\n')
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
64 f.close()
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
65 # Redirect stderr to /dev/null to hide any error messages
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
66 # from the compiler.
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
67 # This will have to be changed if we ever have to check
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
68 # for a function on Windows.
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
69 devnull = open('/dev/null', 'w')
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
70 oldstderr = os.dup(sys.stderr.fileno())
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
71 os.dup2(devnull.fileno(), sys.stderr.fileno())
9124
632df73485ae setup.py: don't pollute the current directory with temporary files
Bryan O'Sullivan <bos@serpentine.com>
parents: 8936
diff changeset
72 objects = cc.compile([fname], output_dir=tmpdir)
6251
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
73 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
74 except:
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
75 return False
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
76 return True
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
77 finally:
6373
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
78 if oldstderr is not None:
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
79 os.dup2(oldstderr, sys.stderr.fileno())
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
80 if devnull is not None:
7010e4557963 setup.py: hide compiler error messages while searching for inotify
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6251
diff changeset
81 devnull.close()
6251
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
82 shutil.rmtree(tmpdir)
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
83
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
84 # py2exe needs to be installed to work
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
85 try:
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
86 import py2exe
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
87 py2exeloaded = True
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
88
1422
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
89 # Help py2exe to find win32com.shell
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
90 try:
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
91 import modulefinder
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
92 import win32com
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
93 for p in win32com.__path__[1:]: # Take the path to win32comext
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
94 modulefinder.AddPackagePath("win32com", p)
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
95 pn = "win32com.shell"
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
96 __import__(pn)
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
97 m = sys.modules[pn]
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
98 for p in m.__path__[1:]:
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
99 modulefinder.AddPackagePath(pn, p)
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
100 except ImportError:
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
101 pass
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
102
1284
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
103 except ImportError:
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
104 py2exeloaded = False
3890
2eec996f2fb9 Fix demandload bits of setup.py py2exe support
Matt Mackall <mpm@selenic.com>
parents: 3887
diff changeset
105 pass
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
106
9807
f359d4f528aa setup: fix f51d1822d6fd refactoring, propagate env to runcmd
Christian Boos <cboos@bct-technology.com>
parents: 9615
diff changeset
107 def runcmd(cmd, env):
9615
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
108 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
109 stderr=subprocess.PIPE, env=env)
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
110 out, err = p.communicate()
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
111 # If root is executing setup.py, but the repository is owned by
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
112 # another user (as in "sudo python setup.py install") we will get
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
113 # trust warnings since the .hg/hgrc file is untrusted. That is
10120
fb890a546d44 setup: ignore 'not importing' warnings during version detection
Steve Borho <steve@borho.org>
parents: 9856
diff changeset
114 # fine, we don't want to load it anyway. Python may warn about
fb890a546d44 setup: ignore 'not importing' warnings during version detection
Steve Borho <steve@borho.org>
parents: 9856
diff changeset
115 # a missing __init__.py in mercurial/locale, we also ignore that.
9615
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
116 err = [e for e in err.splitlines()
10120
fb890a546d44 setup: ignore 'not importing' warnings during version detection
Steve Borho <steve@borho.org>
parents: 9856
diff changeset
117 if not e.startswith('Not trusting file') \
fb890a546d44 setup: ignore 'not importing' warnings during version detection
Steve Borho <steve@borho.org>
parents: 9856
diff changeset
118 and not e.startswith('warning: Not importing')]
9615
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
119 if err:
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
120 return ''
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
121 return out
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
122
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
123 version = ''
8548
3ccbe42ff72f setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 8547
diff changeset
124
8547
548fd7a05373 setup.py: subprocess instead of os.popen, sys.stderr.write instead of print
Christian Ebert <blacktrash@gmx.net>
parents: 8494
diff changeset
125 if os.path.isdir('.hg'):
8629
8e69a22f6792 setup: execute hg in C locale
Martin Geisler <mg@lazybytes.net>
parents: 8628
diff changeset
126 # Execute hg out of this directory with a custom environment which
8e69a22f6792 setup: execute hg in C locale
Martin Geisler <mg@lazybytes.net>
parents: 8628
diff changeset
127 # includes the pure Python modules in mercurial/pure. We also take
8e69a22f6792 setup: execute hg in C locale
Martin Geisler <mg@lazybytes.net>
parents: 8628
diff changeset
128 # care to not use any hgrc files and do no localization.
8e69a22f6792 setup: execute hg in C locale
Martin Geisler <mg@lazybytes.net>
parents: 8628
diff changeset
129 pypath = ['mercurial', os.path.join('mercurial', 'pure')]
8e69a22f6792 setup: execute hg in C locale
Martin Geisler <mg@lazybytes.net>
parents: 8628
diff changeset
130 env = {'PYTHONPATH': os.pathsep.join(pypath),
8e69a22f6792 setup: execute hg in C locale
Martin Geisler <mg@lazybytes.net>
parents: 8628
diff changeset
131 'HGRCPATH': '',
8e69a22f6792 setup: execute hg in C locale
Martin Geisler <mg@lazybytes.net>
parents: 8628
diff changeset
132 'LANGUAGE': 'C'}
9856
ed362d41d1f6 setup: pass LD_LIBRARY_PATH to subprocess when determining version.
Christian Boos <cboos@bct-technology.com>
parents: 9807
diff changeset
133 if 'LD_LIBRARY_PATH' in os.environ:
ed362d41d1f6 setup: pass LD_LIBRARY_PATH to subprocess when determining version.
Christian Boos <cboos@bct-technology.com>
parents: 9807
diff changeset
134 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
8648
ca443bac7ed4 fixed 0xc0150004 error building Mercurial under Python 2.6 for Windows
Garth Roxburgh-Kidd <garth@deadlybloodyserious.com>
parents: 8629
diff changeset
135 if 'SystemRoot' in os.environ:
ca443bac7ed4 fixed 0xc0150004 error building Mercurial under Python 2.6 for Windows
Garth Roxburgh-Kidd <garth@deadlybloodyserious.com>
parents: 8629
diff changeset
136 # Copy SystemRoot into the custom environment for Python 2.6
ca443bac7ed4 fixed 0xc0150004 error building Mercurial under Python 2.6 for Windows
Garth Roxburgh-Kidd <garth@deadlybloodyserious.com>
parents: 8629
diff changeset
137 # under Windows. Otherwise, the subprocess will fail with
ca443bac7ed4 fixed 0xc0150004 error building Mercurial under Python 2.6 for Windows
Garth Roxburgh-Kidd <garth@deadlybloodyserious.com>
parents: 8629
diff changeset
138 # error 0xc0150004. See: http://bugs.python.org/issue3440
ca443bac7ed4 fixed 0xc0150004 error building Mercurial under Python 2.6 for Windows
Garth Roxburgh-Kidd <garth@deadlybloodyserious.com>
parents: 8629
diff changeset
139 env['SystemRoot'] = os.environ['SystemRoot']
8547
548fd7a05373 setup.py: subprocess instead of os.popen, sys.stderr.write instead of print
Christian Ebert <blacktrash@gmx.net>
parents: 8494
diff changeset
140 cmd = [sys.executable, 'hg', 'id', '-i', '-t']
9807
f359d4f528aa setup: fix f51d1822d6fd refactoring, propagate env to runcmd
Christian Boos <cboos@bct-technology.com>
parents: 9615
diff changeset
141 l = runcmd(cmd, env).split()
9615
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
142 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
143 l.pop()
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
144 if len(l) > 1: # tag found
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
145 version = l[-1]
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
146 if l[0].endswith('+'): # propagate the dirty status to the tag
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
147 version += '+'
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
148 elif len(l) == 1: # no tag found
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
149 cmd = [sys.executable, 'hg', 'parents', '--template',
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
150 '{latesttag}+{latesttagdistance}-']
9807
f359d4f528aa setup: fix f51d1822d6fd refactoring, propagate env to runcmd
Christian Boos <cboos@bct-technology.com>
parents: 9615
diff changeset
151 version = runcmd(cmd, env) + l[0]
9615
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
152 if version.endswith('+'):
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
153 version += time.strftime('%Y%m%d')
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
154 elif os.path.exists('.hg_archival.txt'):
10124
08384d8777a4 setup.py: keep Python 2.3 compatibility
Martin Geisler <mg@lazybytes.net>
parents: 10120
diff changeset
155 kw = dict([[t.strip() for t in l.split(':', 1)]
08384d8777a4 setup.py: keep Python 2.3 compatibility
Martin Geisler <mg@lazybytes.net>
parents: 10120
diff changeset
156 for l in open('.hg_archival.txt')])
9615
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
157 if 'tag' in kw:
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
158 version = kw['tag']
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
159 elif 'latesttag' in kw:
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
160 version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
8547
548fd7a05373 setup.py: subprocess instead of os.popen, sys.stderr.write instead of print
Christian Ebert <blacktrash@gmx.net>
parents: 8494
diff changeset
161 else:
9615
f51d1822d6fd setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents: 9539
diff changeset
162 version = kw.get('node', '')[:12]
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
163
8548
3ccbe42ff72f setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 8547
diff changeset
164 if version:
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 8936
diff changeset
165 f = open("mercurial/__version__.py", "w")
8548
3ccbe42ff72f setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 8547
diff changeset
166 f.write('# this file is autogenerated by setup.py\n')
3ccbe42ff72f setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 8547
diff changeset
167 f.write('version = "%s"\n' % version)
3ccbe42ff72f setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 8547
diff changeset
168 f.close()
3ccbe42ff72f setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 8547
diff changeset
169
8493
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
170
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
171 try:
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
172 from mercurial import __version__
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
173 version = __version__.version
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
174 except ImportError:
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
175 version = 'unknown'
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
176
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
177 class hgbuildmo(build):
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
178
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
179 description = "build translations (.mo files)"
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
180
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
181 def run(self):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
182 if not find_executable('msgfmt'):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
183 self.warn("could not find msgfmt executable, no translations "
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
184 "will be built")
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
185 return
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
186
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
187 podir = 'i18n'
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
188 if not os.path.isdir(podir):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
189 self.warn("could not find %s/ directory" % podir)
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
190 return
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
191
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
192 join = os.path.join
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
193 for po in os.listdir(podir):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
194 if not po.endswith('.po'):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
195 continue
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
196 pofile = join(podir, po)
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
197 modir = join('locale', po[:-3], 'LC_MESSAGES')
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
198 mofile = join(modir, 'hg.mo')
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
199 mobuildfile = join('mercurial', mofile)
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
200 cmd = ['msgfmt', '-v', '-o', mobuildfile, pofile]
7720
b6c2cb40e664 setup: do not use -c with msgfmt on Solaris (issue1489)
Martin Geisler <mg@daimi.au.dk>
parents: 7712
diff changeset
201 if sys.platform != 'sunos5':
b6c2cb40e664 setup: do not use -c with msgfmt on Solaris (issue1489)
Martin Geisler <mg@daimi.au.dk>
parents: 7712
diff changeset
202 # msgfmt on Solaris does not know about -c
b6c2cb40e664 setup: do not use -c with msgfmt on Solaris (issue1489)
Martin Geisler <mg@daimi.au.dk>
parents: 7712
diff changeset
203 cmd.append('-c')
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
204 self.mkpath(join('mercurial', modir))
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
205 self.make_file([pofile], mobuildfile, spawn, (cmd,))
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
206
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
207 # Insert hgbuildmo first so that files in mercurial/locale/ are found
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
208 # when build_py is run next.
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
209 build.sub_commands.insert(0, ('build_mo', None))
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
210
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
211 Distribution.pure = 0
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
212 Distribution.global_options.append(('pure', None, "use pure (slow) Python "
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
213 "code instead of C extensions"))
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
214
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
215 class hgbuildext(build_ext):
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
216
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
217 def build_extension(self, ext):
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
218 try:
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
219 build_ext.build_extension(self, ext)
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
220 except CCompilerError:
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
221 if not hasattr(ext, 'optional') or not ext.optional:
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
222 raise
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
223 log.warn("Failed to build optional extension '%s' (skipping)",
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
224 ext.name)
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
225
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
226 class hgbuildpy(build_py):
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
227
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
228 def finalize_options(self):
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
229 build_py.finalize_options(self)
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
230
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
231 if self.distribution.pure:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
232 if self.py_modules is None:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
233 self.py_modules = []
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
234 for ext in self.distribution.ext_modules:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
235 if ext.name.startswith("mercurial."):
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
236 self.py_modules.append("mercurial.pure.%s" % ext.name[10:])
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
237 self.distribution.ext_modules = []
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
238
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
239 def find_modules(self):
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
240 modules = build_py.find_modules(self)
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
241 for module in modules:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
242 if module[0] == "mercurial.pure":
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
243 if module[1] != "__init__":
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
244 yield ("mercurial", module[1], module[2])
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
245 else:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
246 yield module
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
247
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
248 cmdclass = {'build_mo': hgbuildmo,
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
249 'build_ext': hgbuildext,
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
250 'build_py': hgbuildpy}
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
251
10521
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
252 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
253 'hgext.highlight', 'hgext.zeroconf']
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
254
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
255 pymodules = []
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
256
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
257 extmodules = [
6389
0231f763ebc8 manifest: improve parsing performance by 8x via a new C extension
Bryan O'Sullivan <bos@serpentine.com>
parents: 6373
diff changeset
258 Extension('mercurial.base85', ['mercurial/base85.c']),
5396
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
259 Extension('mercurial.bdiff', ['mercurial/bdiff.c']),
6389
0231f763ebc8 manifest: improve parsing performance by 8x via a new C extension
Bryan O'Sullivan <bos@serpentine.com>
parents: 6373
diff changeset
260 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']),
0231f763ebc8 manifest: improve parsing performance by 8x via a new C extension
Bryan O'Sullivan <bos@serpentine.com>
parents: 6373
diff changeset
261 Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
0231f763ebc8 manifest: improve parsing performance by 8x via a new C extension
Bryan O'Sullivan <bos@serpentine.com>
parents: 6373
diff changeset
262 Extension('mercurial.parsers', ['mercurial/parsers.c']),
5396
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
263 ]
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
264
10521
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
265 # disable osutil.c under windows + python 2.4 (issue1364)
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
266 if sys.platform == 'win32' and sys.version_info < (2, 5, 0, 'final'):
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
267 pymodules.append('mercurial.pure.osutil')
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
268 else:
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
269 extmodules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
6239
39cfcef4f463 Add inotify extension
Bryan O'Sullivan <bos@serpentine.com>
parents: 6009
diff changeset
270
8283
d6134b800797 setup: cleanup old left-over code
Martin Geisler <mg@lazybytes.net>
parents: 7958
diff changeset
271 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
d6134b800797 setup: cleanup old left-over code
Martin Geisler <mg@lazybytes.net>
parents: 7958
diff changeset
272 # The inotify extension is only usable with Linux 2.6 kernels.
d6134b800797 setup: cleanup old left-over code
Martin Geisler <mg@lazybytes.net>
parents: 7958
diff changeset
273 # You also need a reasonably recent C library.
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
274 # In any case, if it fails to build the error will be skipped ('optional').
8283
d6134b800797 setup: cleanup old left-over code
Martin Geisler <mg@lazybytes.net>
parents: 7958
diff changeset
275 cc = new_compiler()
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
276 if hasfunction(cc, 'inotify_add_watch'):
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
277 inotify = Extension('hgext.inotify.linux._inotify',
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
278 ['hgext/inotify/linux/_inotify.c'])
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
279 inotify.optional = True
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
280 extmodules.append(inotify)
8283
d6134b800797 setup: cleanup old left-over code
Martin Geisler <mg@lazybytes.net>
parents: 7958
diff changeset
281 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
5396
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
282
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
283 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
284 'help/*.txt']}
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
285
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
286 def ordinarypath(p):
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
287 return p and p[0] != '.' and p[-1] != '~'
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
288
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
289 for root in ('templates',):
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
290 for curdir, dirs, files in os.walk(os.path.join('mercurial', root)):
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
291 curdir = curdir.split(os.sep, 1)[1]
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
292 dirs[:] = filter(ordinarypath, dirs)
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
293 for f in filter(ordinarypath, files):
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
294 f = os.path.join(curdir, f)
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
295 packagedata['mercurial'].append(f)
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
296
7648
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
297 datafiles = []
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
298 setupversion = version
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
299 extra = {}
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
300
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
301 if py2exeloaded:
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
302 extra['console'] = [
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
303 {'script':'hg',
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
304 'copyright':'Copyright (C) 2005-2010 Matt Mackall and others',
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
305 'product_version':version}]
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
306
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
307 if os.name == 'nt':
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
308 # Windows binary file versions for exe/dll files must have the
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
309 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
310 setupversion = version.split('+', 1)[0]
7648
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
311
1977
7eb694a1c1af Don't forget version at the end of setup.py, write it only if changed.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1873
diff changeset
312 setup(name='mercurial',
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
313 version=setupversion,
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
314 author='Matt Mackall',
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
315 author_email='mpm@selenic.com',
8936
1de6e7e1bb9f change wiki/bts URLs to point to new hostname
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8648
diff changeset
316 url='http://mercurial.selenic.com/',
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
317 description='Scalable distributed SCM',
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 10124
diff changeset
318 license='GNU GPLv2+',
6513
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
319 scripts=scripts,
6239
39cfcef4f463 Add inotify extension
Bryan O'Sullivan <bos@serpentine.com>
parents: 6009
diff changeset
320 packages=packages,
10521
bde1bb250fc2 Do not use osutil.c with python 2.4 and Windows (issue1364)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10400
diff changeset
321 py_modules=pymodules,
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
322 ext_modules=extmodules,
7648
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
323 data_files=datafiles,
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
324 package_data=packagedata,
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
325 cmdclass=cmdclass,
6789
c1c202e2d45d Force email package to be loaded in py2exe
Paul Moore <p.f.moore@gmail.com>
parents: 6373
diff changeset
326 options=dict(py2exe=dict(packages=['hgext', 'email']),
4628
02956be66a58 Fix for including hgext in Windows compiled version.
Lee Cantey <lcantey@gmail.com>
parents: 4519
diff changeset
327 bdist_mpkg=dict(zipdist=True,
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
328 license='COPYING',
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
329 readme='contrib/macosx/Readme.html',
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
330 welcome='contrib/macosx/Welcome.html')),
3893
070628929e1f Fix setup.py warning
Matt Mackall <mpm@selenic.com>
parents: 3892
diff changeset
331 **extra)