Mercurial > hg
annotate setup.py @ 27303:57bd9c5431a5
perf: improve grammar of gettimer comment
author | timeless <timeless@mozdev.org> |
---|---|
date | Fri, 04 Dec 2015 17:41:02 +0000 |
parents | bdcbec65750b |
children | 83a8219fb790 |
rev | line source |
---|---|
575 | 1 # |
2 # This is the mercurial setup script. | |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
3 # |
4816
c10d3bc05a8d
setup.py not executable: change instructions at beginning of file
Christian Ebert <blacktrash@gmx.net>
parents:
4628
diff
changeset
|
4 # '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
|
5 # 'python setup.py --help' for more options |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
6 |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
7 import sys, platform |
25009
e1fb276d4619
setup.py: drop compatibility with Python 2.4 and 2.5 (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24941
diff
changeset
|
8 if getattr(sys, 'version_info', (0, 0, 0)) < (2, 6, 0, 'final'): |
e1fb276d4619
setup.py: drop compatibility with Python 2.4 and 2.5 (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24941
diff
changeset
|
9 raise SystemExit("Mercurial requires Python 2.6 or later.") |
1873
205f04b04ec6
Added check for minimal python version to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1777
diff
changeset
|
10 |
11532
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
11 if sys.version_info[0] >= 3: |
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
12 def b(s): |
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
13 '''A helper function to emulate 2.6+ bytes literals using string |
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
14 literals.''' |
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
15 return s.encode('latin1') |
20696
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
16 printf = eval('print') |
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
17 libdir_escape = 'unicode_escape' |
11532
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
18 else: |
20696
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
19 libdir_escape = 'string_escape' |
11532
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
20 def b(s): |
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
21 '''A helper function to emulate 2.6+ bytes literals using string |
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
22 literals.''' |
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
23 return s |
20696
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
24 def printf(*args, **kwargs): |
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
25 f = kwargs.get('file', sys.stdout) |
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
26 end = kwargs.get('end', '\n') |
20697
1cd5bff45db2
setup.py: fix 2.4 breakage in 77ab0abb
Augie Fackler <raf@durin42.com>
parents:
20696
diff
changeset
|
27 f.write(b(' ').join(args) + end) |
11532
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
28 |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
29 # Solaris Python packaging brain damage |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
30 try: |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
31 import hashlib |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
32 sha = hashlib.sha1() |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
33 except ImportError: |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
34 try: |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
35 import sha |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
21840
diff
changeset
|
36 sha.sha # silence unused import warning |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
37 except ImportError: |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
38 raise SystemExit( |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
39 "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
|
40 |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
41 try: |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
42 import zlib |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
21840
diff
changeset
|
43 zlib.compressobj # silence unused import warning |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
44 except ImportError: |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
45 raise SystemExit( |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
46 "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
|
47 |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
48 # The base IronPython distribution (as of 2.7.1) doesn't support bz2 |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
49 isironpython = False |
10761
16a13fdb4b36
setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10521
diff
changeset
|
50 try: |
16683 | 51 isironpython = (platform.python_implementation() |
52 .lower().find("ironpython") != -1) | |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
53 except AttributeError: |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
54 pass |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
55 |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
56 if isironpython: |
15492
36f076d03b34
setup: make script executable with python3
Simon Heimberg <simohe@besonet.ch>
parents:
15460
diff
changeset
|
57 sys.stderr.write("warning: IronPython detected (no bz2 support)\n") |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
58 else: |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
59 try: |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
60 import bz2 |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
21840
diff
changeset
|
61 bz2.BZ2Compressor # silence unused import warning |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
62 except ImportError: |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
63 raise SystemExit( |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
64 "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
|
65 |
24192
390410a6545d
setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents:
24191
diff
changeset
|
66 ispypy = "PyPy" in sys.version |
390410a6545d
setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents:
24191
diff
changeset
|
67 |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
68 import os, stat, subprocess, time |
21038
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
69 import re |
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
|
70 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
|
71 import tempfile |
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
72 from distutils import log |
26600
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
73 if 'FORCE_SETUPTOOLS' in os.environ: |
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
74 from setuptools import setup |
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
75 else: |
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
76 from distutils.core import setup |
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
77 from distutils.core import Command, Extension |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
78 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
|
79 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
|
80 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
|
81 from distutils.command.build_py import build_py |
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
82 from distutils.command.build_scripts import build_scripts |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
83 from distutils.command.install_lib import install_lib |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
84 from distutils.command.install_scripts import install_scripts |
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
85 from distutils.spawn import spawn, find_executable |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
86 from distutils import file_util |
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
87 from distutils.errors import ( |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
88 CCompilerError, |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
89 DistutilsError, |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
90 DistutilsExecError, |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
91 ) |
21038
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
92 from distutils.sysconfig import get_python_inc, get_config_var |
13594
64a458707fd4
setup.py: use StrictVersion instead of manual comparison
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
13583
diff
changeset
|
93 from distutils.version import StrictVersion |
157
2653740d8118
Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents:
155
diff
changeset
|
94 |
15494
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
95 convert2to3 = '--c2to3' in sys.argv |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
96 if convert2to3: |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
97 try: |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
98 from distutils.command.build_py import build_py_2to3 as build_py |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
99 from lib2to3.refactor import get_fixers_from_package as getfixers |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
100 except ImportError: |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
101 if sys.version_info[0] < 3: |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
102 raise SystemExit("--c2to3 is only compatible with python3.") |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
103 raise |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
104 sys.path.append('contrib') |
15500
d5abe76da61e
setup: raise when executing with python3 without c2to3 argument
Simon Heimberg <simohe@besonet.ch>
parents:
15494
diff
changeset
|
105 elif sys.version_info[0] >= 3: |
d5abe76da61e
setup: raise when executing with python3 without c2to3 argument
Simon Heimberg <simohe@besonet.ch>
parents:
15494
diff
changeset
|
106 raise SystemExit("setup.py with python3 needs --c2to3 (experimental)") |
15494
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
107 |
6513
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
108 scripts = ['hg'] |
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
109 if os.name == 'nt': |
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
110 # We remove hg.bat if we are able to build hg.exe. |
6513
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
111 scripts.append('contrib/win32/hg.bat') |
3893 | 112 |
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
|
113 # 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
|
114 # that actually removes its temporary files. |
10000
16f49d671c7f
setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents:
9999
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 try: |
25089
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
119 fname = os.path.join(tmpdir, 'funcname.c') |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
120 f = open(fname, 'w') |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
121 f.write('int main(void) {\n') |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
122 f.write(' %s();\n' % funcname) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
123 f.write('}\n') |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
124 f.close() |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
125 # Redirect stderr to /dev/null to hide any error messages |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
126 # from the compiler. |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
127 # This will have to be changed if we ever have to check |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
128 # for a function on Windows. |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
129 devnull = open('/dev/null', 'w') |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
130 oldstderr = os.dup(sys.stderr.fileno()) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
131 os.dup2(devnull.fileno(), sys.stderr.fileno()) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
132 objects = cc.compile([fname], output_dir=tmpdir) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
133 cc.link_executable(objects, os.path.join(tmpdir, "a.out")) |
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
|
134 return True |
25089
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
135 except Exception: |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
136 return False |
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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 |
1283
f5faab34f32e
Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents:
575
diff
changeset
|
144 # py2exe needs to be installed to work |
f5faab34f32e
Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents:
575
diff
changeset
|
145 try: |
1294
372971e1c40d
Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1284
diff
changeset
|
146 import py2exe |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
21840
diff
changeset
|
147 py2exe.Distribution # silence unused import warning |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
148 py2exeloaded = True |
15527
9926aab3d0b5
setup: fix py2exe generation broken by c3a6ec304055 (issue3116)
Pascal Quantin <pascal.quantin@gmail.com>
parents:
15523
diff
changeset
|
149 # import py2exe's patched Distribution class |
9926aab3d0b5
setup: fix py2exe generation broken by c3a6ec304055 (issue3116)
Pascal Quantin <pascal.quantin@gmail.com>
parents:
15523
diff
changeset
|
150 from distutils.core import Distribution |
1284
59d07a6bd513
Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1283
diff
changeset
|
151 except ImportError: |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
152 py2exeloaded = False |
1283
f5faab34f32e
Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents:
575
diff
changeset
|
153 |
9807
f359d4f528aa
setup: fix f51d1822d6fd refactoring, propagate env to runcmd
Christian Boos <cboos@bct-technology.com>
parents:
9615
diff
changeset
|
154 def runcmd(cmd, env): |
23392
d66547df8207
plan9: setup check for current python build
Jeff Sickel <jas@corpus-callosum.com>
parents:
23142
diff
changeset
|
155 if (sys.platform == 'plan9' |
d66547df8207
plan9: setup check for current python build
Jeff Sickel <jas@corpus-callosum.com>
parents:
23142
diff
changeset
|
156 and (sys.version_info[0] == 2 and sys.version_info[1] < 7)): |
16383
f5dd179bfa4a
plan9: initial support for plan 9 from bell labs
Steven Stallion <sstallion@gmail.com>
parents:
16209
diff
changeset
|
157 # subprocess kludge to work around issues in half-baked Python |
f5dd179bfa4a
plan9: initial support for plan 9 from bell labs
Steven Stallion <sstallion@gmail.com>
parents:
16209
diff
changeset
|
158 # ports, notably bichued/python: |
f5dd179bfa4a
plan9: initial support for plan 9 from bell labs
Steven Stallion <sstallion@gmail.com>
parents:
16209
diff
changeset
|
159 _, out, err = os.popen3(cmd) |
f5dd179bfa4a
plan9: initial support for plan 9 from bell labs
Steven Stallion <sstallion@gmail.com>
parents:
16209
diff
changeset
|
160 return str(out), str(err) |
f5dd179bfa4a
plan9: initial support for plan 9 from bell labs
Steven Stallion <sstallion@gmail.com>
parents:
16209
diff
changeset
|
161 else: |
f5dd179bfa4a
plan9: initial support for plan 9 from bell labs
Steven Stallion <sstallion@gmail.com>
parents:
16209
diff
changeset
|
162 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
f5dd179bfa4a
plan9: initial support for plan 9 from bell labs
Steven Stallion <sstallion@gmail.com>
parents:
16209
diff
changeset
|
163 stderr=subprocess.PIPE, env=env) |
f5dd179bfa4a
plan9: initial support for plan 9 from bell labs
Steven Stallion <sstallion@gmail.com>
parents:
16209
diff
changeset
|
164 out, err = p.communicate() |
f5dd179bfa4a
plan9: initial support for plan 9 from bell labs
Steven Stallion <sstallion@gmail.com>
parents:
16209
diff
changeset
|
165 return out, err |
13636
4bfff063aed6
setup: fix mac build broken by e42d18538e1d
Jon M. Dugan <jdugan@x1024.net>
parents:
13594
diff
changeset
|
166 |
4bfff063aed6
setup: fix mac build broken by e42d18538e1d
Jon M. Dugan <jdugan@x1024.net>
parents:
13594
diff
changeset
|
167 def runhg(cmd, env): |
4bfff063aed6
setup: fix mac build broken by e42d18538e1d
Jon M. Dugan <jdugan@x1024.net>
parents:
13594
diff
changeset
|
168 out, err = 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
|
169 # 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
|
170 # 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
|
171 # 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
|
172 # 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
|
173 # 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
|
174 err = [e for e in err.splitlines() |
18866
930d54b1fd29
setup.py: properly discard trust warning.
Isaac Jurado <diptongo@gmail.com>
parents:
18754
diff
changeset
|
175 if not e.startswith(b('not trusting file')) \ |
18754
d420ac09f866
setup.py: ignore warnings from obsolete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
18753
diff
changeset
|
176 and not e.startswith(b('warning: Not importing')) \ |
d420ac09f866
setup.py: ignore warnings from obsolete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
18753
diff
changeset
|
177 and not e.startswith(b('obsolete feature not enabled'))] |
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
|
178 if err: |
20696
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
179 printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) |
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
180 printf(b('\n').join([b(' ') + e for e in err]), file=sys.stderr) |
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
|
181 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
|
182 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
|
183 |
f51d1822d6fd
setup: refactor the version string to a subset of tag+tagdist-hash+date
Gilles Moris <gilles.moris@free.fr>
parents:
9539
diff
changeset
|
184 version = '' |
8548
3ccbe42ff72f
setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
8547
diff
changeset
|
185 |
27220
4374d819ccd5
mercurial: implement import hook for handling C/Python modules
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27127
diff
changeset
|
186 # Execute hg out of this directory with a custom environment which takes care |
4374d819ccd5
mercurial: implement import hook for handling C/Python modules
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27127
diff
changeset
|
187 # to not use any hgrc files and do no localization. |
4374d819ccd5
mercurial: implement import hook for handling C/Python modules
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27127
diff
changeset
|
188 env = {'HGMODULEPOLICY': 'py', |
15388
eb6c0d47c3d5
setup: set whole env for running hg even if .hg doesn't exist (issue3073)
Yuya Nishihara <yuya@tcha.org>
parents:
15367
diff
changeset
|
189 'HGRCPATH': '', |
eb6c0d47c3d5
setup: set whole env for running hg even if .hg doesn't exist (issue3073)
Yuya Nishihara <yuya@tcha.org>
parents:
15367
diff
changeset
|
190 'LANGUAGE': 'C'} |
eb6c0d47c3d5
setup: set whole env for running hg even if .hg doesn't exist (issue3073)
Yuya Nishihara <yuya@tcha.org>
parents:
15367
diff
changeset
|
191 if 'LD_LIBRARY_PATH' in os.environ: |
eb6c0d47c3d5
setup: set whole env for running hg even if .hg doesn't exist (issue3073)
Yuya Nishihara <yuya@tcha.org>
parents:
15367
diff
changeset
|
192 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] |
eb6c0d47c3d5
setup: set whole env for running hg even if .hg doesn't exist (issue3073)
Yuya Nishihara <yuya@tcha.org>
parents:
15367
diff
changeset
|
193 if 'SystemRoot' in os.environ: |
eb6c0d47c3d5
setup: set whole env for running hg even if .hg doesn't exist (issue3073)
Yuya Nishihara <yuya@tcha.org>
parents:
15367
diff
changeset
|
194 # Copy SystemRoot into the custom environment for Python 2.6 |
eb6c0d47c3d5
setup: set whole env for running hg even if .hg doesn't exist (issue3073)
Yuya Nishihara <yuya@tcha.org>
parents:
15367
diff
changeset
|
195 # under Windows. Otherwise, the subprocess will fail with |
eb6c0d47c3d5
setup: set whole env for running hg even if .hg doesn't exist (issue3073)
Yuya Nishihara <yuya@tcha.org>
parents:
15367
diff
changeset
|
196 # error 0xc0150004. See: http://bugs.python.org/issue3440 |
eb6c0d47c3d5
setup: set whole env for running hg even if .hg doesn't exist (issue3073)
Yuya Nishihara <yuya@tcha.org>
parents:
15367
diff
changeset
|
197 env['SystemRoot'] = os.environ['SystemRoot'] |
15367
b357a972d6cd
setup: set env global earlier (3073)
Matt Mackall <mpm@selenic.com>
parents:
15215
diff
changeset
|
198 |
8547
548fd7a05373
setup.py: subprocess instead of os.popen, sys.stderr.write instead of print
Christian Ebert <blacktrash@gmx.net>
parents:
8494
diff
changeset
|
199 if os.path.isdir('.hg'): |
17709
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
200 cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n'] |
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
201 numerictags = [t for t in runhg(cmd, env).split() if t[0].isdigit()] |
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
202 hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip() |
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
203 if numerictags: # tag(s) found |
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
204 version = numerictags[-1] |
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
205 if hgid.endswith('+'): # propagate the dirty status to the tag |
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
|
206 version += '+' |
17709
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
207 else: # no tag found |
23647
eb55e09202c8
setup: use changes since latest tag instead of just distance
Siddharth Agarwal <sid0@fb.com>
parents:
23646
diff
changeset
|
208 ltagcmd = [sys.executable, 'hg', 'parents', '--template', |
eb55e09202c8
setup: use changes since latest tag instead of just distance
Siddharth Agarwal <sid0@fb.com>
parents:
23646
diff
changeset
|
209 '{latesttag}'] |
eb55e09202c8
setup: use changes since latest tag instead of just distance
Siddharth Agarwal <sid0@fb.com>
parents:
23646
diff
changeset
|
210 ltag = runhg(ltagcmd, env) |
eb55e09202c8
setup: use changes since latest tag instead of just distance
Siddharth Agarwal <sid0@fb.com>
parents:
23646
diff
changeset
|
211 changessincecmd = [sys.executable, 'hg', 'log', '-T', 'x\n', '-r', |
eb55e09202c8
setup: use changes since latest tag instead of just distance
Siddharth Agarwal <sid0@fb.com>
parents:
23646
diff
changeset
|
212 "only(.,'%s')" % ltag] |
eb55e09202c8
setup: use changes since latest tag instead of just distance
Siddharth Agarwal <sid0@fb.com>
parents:
23646
diff
changeset
|
213 changessince = len(runhg(changessincecmd, env).splitlines()) |
eb55e09202c8
setup: use changes since latest tag instead of just distance
Siddharth Agarwal <sid0@fb.com>
parents:
23646
diff
changeset
|
214 version = '%s+%s-%s' % (ltag, changessince, hgid) |
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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 elif 'latesttag' in kw: |
23646
9641643fac71
setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents:
23392
diff
changeset
|
223 if 'changessincelatesttag' in kw: |
9641643fac71
setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents:
23392
diff
changeset
|
224 version = '%(latesttag)s+%(changessincelatesttag)s-%(node).12s' % kw |
9641643fac71
setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents:
23392
diff
changeset
|
225 else: |
9641643fac71
setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents:
23392
diff
changeset
|
226 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
|
227 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
|
228 version = kw.get('node', '')[:12] |
7632 | 229 |
8548
3ccbe42ff72f
setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
8547
diff
changeset
|
230 if version: |
9031
3b76321aa0de
compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents:
8936
diff
changeset
|
231 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
|
232 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
|
233 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
|
234 f.close() |
3ccbe42ff72f
setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
8547
diff
changeset
|
235 |
8493
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
236 |
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
237 try: |
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
238 from mercurial import __version__ |
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
239 version = __version__.version |
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
240 except ImportError: |
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
241 version = 'unknown' |
7632 | 242 |
15460
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
243 class hgbuild(build): |
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
244 # Insert hgbuildmo first so that files in mercurial/locale/ are found |
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
245 # when build_py is run next. |
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
246 sub_commands = [('build_mo', None), |
16683 | 247 |
248 # We also need build_ext before build_py. Otherwise, when 2to3 is | |
249 # called (in build_py), it will not find osutil & friends, | |
250 # thinking that those modules are global and, consequently, making | |
251 # a mess, now that all module imports are global. | |
252 | |
15494
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
253 ('build_ext', build.has_ext_modules), |
15460
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
254 ] + build.sub_commands |
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
255 |
15523
f9da84a950d0
setup: backout 8504699d1aa6
Matt Mackall <mpm@selenic.com>
parents:
15500
diff
changeset
|
256 class hgbuildmo(build): |
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
257 |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
258 description = "build translations (.mo files)" |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
259 |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
260 def run(self): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
261 if not find_executable('msgfmt'): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
262 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
|
263 "will be built") |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
264 return |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
265 |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
266 podir = 'i18n' |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
267 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
|
268 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
|
269 return |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
270 |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
271 join = os.path.join |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
272 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
|
273 if not po.endswith('.po'): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
274 continue |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
275 pofile = join(podir, po) |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
276 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
|
277 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
|
278 mobuildfile = join('mercurial', mofile) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
279 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
|
280 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
|
281 # 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
|
282 cmd.append('-c') |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
283 self.mkpath(join('mercurial', modir)) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
284 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
|
285 |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
286 |
15458
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
287 class hgdist(Distribution): |
24192
390410a6545d
setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents:
24191
diff
changeset
|
288 pure = ispypy |
15458
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
289 |
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
290 global_options = Distribution.global_options + \ |
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
291 [('pure', None, "use pure (slow) Python " |
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
292 "code instead of C extensions"), |
15494
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
293 ('c2to3', None, "(experimental!) convert " |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
294 "code with 2to3"), |
15458
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
295 ] |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
296 |
15459
434c48e981b8
setup: has_ext_modules always returns false when pure is specified
Simon Heimberg <simohe@besonet.ch>
parents:
15458
diff
changeset
|
297 def has_ext_modules(self): |
434c48e981b8
setup: has_ext_modules always returns false when pure is specified
Simon Heimberg <simohe@besonet.ch>
parents:
15458
diff
changeset
|
298 # self.ext_modules is emptied in hgbuildpy.finalize_options which is |
434c48e981b8
setup: has_ext_modules always returns false when pure is specified
Simon Heimberg <simohe@besonet.ch>
parents:
15458
diff
changeset
|
299 # too late for some cases |
434c48e981b8
setup: has_ext_modules always returns false when pure is specified
Simon Heimberg <simohe@besonet.ch>
parents:
15458
diff
changeset
|
300 return not self.pure and Distribution.has_ext_modules(self) |
434c48e981b8
setup: has_ext_modules always returns false when pure is specified
Simon Heimberg <simohe@besonet.ch>
parents:
15458
diff
changeset
|
301 |
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
302 class hgbuildext(build_ext): |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
303 |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
304 def build_extension(self, ext): |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
305 try: |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
306 build_ext.build_extension(self, ext) |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
307 except CCompilerError: |
12501
98f21e4d9633
setup: slight simplification
Martin Geisler <mg@lazybytes.net>
parents:
11533
diff
changeset
|
308 if not getattr(ext, 'optional', False): |
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
309 raise |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
310 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
|
311 ext.name) |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
312 |
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
313 class hgbuildscripts(build_scripts): |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
314 def run(self): |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
315 if os.name != 'nt': |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
316 return build_scripts.run(self) |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
317 |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
318 exebuilt = False |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
319 try: |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
320 self.run_command('build_hgexe') |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
321 exebuilt = True |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
322 except (DistutilsError, CCompilerError): |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
323 log.warn('failed to build optional hg.exe') |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
324 |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
325 if exebuilt: |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
326 # Copying hg.exe to the scripts build directory ensures it is |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
327 # installed by the install_scripts command. |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
328 hgexecommand = self.get_finalized_command('build_hgexe') |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
329 dest = os.path.join(self.build_dir, 'hg.exe') |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
330 self.mkpath(self.build_dir) |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
331 self.copy_file(hgexecommand.hgexepath, dest) |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
332 |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
333 # Remove hg.bat because it is redundant with hg.exe. |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
334 self.scripts.remove('contrib/win32/hg.bat') |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
335 |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
336 return build_scripts.run(self) |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
337 |
10000
16f49d671c7f
setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents:
9999
diff
changeset
|
338 class hgbuildpy(build_py): |
15494
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
339 if convert2to3: |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
340 fixer_names = sorted(set(getfixers("lib2to3.fixes") + |
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
341 getfixers("hgfixes"))) |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
342 |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
343 def finalize_options(self): |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
344 build_py.finalize_options(self) |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
345 |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
346 if self.distribution.pure: |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
347 self.distribution.ext_modules = [] |
12649
6c0e1aee1b19
setup: user-friendly error message if Python headers are missing
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12501
diff
changeset
|
348 else: |
18905
012780620d4f
setup: make error message for missing Python headers more helpful
Mads Kiilerich <mads@kiilerich.com>
parents:
18900
diff
changeset
|
349 h = os.path.join(get_python_inc(), 'Python.h') |
012780620d4f
setup: make error message for missing Python headers more helpful
Mads Kiilerich <mads@kiilerich.com>
parents:
18900
diff
changeset
|
350 if not os.path.exists(h): |
16683 | 351 raise SystemExit('Python headers are required to build ' |
18905
012780620d4f
setup: make error message for missing Python headers more helpful
Mads Kiilerich <mads@kiilerich.com>
parents:
18900
diff
changeset
|
352 'Mercurial but weren\'t found in %s' % h) |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
353 |
27222
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
354 def copy_file(self, *args, **kwargs): |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
355 dst, copied = build_py.copy_file(self, *args, **kwargs) |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
356 |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
357 if copied and dst.endswith('__init__.py'): |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
358 if self.distribution.pure: |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
359 modulepolicy = 'py' |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
360 else: |
27222
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
361 modulepolicy = 'c' |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
362 content = open(dst, 'rb').read() |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
363 content = content.replace(b'@MODULELOADPOLICY@', |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
364 modulepolicy.encode(libdir_escape)) |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
365 with open(dst, 'wb') as fh: |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
366 fh.write(content) |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
367 |
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
368 return dst, copied |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
369 |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
370 class buildhgextindex(Command): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
371 description = 'generate prebuilt index of hgext (for frozen package)' |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
372 user_options = [] |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
373 _indexfilename = 'hgext/__index__.py' |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
374 |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
375 def initialize_options(self): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
376 pass |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
377 |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
378 def finalize_options(self): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
379 pass |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
380 |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
381 def run(self): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
382 if os.path.exists(self._indexfilename): |
21229
54d7657d7d1e
setup.py, make: avoid problems with outdated, existing hgext/__index__.py*
Thomas Arendsen Hein <thomas@intevation.de>
parents:
21038
diff
changeset
|
383 f = open(self._indexfilename, 'w') |
54d7657d7d1e
setup.py, make: avoid problems with outdated, existing hgext/__index__.py*
Thomas Arendsen Hein <thomas@intevation.de>
parents:
21038
diff
changeset
|
384 f.write('# empty\n') |
54d7657d7d1e
setup.py, make: avoid problems with outdated, existing hgext/__index__.py*
Thomas Arendsen Hein <thomas@intevation.de>
parents:
21038
diff
changeset
|
385 f.close() |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
386 |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
387 # here no extension enabled, disabled() lists up everything |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
388 code = ('import pprint; from mercurial import extensions; ' |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
389 'pprint.pprint(extensions.disabled())') |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
390 out, err = runcmd([sys.executable, '-c', code], env) |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
391 if err: |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
392 raise DistutilsExecError(err) |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
393 |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
394 f = open(self._indexfilename, 'w') |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
395 f.write('# this file is autogenerated by setup.py\n') |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
396 f.write('docs = ') |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
397 f.write(out) |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
398 f.close() |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
399 |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
400 class buildhgexe(build_ext): |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
401 description = 'compile hg.exe from mercurial/exewrapper.c' |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
402 |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
403 def build_extensions(self): |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
404 if os.name != 'nt': |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
405 return |
17246
bf5bb38bcc7c
setup: fix build_hgexe for mingw32 compiler
Adrian Buehlmann <adrian@cadifra.com>
parents:
17121
diff
changeset
|
406 if isinstance(self.compiler, HackedMingw32CCompiler): |
bf5bb38bcc7c
setup: fix build_hgexe for mingw32 compiler
Adrian Buehlmann <adrian@cadifra.com>
parents:
17121
diff
changeset
|
407 self.compiler.compiler_so = self.compiler.compiler # no -mdll |
bf5bb38bcc7c
setup: fix build_hgexe for mingw32 compiler
Adrian Buehlmann <adrian@cadifra.com>
parents:
17121
diff
changeset
|
408 self.compiler.dll_libraries = [] # no -lmsrvc90 |
17732
93d97a212559
exewrapper: adapt for legacy HackableMercurial
Adrian Buehlmann <adrian@cadifra.com>
parents:
17709
diff
changeset
|
409 hv = sys.hexversion |
93d97a212559
exewrapper: adapt for legacy HackableMercurial
Adrian Buehlmann <adrian@cadifra.com>
parents:
17709
diff
changeset
|
410 pythonlib = 'python%d%d' % (hv >> 24, (hv >> 16) & 0xff) |
93d97a212559
exewrapper: adapt for legacy HackableMercurial
Adrian Buehlmann <adrian@cadifra.com>
parents:
17709
diff
changeset
|
411 f = open('mercurial/hgpythonlib.h', 'wb') |
93d97a212559
exewrapper: adapt for legacy HackableMercurial
Adrian Buehlmann <adrian@cadifra.com>
parents:
17709
diff
changeset
|
412 f.write('/* this file is autogenerated by setup.py */\n') |
93d97a212559
exewrapper: adapt for legacy HackableMercurial
Adrian Buehlmann <adrian@cadifra.com>
parents:
17709
diff
changeset
|
413 f.write('#define HGPYTHONLIB "%s"\n' % pythonlib) |
93d97a212559
exewrapper: adapt for legacy HackableMercurial
Adrian Buehlmann <adrian@cadifra.com>
parents:
17709
diff
changeset
|
414 f.close() |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
415 objects = self.compiler.compile(['mercurial/exewrapper.c'], |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
416 output_dir=self.build_temp) |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
417 dir = os.path.dirname(self.get_ext_fullpath('dummy')) |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
418 target = os.path.join(dir, 'hg') |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
419 self.compiler.link_executable(objects, target, |
17732
93d97a212559
exewrapper: adapt for legacy HackableMercurial
Adrian Buehlmann <adrian@cadifra.com>
parents:
17709
diff
changeset
|
420 libraries=[], |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
421 output_dir=self.build_temp) |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
422 |
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
423 @property |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
424 def hgexepath(self): |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
425 dir = os.path.dirname(self.get_ext_fullpath('dummy')) |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
426 return os.path.join(self.build_temp, dir, 'hg.exe') |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
427 |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
428 class hginstalllib(install_lib): |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
429 ''' |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
430 This is a specialization of install_lib that replaces the copy_file used |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
431 there so that it supports setting the mode of files after copying them, |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
432 instead of just preserving the mode that the files originally had. If your |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
433 system has a umask of something like 027, preserving the permissions when |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
434 copying will lead to a broken install. |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
435 |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
436 Note that just passing keep_permissions=False to copy_file would be |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
437 insufficient, as it might still be applying a umask. |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
438 ''' |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
439 |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
440 def run(self): |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
441 realcopyfile = file_util.copy_file |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
442 def copyfileandsetmode(*args, **kwargs): |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
443 src, dst = args[0], args[1] |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
444 dst, copied = realcopyfile(*args, **kwargs) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
445 if copied: |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
446 st = os.stat(src) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
447 # Persist executable bit (apply it to group and other if user |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
448 # has it) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
449 if st[stat.ST_MODE] & stat.S_IXUSR: |
24941
9c1942635c1f
setup: hide octal literals inside strings so they're portable (issue4554)
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
450 setmode = int('0755', 8) |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
451 else: |
24941
9c1942635c1f
setup: hide octal literals inside strings so they're portable (issue4554)
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
452 setmode = int('0644', 8) |
9c1942635c1f
setup: hide octal literals inside strings so they're portable (issue4554)
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
453 m = stat.S_IMODE(st[stat.ST_MODE]) |
9c1942635c1f
setup: hide octal literals inside strings so they're portable (issue4554)
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
454 m = (m & ~int('0777', 8)) | setmode |
9c1942635c1f
setup: hide octal literals inside strings so they're portable (issue4554)
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
455 os.chmod(dst, m) |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
456 file_util.copy_file = copyfileandsetmode |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
457 try: |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
458 install_lib.run(self) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
459 finally: |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
460 file_util.copy_file = realcopyfile |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
461 |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
462 class hginstallscripts(install_scripts): |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
463 ''' |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
464 This is a specialization of install_scripts that replaces the @LIBDIR@ with |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
465 the configured directory for modules. If possible, the path is made relative |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
466 to the directory for scripts. |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
467 ''' |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
468 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
469 def initialize_options(self): |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
470 install_scripts.initialize_options(self) |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
471 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
472 self.install_lib = None |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
473 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
474 def finalize_options(self): |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
475 install_scripts.finalize_options(self) |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
476 self.set_undefined_options('install', |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
477 ('install_lib', 'install_lib')) |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
478 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
479 def run(self): |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
480 install_scripts.run(self) |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
481 |
27269
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
482 # It only makes sense to replace @LIBDIR@ with the install path if |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
483 # the install path is known. For wheels, the logic below calculates |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
484 # the libdir to be "../..". This is because the internal layout of a |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
485 # wheel archive looks like: |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
486 # |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
487 # mercurial-3.6.1.data/scripts/hg |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
488 # mercurial/__init__.py |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
489 # |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
490 # When installing wheels, the subdirectories of the "<pkg>.data" |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
491 # directory are translated to system local paths and files therein |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
492 # are copied in place. The mercurial/* files are installed into the |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
493 # site-packages directory. However, the site-packages directory |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
494 # isn't known until wheel install time. This means we have no clue |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
495 # at wheel generation time what the installed site-packages directory |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
496 # will be. And, wheels don't appear to provide the ability to register |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
497 # custom code to run during wheel installation. This all means that |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
498 # we can't reliably set the libdir in wheels: the default behavior |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
499 # of looking in sys.path must do. |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
500 |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
501 if (os.path.splitdrive(self.install_dir)[0] != |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
502 os.path.splitdrive(self.install_lib)[0]): |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
503 # can't make relative paths from one drive to another, so use an |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
504 # absolute path instead |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
505 libdir = self.install_lib |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
506 else: |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
507 common = os.path.commonprefix((self.install_dir, self.install_lib)) |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
508 rest = self.install_dir[len(common):] |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
509 uplevel = len([n for n in os.path.split(rest) if n]) |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
510 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
511 libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):] |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
512 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
513 for outfile in self.outfiles: |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12865
diff
changeset
|
514 fp = open(outfile, 'rb') |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12865
diff
changeset
|
515 data = fp.read() |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12865
diff
changeset
|
516 fp.close() |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
517 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
518 # skip binary files |
15494
7a7a1c594daf
setup: support executing with python3 including 2to3
Simon Heimberg <simohe@besonet.ch>
parents:
15493
diff
changeset
|
519 if b('\0') in data: |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
520 continue |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
521 |
27269
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
522 # During local installs, the shebang will be rewritten to the final |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
523 # install path. During wheel packaging, the shebang has a special |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
524 # value. |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
525 if data.startswith(b'#!python'): |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
526 log.info('not rewriting @LIBDIR@ in %s because install path ' |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
527 'not known' % outfile) |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
528 continue |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
529 |
20696
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
530 data = data.replace(b('@LIBDIR@'), libdir.encode(libdir_escape)) |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12865
diff
changeset
|
531 fp = open(outfile, 'wb') |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12865
diff
changeset
|
532 fp.write(data) |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12865
diff
changeset
|
533 fp.close() |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
534 |
15460
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
535 cmdclass = {'build': hgbuild, |
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
536 'build_mo': hgbuildmo, |
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
537 'build_ext': hgbuildext, |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
538 'build_py': hgbuildpy, |
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
539 'build_scripts': hgbuildscripts, |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
540 'build_hgextindex': buildhgextindex, |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
541 'install_lib': hginstalllib, |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
542 'install_scripts': hginstallscripts, |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
543 'build_hgexe': buildhgexe, |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
544 } |
3238
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
545 |
16775
e6af8676302f
httpclient: omit tests for the client since we don't run them anyway
Augie Fackler <raf@durin42.com>
parents:
16689
diff
changeset
|
546 packages = ['mercurial', 'mercurial.hgweb', 'mercurial.httpclient', |
27222
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
547 'mercurial.pure', |
15215
c41078b9d0b8
setup: add largefiles to list of packages
Na'Tosha Bard <natosha@unity3d.com>
parents:
15167
diff
changeset
|
548 'hgext', 'hgext.convert', 'hgext.highlight', 'hgext.zeroconf', |
c41078b9d0b8
setup: add largefiles to list of packages
Na'Tosha Bard <natosha@unity3d.com>
parents:
15167
diff
changeset
|
549 'hgext.largefiles'] |
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
|
550 |
19724
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
551 common_depends = ['mercurial/util.h'] |
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
552 |
25073
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
553 osutil_ldflags = [] |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
554 |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
555 if sys.platform == 'darwin': |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
556 osutil_ldflags += ['-framework', 'ApplicationServices'] |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
557 |
10000
16f49d671c7f
setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents:
9999
diff
changeset
|
558 extmodules = [ |
19724
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
559 Extension('mercurial.base85', ['mercurial/base85.c'], |
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
560 depends=common_depends), |
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
561 Extension('mercurial.bdiff', ['mercurial/bdiff.c'], |
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
562 depends=common_depends), |
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
563 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'], |
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
564 depends=common_depends), |
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
565 Extension('mercurial.mpatch', ['mercurial/mpatch.c'], |
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
566 depends=common_depends), |
18900
02ee846b246a
scmutil: rewrite dirs in C, use if available
Bryan O'Sullivan <bryano@fb.com>
parents:
18866
diff
changeset
|
567 Extension('mercurial.parsers', ['mercurial/dirs.c', |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
24192
diff
changeset
|
568 'mercurial/manifest.c', |
18900
02ee846b246a
scmutil: rewrite dirs in C, use if available
Bryan O'Sullivan <bryano@fb.com>
parents:
18866
diff
changeset
|
569 'mercurial/parsers.c', |
19724
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
570 'mercurial/pathencode.c'], |
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
571 depends=common_depends), |
25074
0021ad4c2309
setup: integrate osutil C extension into extmodules initialization
Adrian Buehlmann <adrian@cadifra.com>
parents:
25073
diff
changeset
|
572 Extension('mercurial.osutil', ['mercurial/osutil.c'], |
0021ad4c2309
setup: integrate osutil C extension into extmodules initialization
Adrian Buehlmann <adrian@cadifra.com>
parents:
25073
diff
changeset
|
573 extra_link_args=osutil_ldflags, |
0021ad4c2309
setup: integrate osutil C extension into extmodules initialization
Adrian Buehlmann <adrian@cadifra.com>
parents:
25073
diff
changeset
|
574 depends=common_depends), |
5396
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
575 ] |
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
576 |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
577 try: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
578 from distutils import cygwinccompiler |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
579 |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
580 # the -mno-cygwin option has been deprecated for years |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
581 compiler = cygwinccompiler.Mingw32CCompiler |
17121
d13f47c800fd
setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents:
17061
diff
changeset
|
582 |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
583 class HackedMingw32CCompiler(cygwinccompiler.Mingw32CCompiler): |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
584 def __init__(self, *args, **kwargs): |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
585 compiler.__init__(self, *args, **kwargs) |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
586 for i in 'compiler compiler_so linker_exe linker_so'.split(): |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
587 try: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
588 getattr(self, i).remove('-mno-cygwin') |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
589 except ValueError: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
590 pass |
17121
d13f47c800fd
setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents:
17061
diff
changeset
|
591 |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
592 cygwinccompiler.Mingw32CCompiler = HackedMingw32CCompiler |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
593 except ImportError: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
594 # the cygwinccompiler package is not available on some Python |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
595 # distributions like the ones from the optware project for Synology |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
596 # DiskStation boxes |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
597 class HackedMingw32CCompiler(object): |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
598 pass |
17121
d13f47c800fd
setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents:
17061
diff
changeset
|
599 |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
600 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo', |
22575
d7f7f1860f00
ssl: on OS X, use a dummy cert to trick Python/OpenSSL to use system CA certs
Mads Kiilerich <madski@unity3d.com>
parents:
22358
diff
changeset
|
601 'help/*.txt', |
23142
c4ce077588d0
config: introduce "built-in" default configuration settings in default.d
Mads Kiilerich <madski@unity3d.com>
parents:
22640
diff
changeset
|
602 'default.d/*.rc', |
22575
d7f7f1860f00
ssl: on OS X, use a dummy cert to trick Python/OpenSSL to use system CA certs
Mads Kiilerich <madski@unity3d.com>
parents:
22358
diff
changeset
|
603 'dummycert.pem']} |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
604 |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
605 def ordinarypath(p): |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
606 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
|
607 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
608 for root in ('templates',): |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
609 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
|
610 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
|
611 dirs[:] = filter(ordinarypath, dirs) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
612 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
|
613 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
|
614 packagedata['mercurial'].append(f) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
615 |
7648
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
616 datafiles = [] |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
617 setupversion = version |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
618 extra = {} |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
619 |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
620 if py2exeloaded: |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
621 extra['console'] = [ |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
622 {'script':'hg', |
24191 | 623 'copyright':'Copyright (C) 2005-2015 Matt Mackall and others', |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
624 'product_version':version}] |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
625 # sub command of 'build' because 'py2exe' does not handle sub_commands |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
626 build.sub_commands.insert(0, ('build_hgextindex', None)) |
25409
95e042d77a5f
wix: move library.zip and all *.pyd into a lib/ folder
Steve Borho <steve@borho.org>
parents:
25089
diff
changeset
|
627 # put dlls in sub directory so that they won't pollute PATH |
95e042d77a5f
wix: move library.zip and all *.pyd into a lib/ folder
Steve Borho <steve@borho.org>
parents:
25089
diff
changeset
|
628 extra['zipfile'] = 'lib/library.zip' |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
629 |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
630 if os.name == 'nt': |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
631 # 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
|
632 # 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
|
633 setupversion = version.split('+', 1)[0] |
7648
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
634 |
13583
e42d18538e1d
fix compiling of extensions for OS X and XCode 4.0
Alexander Solovyov <alexander@solovyov.net>
parents:
13400
diff
changeset
|
635 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'): |
16187
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
636 version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines() |
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
637 if version: |
16209
5536770b3c88
setup.py: don't call splitlines twice on the output of xcodebuild (issue3277)
Brendan Cully <brendan@kublai.com>
parents:
16187
diff
changeset
|
638 version = version[0] |
25043
facaceeb85ac
setup: decode xcode version number on python3
Augie Fackler <augie@google.com>
parents:
25009
diff
changeset
|
639 if sys.version_info[0] == 3: |
facaceeb85ac
setup: decode xcode version number on python3
Augie Fackler <augie@google.com>
parents:
25009
diff
changeset
|
640 version = version.decode('utf-8') |
16187
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
641 xcode4 = (version.startswith('Xcode') and |
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
642 StrictVersion(version.split()[1]) >= StrictVersion('4.0')) |
21558
8b482d49563b
setup: make Xcode 5.1 check less specific
Matt Mackall <mpm@selenic.com>
parents:
21229
diff
changeset
|
643 xcode51 = re.match(r'^Xcode\s+5\.1', version) is not None |
16187
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
644 else: |
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
645 # xcodebuild returns empty on OS X Lion with XCode 4.3 not |
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
646 # installed, but instead with only command-line tools. Assume |
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
647 # that only happens on >= Lion, thus no PPC support. |
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
648 xcode4 = True |
21038
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
649 xcode51 = False |
16187
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
650 |
21038
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
651 # XCode 4.0 dropped support for ppc architecture, which is hardcoded in |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
652 # distutils.sysconfig |
16187
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
653 if xcode4: |
14324
d3a49a52f117
Hardcoding ARCHFLAGS breaks the build against fink's python
Brendan Cully <brendan@kublai.com>
parents:
14295
diff
changeset
|
654 os.environ['ARCHFLAGS'] = '' |
13583
e42d18538e1d
fix compiling of extensions for OS X and XCode 4.0
Alexander Solovyov <alexander@solovyov.net>
parents:
13400
diff
changeset
|
655 |
21038
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
656 # XCode 5.1 changes clang such that it now fails to compile if the |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
657 # -mno-fused-madd flag is passed, but the version of Python shipped with |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
658 # OS X 10.9 Mavericks includes this flag. This causes problems in all |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
659 # C extension modules, and a bug has been filed upstream at |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
660 # http://bugs.python.org/issue21244. We also need to patch this here |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
661 # so Mercurial can continue to compile in the meantime. |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
662 if xcode51: |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
663 cflags = get_config_var('CFLAGS') |
21839
f266be73f764
setup: fixed for Pythons which don't have a CFLAGS
Alex Gaynor <alex.gaynor@gmail.com>
parents:
21229
diff
changeset
|
664 if cflags and re.search(r'-mno-fused-madd\b', cflags) is not None: |
21038
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
665 os.environ['CFLAGS'] = ( |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
666 os.environ.get('CFLAGS', '') + ' -Qunused-arguments') |
440fbe52b4a8
setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
Kent Frazier <kentfrazier@gmail.com>
parents:
20697
diff
changeset
|
667 |
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
|
668 setup(name='mercurial', |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
669 version=setupversion, |
18753
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
670 author='Matt Mackall and many others', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
671 author_email='mercurial@selenic.com', |
26421
4b0fc75f9403
urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents:
25409
diff
changeset
|
672 url='https://mercurial-scm.org/', |
4b0fc75f9403
urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents:
25409
diff
changeset
|
673 download_url='https://mercurial-scm.org/release/', |
18753
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
674 description=('Fast scalable distributed SCM (revision control, version ' |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
675 'control) system'), |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
676 long_description=('Mercurial is a distributed SCM tool written in Python.' |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
677 ' It is used by a number of large projects that require' |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
678 ' fast, reliable distributed revision control, such as ' |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
679 'Mozilla.'), |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
680 license='GNU GPLv2 or any later version', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
681 classifiers=[ |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
682 'Development Status :: 6 - Mature', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
683 'Environment :: Console', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
684 'Intended Audience :: Developers', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
685 'Intended Audience :: System Administrators', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
686 'License :: OSI Approved :: GNU General Public License (GPL)', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
687 'Natural Language :: Danish', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
688 'Natural Language :: English', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
689 'Natural Language :: German', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
690 'Natural Language :: Italian', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
691 'Natural Language :: Japanese', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
692 'Natural Language :: Portuguese (Brazilian)', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
693 'Operating System :: Microsoft :: Windows', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
694 'Operating System :: OS Independent', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
695 'Operating System :: POSIX', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
696 'Programming Language :: C', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
697 'Programming Language :: Python', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
698 'Topic :: Software Development :: Version Control', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
699 ], |
6513
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
700 scripts=scripts, |
6239
39cfcef4f463
Add inotify extension
Bryan O'Sullivan <bos@serpentine.com>
parents:
6009
diff
changeset
|
701 packages=packages, |
10000
16f49d671c7f
setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents:
9999
diff
changeset
|
702 ext_modules=extmodules, |
7648
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
703 data_files=datafiles, |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
704 package_data=packagedata, |
3238
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
705 cmdclass=cmdclass, |
15458
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
706 distclass=hgdist, |
20687
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
707 options={'py2exe': {'packages': ['hgext', 'email']}, |
22358
198e2da3ee20
osx: create dmg with installer instead of zip
Mads Kiilerich <madski@unity3d.com>
parents:
22198
diff
changeset
|
708 'bdist_mpkg': {'zipdist': False, |
20687
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
709 'license': 'COPYING', |
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
710 'readme': 'contrib/macosx/Readme.html', |
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
711 'welcome': 'contrib/macosx/Welcome.html', |
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
712 }, |
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
713 }, |
3893 | 714 **extra) |