annotate setup.py @ 7732:3793802ea41b

Make util.find_exe alway returns existing file, fixing issue1459 It seems like the old behaviour with different handling for commands with and without path was intended, but I think this behaviour of util.find_exe is better: * Always returns existing file * or None if command not found - no default * Windows: Returned file thus always ends with extension from PATHEXT This fixes http://www.selenic.com/mercurial/bts/issue1459. The change might fix other unintended behaviour too.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 25 Jan 2009 21:20:13 +0100
parents 103127a8cbdb
children 1817e45c2212
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
3590
231e61de692c Check for at least having a final release of python 2.3.0 in setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3283
diff changeset
9 if not hasattr(sys, 'version_info') or sys.version_info < (2, 3, 0, 'final'):
7008
8fee8ff13d37 use Exception(args)-style raising consistently (py3k compatibility)
Peter Ruibal <peter.ruibal@intel.com>
parents: 6948
diff changeset
10 raise SystemExit("Mercurial requires python 2.3 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
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
29 import os, 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
30 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
31 import tempfile
72
4a6ab4d80dc4 Add an O(m + nlog n) patching extension
mpm@selenic.com
parents: 67
diff changeset
32 from distutils.core import setup, Extension
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
33 from distutils.dist import Distribution
157
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
34 from distutils.command.install_data import install_data
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
35 from distutils.command.build import build
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
36 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
37 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
38 from distutils.ccompiler import new_compiler
157
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
39
3893
070628929e1f Fix setup.py warning
Matt Mackall <mpm@selenic.com>
parents: 3892
diff changeset
40 extra = {}
6513
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
41 scripts = ['hg']
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
42 if os.name == 'nt':
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
43 scripts.append('contrib/win32/hg.bat')
3893
070628929e1f Fix setup.py warning
Matt Mackall <mpm@selenic.com>
parents: 3892
diff changeset
44
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
45 # 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
46 # that actually removes its temporary files.
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
47 def has_function(cc, funcname):
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 # 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
59 # 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
60 # 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
61 # 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
62 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
63 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
64 os.dup2(devnull.fileno(), sys.stderr.fileno())
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
65 objects = cc.compile([fname])
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
77 # py2exe needs to be installed to work
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
78 try:
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
79 import py2exe
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
80
1422
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
81 # 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
82 try:
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
83 import modulefinder
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
84 import win32com
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
85 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
86 modulefinder.AddPackagePath("win32com", p)
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
87 pn = "win32com.shell"
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
88 __import__(pn)
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
89 m = sys.modules[pn]
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
90 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
91 modulefinder.AddPackagePath(pn, p)
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
92 except ImportError:
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
93 pass
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
94
3893
070628929e1f Fix setup.py warning
Matt Mackall <mpm@selenic.com>
parents: 3892
diff changeset
95 extra['console'] = ['hg']
070628929e1f Fix setup.py warning
Matt Mackall <mpm@selenic.com>
parents: 3892
diff changeset
96
1284
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
97 except ImportError:
3890
2eec996f2fb9 Fix demandload bits of setup.py py2exe support
Matt Mackall <mpm@selenic.com>
parents: 3887
diff changeset
98 pass
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
99
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
100 try:
7721
a1138f437640 setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents: 7720
diff changeset
101 # execute hg out of this directory with a custom environment which
a1138f437640 setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents: 7720
diff changeset
102 # includes the pure Python modules in mercurial/pure
a1138f437640 setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents: 7720
diff changeset
103 pypath = os.environ.get('PYTHONPATH', '')
a1138f437640 setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents: 7720
diff changeset
104 purepath = os.path.join('mercurial', 'pure')
a1138f437640 setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents: 7720
diff changeset
105 os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath])
a1138f437640 setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents: 7720
diff changeset
106 cmd = '%s id -it' % os.path.join('.', 'hg')
a1138f437640 setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents: 7720
diff changeset
107 l = os.popen(cmd).read().split()
a1138f437640 setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents: 7720
diff changeset
108 os.environ['PYTHONPATH'] = pypath
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
109 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
110 l.pop()
7647
f7256cd9beff recover when no version information is available
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7632
diff changeset
111 version = l and l[-1] or 'unknown' # latest tag or revision number
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
112 if version.endswith('+'):
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
113 version += time.strftime('%Y%m%d')
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
114
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
115 except OSError:
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
116 version = "unknown"
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
117
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
118 f = file("mercurial/__version__.py", "w")
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
119 f.write('# this file is autogenerated by setup.py\n')
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
120 f.write('version = "%s"\n' % version)
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
121 f.close()
427
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
122
157
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
123 class install_package_data(install_data):
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
124 def finalize_options(self):
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
125 self.set_undefined_options('install',
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
126 ('install_lib', 'install_dir'))
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
127 install_data.finalize_options(self)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
128
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
129 class build_mo(build):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
130
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
131 description = "build translations (.mo files)"
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
132
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
133 def run(self):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
134 if not find_executable('msgfmt'):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
135 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
136 "will be built")
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
137 return
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
138
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
139 podir = 'i18n'
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
140 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
141 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
142 return
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
143
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
144 join = os.path.join
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
145 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
146 if not po.endswith('.po'):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
147 continue
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
148 pofile = join(podir, po)
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
149 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
150 mofile = join(modir, 'hg.mo')
7720
b6c2cb40e664 setup: do not use -c with msgfmt on Solaris (issue1489)
Martin Geisler <mg@daimi.au.dk>
parents: 7712
diff changeset
151 cmd = ['msgfmt', '-v', '-o', mofile, pofile]
b6c2cb40e664 setup: do not use -c with msgfmt on Solaris (issue1489)
Martin Geisler <mg@daimi.au.dk>
parents: 7712
diff changeset
152 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
153 # 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
154 cmd.append('-c')
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
155 self.mkpath(modir)
7720
b6c2cb40e664 setup: do not use -c with msgfmt on Solaris (issue1489)
Martin Geisler <mg@daimi.au.dk>
parents: 7712
diff changeset
156 self.make_file([pofile], mofile, spawn, (cmd,))
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
157 self.distribution.data_files.append((join('mercurial', modir),
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
158 [mofile]))
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
159
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
160 build.sub_commands.append(('build_mo', None))
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
161
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
162 Distribution.pure = 0
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
163 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
164 "code instead of C extensions"))
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
165
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
166 class hg_build_py(build_py):
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
167
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
168 def finalize_options(self):
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
169 build_py.finalize_options(self)
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
170
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
171 if self.distribution.pure:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
172 if self.py_modules is None:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
173 self.py_modules = []
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
174 for ext in self.distribution.ext_modules:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
175 if ext.name.startswith("mercurial."):
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
176 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
177 self.distribution.ext_modules = []
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
178
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
179 def find_modules(self):
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
180 modules = build_py.find_modules(self)
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
181 for module in modules:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
182 if module[0] == "mercurial.pure":
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
183 if module[1] != "__init__":
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
184 yield ("mercurial", module[1], module[2])
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
185 else:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
186 yield module
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
187
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
188 cmdclass = {'install_data': install_package_data,
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
189 'build_mo': build_mo,
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
190 'build_py': hg_build_py}
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
191
5396
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
192 ext_modules=[
6389
0231f763ebc8 manifest: improve parsing performance by 8x via a new C extension
Bryan O'Sullivan <bos@serpentine.com>
parents: 6373
diff changeset
193 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
194 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
195 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
196 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
197 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
198 ]
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
199
6948
359e93ceee3a fix double indentation and trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6938
diff changeset
200 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
7081
2fdbf2ccd03a Add hgext.zeroconf to the package list so it gets installed by setup.py.
Augie Fackler <durin42@gmail.com>
parents: 7056
diff changeset
201 'hgext.highlight', 'hgext.zeroconf', ]
6239
39cfcef4f463 Add inotify extension
Bryan O'Sullivan <bos@serpentine.com>
parents: 6009
diff changeset
202
5396
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
203 try:
7056
2c1f18b88b6a osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents: 7008
diff changeset
204 import msvcrt
2c1f18b88b6a osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents: 7008
diff changeset
205 ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
2c1f18b88b6a osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents: 7008
diff changeset
206 except ImportError:
2c1f18b88b6a osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents: 7008
diff changeset
207 pass
2c1f18b88b6a osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents: 7008
diff changeset
208
2c1f18b88b6a osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents: 7008
diff changeset
209 try:
5396
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
210 import posix
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
211 ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
6241
a718e66836e8 setup.py: os.uname is not available on Windows
Bryan O'Sullivan <bos@serpentine.com>
parents: 6239
diff changeset
212
a718e66836e8 setup.py: os.uname is not available on Windows
Bryan O'Sullivan <bos@serpentine.com>
parents: 6239
diff changeset
213 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
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
214 # The inotify extension is only usable with Linux 2.6 kernels.
0d0939b2d272 setup.py: skip inotify if there's no inotify_add_watch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6241
diff changeset
215 # You also need a reasonably recent C library.
0d0939b2d272 setup.py: skip inotify if there's no inotify_add_watch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6241
diff changeset
216 cc = new_compiler()
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
217 if has_function(cc, 'inotify_add_watch'):
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
218 ext_modules.append(Extension('hgext.inotify.linux._inotify',
0d0939b2d272 setup.py: skip inotify if there's no inotify_add_watch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6241
diff changeset
219 ['hgext/inotify/linux/_inotify.c']))
0d0939b2d272 setup.py: skip inotify if there's no inotify_add_watch
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6241
diff changeset
220 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
221 except ImportError:
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
222 pass
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
223
7648
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
224 datafiles = []
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
225 for root in ('templates', 'i18n'):
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
226 for dir, dirs, files in os.walk(root):
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
227 datafiles.append((os.path.join('mercurial', dir),
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
228 [os.path.join(dir, file_) for file_ in files]))
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
229
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
230 setup(name='mercurial',
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
231 version=version,
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
232 author='Matt Mackall',
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
233 author_email='mpm@selenic.com',
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
234 url='http://selenic.com/mercurial',
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
235 description='Scalable distributed SCM',
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
236 license='GNU GPL',
6513
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
237 scripts=scripts,
6239
39cfcef4f463 Add inotify extension
Bryan O'Sullivan <bos@serpentine.com>
parents: 6009
diff changeset
238 packages=packages,
5396
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
239 ext_modules=ext_modules,
7648
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
240 data_files=datafiles,
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
241 cmdclass=cmdclass,
6789
c1c202e2d45d Force email package to be loaded in py2exe
Paul Moore <p.f.moore@gmail.com>
parents: 6373
diff changeset
242 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
243 bdist_mpkg=dict(zipdist=True,
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
244 license='COPYING',
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
245 readme='contrib/macosx/Readme.html',
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
246 welcome='contrib/macosx/Welcome.html')),
3893
070628929e1f Fix setup.py warning
Matt Mackall <mpm@selenic.com>
parents: 3892
diff changeset
247 **extra)