author | Stefano Tortarolo <stefano.tortarolo@gmail.com> |
Sun, 29 Mar 2009 14:47:59 +0200 | |
changeset 7951 | 4d9e8efb7326 |
parent 7946 | 9d36291f787a |
child 7958 | 73fa2be69ea9 |
permissions | -rw-r--r-- |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
575 | 2 |
# |
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 | 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 | 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 | 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 | 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 | 95 |
extra['console'] = ['hg'] |
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 |
|
7826
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
100 |
def getversion(): |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
101 |
if not os.path.exists('.hg'): |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
102 |
return None # not in a repository |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
103 |
|
7721
a1138f437640
setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents:
7720
diff
changeset
|
104 |
# 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
|
105 |
# 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
|
106 |
pypath = os.environ.get('PYTHONPATH', '') |
a1138f437640
setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents:
7720
diff
changeset
|
107 |
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
|
108 |
os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath]) |
7801
e5627562b9f2
setup: run hg with empty HGRCPATH for robustness.
Martin Geisler <mg@daimi.au.dk>
parents:
7790
diff
changeset
|
109 |
os.environ['HGRCPATH'] = '' # do not read any config file |
7790
1817e45c2212
setup: use sys.executable to call hg
Martin Geisler <mg@daimi.au.dk>
parents:
7722
diff
changeset
|
110 |
cmd = '%s hg id -it' % sys.executable |
7826
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
111 |
|
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
112 |
try: |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
113 |
l = os.popen(cmd).read().split() |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
114 |
except OSError, e: |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
115 |
print "warning: could not establish Mercurial version: %s" % e |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
116 |
|
7721
a1138f437640
setup: get version number using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents:
7720
diff
changeset
|
117 |
os.environ['PYTHONPATH'] = pypath |
7826
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
118 |
|
7632 | 119 |
while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags |
120 |
l.pop() |
|
7826
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
121 |
if l: |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
122 |
version = l[-1] # latest tag or revision number |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
123 |
if version.endswith('+'): |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
124 |
version += time.strftime('%Y%m%d') |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
125 |
return version |
7632 | 126 |
|
7826
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
127 |
version = getversion() |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
128 |
if version: |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
129 |
f = file("mercurial/__version__.py", "w") |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
130 |
f.write('# this file is autogenerated by setup.py\n') |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
131 |
f.write('version = "%s"\n' % version) |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
132 |
f.close() |
f0a7accf1d68
setup.py: fix version detection for tarball
Matt Mackall <mpm@selenic.com>
parents:
7801
diff
changeset
|
133 |
else: |
7632 | 134 |
version = "unknown" |
135 |
||
157
2653740d8118
Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents:
155
diff
changeset
|
136 |
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
|
137 |
def finalize_options(self): |
2653740d8118
Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents:
155
diff
changeset
|
138 |
self.set_undefined_options('install', |
2653740d8118
Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents:
155
diff
changeset
|
139 |
('install_lib', 'install_dir')) |
2653740d8118
Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents:
155
diff
changeset
|
140 |
install_data.finalize_options(self) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
141 |
|
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
142 |
class build_mo(build): |
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 |
description = "build translations (.mo files)" |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
145 |
|
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
146 |
def run(self): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
147 |
if not find_executable('msgfmt'): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
148 |
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
|
149 |
"will be built") |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
150 |
return |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
151 |
|
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
152 |
podir = 'i18n' |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
153 |
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
|
154 |
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
|
155 |
return |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
156 |
|
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
157 |
join = os.path.join |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
158 |
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
|
159 |
if not po.endswith('.po'): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
160 |
continue |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
161 |
pofile = join(podir, po) |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
162 |
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
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
# 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
|
167 |
cmd.append('-c') |
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
168 |
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
|
169 |
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
|
170 |
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
|
171 |
[mofile])) |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
172 |
|
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
173 |
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
|
174 |
|
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
175 |
Distribution.pure = 0 |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
176 |
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
|
177 |
"code instead of C extensions")) |
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 |
class hg_build_py(build_py): |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
180 |
|
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
181 |
def finalize_options(self): |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
182 |
build_py.finalize_options(self) |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
183 |
|
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
184 |
if self.distribution.pure: |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
185 |
if self.py_modules is None: |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
186 |
self.py_modules = [] |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
187 |
for ext in self.distribution.ext_modules: |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
188 |
if ext.name.startswith("mercurial."): |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
189 |
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
|
190 |
self.distribution.ext_modules = [] |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
191 |
|
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
192 |
def find_modules(self): |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
193 |
modules = build_py.find_modules(self) |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
194 |
for module in modules: |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
195 |
if module[0] == "mercurial.pure": |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
196 |
if module[1] != "__init__": |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
197 |
yield ("mercurial", module[1], module[2]) |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
198 |
else: |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
199 |
yield module |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
200 |
|
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
201 |
cmdclass = {'install_data': install_package_data, |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
202 |
'build_mo': build_mo, |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
203 |
'build_py': hg_build_py} |
3238
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
204 |
|
5396
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
205 |
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
|
206 |
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
|
207 |
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
|
208 |
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
|
209 |
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
|
210 |
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
|
211 |
] |
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
212 |
|
6948
359e93ceee3a
fix double indentation and trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6938
diff
changeset
|
213 |
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
|
214 |
'hgext.highlight', 'hgext.zeroconf', ] |
6239
39cfcef4f463
Add inotify extension
Bryan O'Sullivan <bos@serpentine.com>
parents:
6009
diff
changeset
|
215 |
|
5396
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
216 |
try: |
7056
2c1f18b88b6a
osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents:
7008
diff
changeset
|
217 |
import msvcrt |
2c1f18b88b6a
osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents:
7008
diff
changeset
|
218 |
ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c'])) |
2c1f18b88b6a
osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents:
7008
diff
changeset
|
219 |
except ImportError: |
2c1f18b88b6a
osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents:
7008
diff
changeset
|
220 |
pass |
2c1f18b88b6a
osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents:
7008
diff
changeset
|
221 |
|
2c1f18b88b6a
osutil: implementation for Win32
Petr Kodl <petrkodl@gmail.com>
parents:
7008
diff
changeset
|
222 |
try: |
5396
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
223 |
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
|
224 |
|
a718e66836e8
setup.py: os.uname is not available on Windows
Bryan O'Sullivan <bos@serpentine.com>
parents:
6239
diff
changeset
|
225 |
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
|
226 |
# 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
|
227 |
# 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
|
228 |
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
|
229 |
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
|
230 |
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
|
231 |
['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
|
232 |
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
|
233 |
except ImportError: |
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
234 |
pass |
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
235 |
|
7648
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
236 |
datafiles = [] |
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
237 |
for root in ('templates', 'i18n'): |
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
238 |
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
|
239 |
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
|
240 |
[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
|
241 |
|
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
|
242 |
setup(name='mercurial', |
7632 | 243 |
version=version, |
3238
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
244 |
author='Matt Mackall', |
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
245 |
author_email='mpm@selenic.com', |
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
246 |
url='http://selenic.com/mercurial', |
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
247 |
description='Scalable distributed SCM', |
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
248 |
license='GNU GPL', |
6513
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
249 |
scripts=scripts, |
6239
39cfcef4f463
Add inotify extension
Bryan O'Sullivan <bos@serpentine.com>
parents:
6009
diff
changeset
|
250 |
packages=packages, |
5396
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
251 |
ext_modules=ext_modules, |
7648
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
252 |
data_files=datafiles, |
3238
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
253 |
cmdclass=cmdclass, |
6789
c1c202e2d45d
Force email package to be loaded in py2exe
Paul Moore <p.f.moore@gmail.com>
parents:
6373
diff
changeset
|
254 |
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
|
255 |
bdist_mpkg=dict(zipdist=True, |
3238
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
256 |
license='COPYING', |
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
257 |
readme='contrib/macosx/Readme.html', |
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
258 |
welcome='contrib/macosx/Welcome.html')), |
3893 | 259 |
**extra) |