Mercurial > hg-stable
annotate setup.py @ 37445:cc4b569975ed
tests: call rawsize() directly
rawsize() is not reimplemented outside of revlog. I'm not sure why
this code was insisting it call a specific implementation. Changing
it to call rawsize() on the repo.file(f) result seems to work just
fine.
Differential Revision: https://phab.mercurial-scm.org/D3153
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 05 Apr 2018 17:44:18 -0700 |
parents | 611e466662af |
children | 2025bf60adb2 |
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 |
33591
ee11d18fcd3c
setup: fix mistake that prevented Python 3 from being excluded
Augie Fackler <augie@google.com>
parents:
33589
diff
changeset
|
7 import os |
ee11d18fcd3c
setup: fix mistake that prevented Python 3 from being excluded
Augie Fackler <augie@google.com>
parents:
33589
diff
changeset
|
8 |
33587
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
9 supportedpy = '~= 2.7' |
33591
ee11d18fcd3c
setup: fix mistake that prevented Python 3 from being excluded
Augie Fackler <augie@google.com>
parents:
33589
diff
changeset
|
10 if os.environ.get('HGALLOWPYTHON3', ''): |
33587
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
11 # Mercurial will never work on Python 3 before 3.5 due to a lack |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
12 # of % formatting on bytestrings, and can't work on 3.6.0 or 3.6.1 |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
13 # due to a bug in % formatting in bytestrings. |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
14 # |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
15 # TODO: when we actually work on Python 3, use this string as the |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
16 # actual supportedpy string. |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
17 supportedpy = ','.join([ |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
18 '>=2.7', |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
19 '!=3.0.*', |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
20 '!=3.1.*', |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
21 '!=3.2.*', |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
22 '!=3.3.*', |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
23 '!=3.4.*', |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
24 '!=3.6.0', |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
25 '!=3.6.1', |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
26 ]) |
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33131
diff
changeset
|
27 |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
28 import sys, platform |
11532
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
29 if sys.version_info[0] >= 3: |
20696
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
30 printf = eval('print') |
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
31 libdir_escape = 'unicode_escape' |
35255
d73ccc63b8f9
setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
35238
diff
changeset
|
32 def sysstr(s): |
d73ccc63b8f9
setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
35238
diff
changeset
|
33 return s.decode('latin-1') |
11532
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
34 else: |
20696
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
35 libdir_escape = 'string_escape' |
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
36 def printf(*args, **kwargs): |
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
37 f = kwargs.get('file', sys.stdout) |
77ab0abb08a0
setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents:
20687
diff
changeset
|
38 end = kwargs.get('end', '\n') |
27348
83a8219fb790
setup.py: use bytes literals
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27269
diff
changeset
|
39 f.write(b' '.join(args) + end) |
35255
d73ccc63b8f9
setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
35238
diff
changeset
|
40 def sysstr(s): |
d73ccc63b8f9
setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
35238
diff
changeset
|
41 return s |
11532
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
42 |
33588
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
43 # Attempt to guide users to a modern pip - this means that 2.6 users |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
44 # should have a chance of getting a 4.2 release, and when we ratchet |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
45 # the version requirement forward again hopefully everyone will get |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
46 # something that works for them. |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
47 if sys.version_info < (2, 7, 0, 'final'): |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
48 pip_message = ('This may be due to an out of date pip. ' |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
49 'Make sure you have pip >= 9.0.1.') |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
50 try: |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
51 import pip |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
52 pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]]) |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
53 if pip_version < (9, 0, 1) : |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
54 pip_message = ( |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
55 'Your pip version is out of date, please install ' |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
56 'pip >= 9.0.1. pip {} detected.'.format(pip.__version__)) |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
57 else: |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
58 # pip is new enough - it must be something else |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
59 pip_message = '' |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
60 except Exception: |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
61 pass |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
62 error = """ |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
63 Mercurial does not support Python older than 2.7. |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
64 Python {py} detected. |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
65 {pip} |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
66 """.format(py=sys.version_info, pip=pip_message) |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
67 printf(error, file=sys.stderr) |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
68 sys.exit(1) |
025017423e53
setup: add extra logic to try and recommend a new pip on bad Python
Augie Fackler <augie@google.com>
parents:
33587
diff
changeset
|
69 |
35830
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
70 # We don't yet officially support Python 3. But we want to allow developers to |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
71 # hack on. Detect and disallow running on Python 3 by default. But provide a |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
72 # backdoor to enable working on Python 3. |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
73 if sys.version_info[0] != 2: |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
74 badpython = True |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
75 |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
76 # Allow Python 3 from source checkouts. |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
77 if os.path.isdir('.hg'): |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
78 badpython = False |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
79 |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
80 if badpython: |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
81 error = """ |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
82 Mercurial only supports Python 2.7. |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
83 Python {py} detected. |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
84 Please re-run with Python 2.7. |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
85 """.format(py=sys.version_info) |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
86 |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
87 printf(error, file=sys.stderr) |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
88 sys.exit(1) |
fb39f6a8a864
setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35774
diff
changeset
|
89 |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
90 # Solaris Python packaging brain damage |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
91 try: |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
92 import hashlib |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
93 sha = hashlib.sha1() |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
94 except ImportError: |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
95 try: |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
96 import sha |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
21840
diff
changeset
|
97 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
|
98 except ImportError: |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
99 raise SystemExit( |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
100 "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
|
101 |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
102 try: |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
103 import zlib |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
21840
diff
changeset
|
104 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
|
105 except ImportError: |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
106 raise SystemExit( |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
107 "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
|
108 |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
109 # 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
|
110 isironpython = False |
10761
16a13fdb4b36
setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10521
diff
changeset
|
111 try: |
16683 | 112 isironpython = (platform.python_implementation() |
113 .lower().find("ironpython") != -1) | |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
114 except AttributeError: |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
115 pass |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
116 |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
117 if isironpython: |
15492
36f076d03b34
setup: make script executable with python3
Simon Heimberg <simohe@besonet.ch>
parents:
15460
diff
changeset
|
118 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
|
119 else: |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
120 try: |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
121 import bz2 |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
21840
diff
changeset
|
122 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
|
123 except ImportError: |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
124 raise SystemExit( |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
125 "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
|
126 |
24192
390410a6545d
setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents:
24191
diff
changeset
|
127 ispypy = "PyPy" in sys.version |
390410a6545d
setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents:
24191
diff
changeset
|
128 |
29020
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
129 import ctypes |
33591
ee11d18fcd3c
setup: fix mistake that prevented Python 3 from being excluded
Augie Fackler <augie@google.com>
parents:
33589
diff
changeset
|
130 import 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
|
131 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
|
132 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
|
133 import tempfile |
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
134 from distutils import log |
31298
718a57e95a89
setup: use setuptools on Windows (issue5400)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30869
diff
changeset
|
135 # We have issues with setuptools on some platforms and builders. Until |
718a57e95a89
setup: use setuptools on Windows (issue5400)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30869
diff
changeset
|
136 # those are resolved, setuptools is opt-in except for platforms where |
718a57e95a89
setup: use setuptools on Windows (issue5400)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30869
diff
changeset
|
137 # we don't have issues. |
33600
47829b89c8c6
setup: silence warning of unknown option python_requires on distutils
Yuya Nishihara <yuya@tcha.org>
parents:
33599
diff
changeset
|
138 issetuptools = (os.name == 'nt' or 'FORCE_SETUPTOOLS' in os.environ) |
47829b89c8c6
setup: silence warning of unknown option python_requires on distutils
Yuya Nishihara <yuya@tcha.org>
parents:
33599
diff
changeset
|
139 if issetuptools: |
26600
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
140 from setuptools import setup |
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
141 else: |
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
142 from distutils.core import setup |
30418
ce9a3033c118
setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents:
30356
diff
changeset
|
143 from distutils.ccompiler import new_compiler |
26600
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
144 from distutils.core import Command, Extension |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
145 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
|
146 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
|
147 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
|
148 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
|
149 from distutils.command.build_scripts import build_scripts |
32670
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32539
diff
changeset
|
150 from distutils.command.install import install |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 CCompilerError, |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
157 DistutilsError, |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
158 DistutilsExecError, |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
159 ) |
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
|
160 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
|
161 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
|
162 |
35238
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
163 def write_if_changed(path, content): |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
164 """Write content to a file iff the content hasn't changed.""" |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
165 if os.path.exists(path): |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
166 with open(path, 'rb') as fh: |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
167 current = fh.read() |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
168 else: |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
169 current = b'' |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
170 |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
171 if current != content: |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
172 with open(path, 'wb') as fh: |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
173 fh.write(content) |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
174 |
6513
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
175 scripts = ['hg'] |
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
176 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
|
177 # 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
|
178 scripts.append('contrib/win32/hg.bat') |
3893 | 179 |
31565
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31325
diff
changeset
|
180 def cancompile(cc, code): |
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
|
181 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
|
182 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
|
183 try: |
31565
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31325
diff
changeset
|
184 fname = os.path.join(tmpdir, 'testcomp.c') |
25089
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
185 f = open(fname, 'w') |
31565
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31325
diff
changeset
|
186 f.write(code) |
25089
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
187 f.close() |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
188 # 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
|
189 # from the compiler. |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
190 # 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
|
191 # for a function on Windows. |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
192 devnull = open('/dev/null', 'w') |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
193 oldstderr = os.dup(sys.stderr.fileno()) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
194 os.dup2(devnull.fileno(), sys.stderr.fileno()) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
195 objects = cc.compile([fname], output_dir=tmpdir) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
196 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
|
197 return True |
25089
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
198 except Exception: |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 |
31565
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31325
diff
changeset
|
207 # simplified version of distutils.ccompiler.CCompiler.has_function |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31325
diff
changeset
|
208 # that actually removes its temporary files. |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31325
diff
changeset
|
209 def hasfunction(cc, funcname): |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31325
diff
changeset
|
210 code = 'int main(void) { %s(); }\n' % funcname |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31325
diff
changeset
|
211 return cancompile(cc, code) |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31325
diff
changeset
|
212 |
31566
5a0460219649
setup: add a function to test header files
Jun Wu <quark@fb.com>
parents:
31565
diff
changeset
|
213 def hasheader(cc, headername): |
5a0460219649
setup: add a function to test header files
Jun Wu <quark@fb.com>
parents:
31565
diff
changeset
|
214 code = '#include <%s>\nint main(void) { return 0; }\n' % headername |
5a0460219649
setup: add a function to test header files
Jun Wu <quark@fb.com>
parents:
31565
diff
changeset
|
215 return cancompile(cc, code) |
5a0460219649
setup: add a function to test header files
Jun Wu <quark@fb.com>
parents:
31565
diff
changeset
|
216 |
1283
f5faab34f32e
Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents:
575
diff
changeset
|
217 # py2exe needs to be installed to work |
f5faab34f32e
Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents:
575
diff
changeset
|
218 try: |
1294
372971e1c40d
Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1284
diff
changeset
|
219 import py2exe |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
21840
diff
changeset
|
220 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
|
221 py2exeloaded = True |
15527
9926aab3d0b5
setup: fix py2exe generation broken by c3a6ec304055 (issue3116)
Pascal Quantin <pascal.quantin@gmail.com>
parents:
15523
diff
changeset
|
222 # 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
|
223 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
|
224 except ImportError: |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
225 py2exeloaded = False |
1283
f5faab34f32e
Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents:
575
diff
changeset
|
226 |
9807
f359d4f528aa
setup: fix f51d1822d6fd refactoring, propagate env to runcmd
Christian Boos <cboos@bct-technology.com>
parents:
9615
diff
changeset
|
227 def runcmd(cmd, env): |
32904
19b0fd4b5570
plan9: drop py26 hacks
Matt Harbison <matt_harbison@yahoo.com>
parents:
32802
diff
changeset
|
228 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
19b0fd4b5570
plan9: drop py26 hacks
Matt Harbison <matt_harbison@yahoo.com>
parents:
32802
diff
changeset
|
229 stderr=subprocess.PIPE, env=env) |
19b0fd4b5570
plan9: drop py26 hacks
Matt Harbison <matt_harbison@yahoo.com>
parents:
32802
diff
changeset
|
230 out, err = p.communicate() |
33123
87ee783f7299
setup: update runcmd() to also return the exit status
Adam Simpkins <simpkins@fb.com>
parents:
33122
diff
changeset
|
231 return p.returncode, out, err |
13636
4bfff063aed6
setup: fix mac build broken by e42d18538e1d
Jon M. Dugan <jdugan@x1024.net>
parents:
13594
diff
changeset
|
232 |
33125
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
233 class hgcommand(object): |
33126
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
234 def __init__(self, cmd, env): |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
235 self.cmd = cmd |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
236 self.env = 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
|
237 |
33125
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
238 def run(self, args): |
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
239 cmd = self.cmd + args |
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
240 returncode, out, err = runcmd(cmd, self.env) |
33598
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
241 err = filterhgerr(err) |
33125
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
242 if err or returncode != 0: |
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
243 printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) |
33598
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
244 printf(err, file=sys.stderr) |
33125
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
245 return '' |
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
246 return out |
8548
3ccbe42ff72f
setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
8547
diff
changeset
|
247 |
33598
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
248 def filterhgerr(err): |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
249 # If root is executing setup.py, but the repository is owned by |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
250 # another user (as in "sudo python setup.py install") we will get |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
251 # trust warnings since the .hg/hgrc file is untrusted. That is |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
252 # fine, we don't want to load it anyway. Python may warn about |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
253 # a missing __init__.py in mercurial/locale, we also ignore that. |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
254 err = [e for e in err.splitlines() |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
255 if (not e.startswith(b'not trusting file') |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
256 and not e.startswith(b'warning: Not importing') |
34923
a6a322193a02
setup: filter out devel-warn messages from system hg
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
34922
diff
changeset
|
257 and not e.startswith(b'obsolete feature not enabled') |
36713
5f41e3418407
setup: ignore extension load failures when finding working hg
Ryan McElroy <rmcelroy@fb.com>
parents:
36704
diff
changeset
|
258 and not e.startswith(b'*** failed to import extension') |
34923
a6a322193a02
setup: filter out devel-warn messages from system hg
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
34922
diff
changeset
|
259 and not e.startswith(b'devel-warn:'))] |
33598
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
260 return b'\n'.join(b' ' + e for e in err) |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
261 |
33126
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
262 def findhg(): |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
263 """Try to figure out how we should invoke hg for examining the local |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
264 repository contents. |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
265 |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
266 Returns an hgcommand object.""" |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
267 # By default, prefer the "hg" command in the user's path. This was |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
268 # presumably the hg command that the user used to create this repository. |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
269 # |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
270 # This repository may require extensions or other settings that would not |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
271 # be enabled by running the hg script directly from this local repository. |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
272 hgenv = os.environ.copy() |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
273 # Use HGPLAIN to disable hgrc settings that would change output formatting, |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
274 # and disable localization for the same reasons. |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
275 hgenv['HGPLAIN'] = '1' |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
276 hgenv['LANGUAGE'] = 'C' |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
277 hgcmd = ['hg'] |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
278 # Run a simple "hg log" command just to see if using hg from the user's |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
279 # path works and can successfully interact with this repository. |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
280 check_cmd = ['log', '-r.', '-Ttest'] |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
281 try: |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
282 retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
283 except EnvironmentError: |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
284 retcode = -1 |
33598
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
285 if retcode == 0 and not filterhgerr(err): |
33126
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
286 return hgcommand(hgcmd, hgenv) |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
287 |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
288 # Fall back to trying the local hg installation. |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
289 hgenv = localhgenv() |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
290 hgcmd = [sys.executable, 'hg'] |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
291 try: |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
292 retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
293 except EnvironmentError: |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
294 retcode = -1 |
33598
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
295 if retcode == 0 and not filterhgerr(err): |
33126
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
296 return hgcommand(hgcmd, hgenv) |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
297 |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
298 raise SystemExit('Unable to find a working hg binary to extract the ' |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
299 'version from the repository tags') |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
300 |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
301 def localhgenv(): |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
302 """Get an environment dictionary to use for invoking or importing |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
303 mercurial from the local repository.""" |
33124
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
304 # Execute hg out of this directory with a custom environment which takes |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
305 # care to not use any hgrc files and do no localization. |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
306 env = {'HGMODULEPOLICY': 'py', |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
307 'HGRCPATH': '', |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
308 'LANGUAGE': 'C', |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
309 'PATH': ''} # make pypi modules that use os.environ['PATH'] happy |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
310 if 'LD_LIBRARY_PATH' in os.environ: |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
311 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
312 if 'SystemRoot' in os.environ: |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
313 # SystemRoot is required by Windows to load various DLLs. See: |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
314 # https://bugs.python.org/issue13524#msg148850 |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
315 env['SystemRoot'] = os.environ['SystemRoot'] |
33129 | 316 return env |
33124
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
317 |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33123
diff
changeset
|
318 version = '' |
15367
b357a972d6cd
setup: set env global earlier (3073)
Matt Mackall <mpm@selenic.com>
parents:
15215
diff
changeset
|
319 |
8547
548fd7a05373
setup.py: subprocess instead of os.popen, sys.stderr.write instead of print
Christian Ebert <blacktrash@gmx.net>
parents:
8494
diff
changeset
|
320 if os.path.isdir('.hg'): |
33126
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
321 hg = findhg() |
33125
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
322 cmd = ['log', '-r', '.', '--template', '{tags}\n'] |
35255
d73ccc63b8f9
setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
35238
diff
changeset
|
323 numerictags = [t for t in sysstr(hg.run(cmd)).split() if t[0:1].isdigit()] |
d73ccc63b8f9
setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
35238
diff
changeset
|
324 hgid = sysstr(hg.run(['id', '-i'])).strip() |
33122
6fdc1518983e
setup: fail if we cannot determine the version number
Adam Simpkins <simpkins@fb.com>
parents:
33115
diff
changeset
|
325 if not hgid: |
6fdc1518983e
setup: fail if we cannot determine the version number
Adam Simpkins <simpkins@fb.com>
parents:
33115
diff
changeset
|
326 # Bail out if hg is having problems interacting with this repository, |
6fdc1518983e
setup: fail if we cannot determine the version number
Adam Simpkins <simpkins@fb.com>
parents:
33115
diff
changeset
|
327 # rather than falling through and producing a bogus version number. |
6fdc1518983e
setup: fail if we cannot determine the version number
Adam Simpkins <simpkins@fb.com>
parents:
33115
diff
changeset
|
328 # Continuing with an invalid version number will break extensions |
6fdc1518983e
setup: fail if we cannot determine the version number
Adam Simpkins <simpkins@fb.com>
parents:
33115
diff
changeset
|
329 # that define minimumhgversion. |
6fdc1518983e
setup: fail if we cannot determine the version number
Adam Simpkins <simpkins@fb.com>
parents:
33115
diff
changeset
|
330 raise SystemExit('Unable to determine hg version from local repository') |
17709
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
331 if numerictags: # tag(s) found |
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
332 version = numerictags[-1] |
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
333 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
|
334 version += '+' |
17709
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
335 else: # no tag found |
33125
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
336 ltagcmd = ['parents', '--template', '{latesttag}'] |
35255
d73ccc63b8f9
setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
35238
diff
changeset
|
337 ltag = sysstr(hg.run(ltagcmd)) |
33125
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
338 changessincecmd = ['log', '-T', 'x\n', '-r', "only(.,'%s')" % ltag] |
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33124
diff
changeset
|
339 changessince = len(hg.run(changessincecmd).splitlines()) |
23647
eb55e09202c8
setup: use changes since latest tag instead of just distance
Siddharth Agarwal <sid0@fb.com>
parents:
23646
diff
changeset
|
340 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 if 'tag' in kw: |
27637
b502138f5faa
cleanup: remove superfluous space after space after equals (python)
timeless <timeless@mozdev.org>
parents:
27374
diff
changeset
|
347 version = kw['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
|
348 elif 'latesttag' in kw: |
23646
9641643fac71
setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents:
23392
diff
changeset
|
349 if 'changessincelatesttag' in kw: |
9641643fac71
setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents:
23392
diff
changeset
|
350 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
|
351 else: |
9641643fac71
setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents:
23392
diff
changeset
|
352 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
|
353 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
|
354 version = kw.get('node', '')[:12] |
7632 | 355 |
8548
3ccbe42ff72f
setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
8547
diff
changeset
|
356 if version: |
35238
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
357 versionb = version |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
358 if not isinstance(versionb, bytes): |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
359 versionb = versionb.encode('ascii') |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
360 |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
361 write_if_changed('mercurial/__version__.py', b''.join([ |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
362 b'# this file is autogenerated by setup.py\n' |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
363 b'version = "%s"\n' % versionb, |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
364 ])) |
8493
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
365 |
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
366 try: |
28431
a7e3b72cf756
setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents:
28430
diff
changeset
|
367 oldpolicy = os.environ.get('HGMODULEPOLICY', None) |
a7e3b72cf756
setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents:
28430
diff
changeset
|
368 os.environ['HGMODULEPOLICY'] = 'py' |
8493
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
369 from mercurial import __version__ |
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
370 version = __version__.version |
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
371 except ImportError: |
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
372 version = 'unknown' |
28431
a7e3b72cf756
setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents:
28430
diff
changeset
|
373 finally: |
a7e3b72cf756
setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents:
28430
diff
changeset
|
374 if oldpolicy is None: |
a7e3b72cf756
setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents:
28430
diff
changeset
|
375 del os.environ['HGMODULEPOLICY'] |
a7e3b72cf756
setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents:
28430
diff
changeset
|
376 else: |
a7e3b72cf756
setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents:
28430
diff
changeset
|
377 os.environ['HGMODULEPOLICY'] = oldpolicy |
7632 | 378 |
15460
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
379 class hgbuild(build): |
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
380 # 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
|
381 # when build_py is run next. |
28398
712298942c82
setup: remove support for 2to3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28041
diff
changeset
|
382 sub_commands = [('build_mo', None)] + build.sub_commands |
15460
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
383 |
15523
f9da84a950d0
setup: backout 8504699d1aa6
Matt Mackall <mpm@selenic.com>
parents:
15500
diff
changeset
|
384 class hgbuildmo(build): |
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
385 |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
386 description = "build translations (.mo files)" |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
387 |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
388 def run(self): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
389 if not find_executable('msgfmt'): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
390 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
|
391 "will be built") |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
392 return |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
393 |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
394 podir = 'i18n' |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
395 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
|
396 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
|
397 return |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
398 |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
399 join = os.path.join |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
400 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
|
401 if not po.endswith('.po'): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
402 continue |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
403 pofile = join(podir, po) |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
404 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
|
405 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
|
406 mobuildfile = join('mercurial', mofile) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
407 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
|
408 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
|
409 # 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
|
410 cmd.append('-c') |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
411 self.mkpath(join('mercurial', modir)) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
412 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
|
413 |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
414 |
15458
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
415 class hgdist(Distribution): |
29505
2dce3f96ad7b
setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents:
29444
diff
changeset
|
416 pure = False |
2dce3f96ad7b
setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents:
29444
diff
changeset
|
417 cffi = ispypy |
15458
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
418 |
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
419 global_options = Distribution.global_options + \ |
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
420 [('pure', None, "use pure (slow) Python " |
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
421 "code instead of C extensions"), |
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
422 ] |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
423 |
15459
434c48e981b8
setup: has_ext_modules always returns false when pure is specified
Simon Heimberg <simohe@besonet.ch>
parents:
15458
diff
changeset
|
424 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
|
425 # 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
|
426 # 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
|
427 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
|
428 |
30459
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
429 # This is ugly as a one-liner. So use a variable. |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
430 buildextnegops = dict(getattr(build_ext, 'negative_options', {})) |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
431 buildextnegops['no-zstd'] = 'zstd' |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
432 |
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
433 class hgbuildext(build_ext): |
30459
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
434 user_options = build_ext.user_options + [ |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
435 ('zstd', None, 'compile zstd bindings [default]'), |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
436 ('no-zstd', None, 'do not compile zstd bindings'), |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
437 ] |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
438 |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
439 boolean_options = build_ext.boolean_options + ['zstd'] |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
440 negative_opt = buildextnegops |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
441 |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
442 def initialize_options(self): |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
443 self.zstd = True |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
444 return build_ext.initialize_options(self) |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
445 |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
446 def build_extensions(self): |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
447 # Filter out zstd if disabled via argument. |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
448 if not self.zstd: |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
449 self.extensions = [e for e in self.extensions |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
450 if e.name != 'mercurial.zstd'] |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
451 |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30445
diff
changeset
|
452 return build_ext.build_extensions(self) |
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
453 |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
454 def build_extension(self, ext): |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
455 try: |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
456 build_ext.build_extension(self, ext) |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
457 except CCompilerError: |
12501
98f21e4d9633
setup: slight simplification
Martin Geisler <mg@lazybytes.net>
parents:
11533
diff
changeset
|
458 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
|
459 raise |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
460 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
|
461 ext.name) |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
462 |
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
463 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
|
464 def run(self): |
28041
8da94662afe5
setup: avoid procedure related to hg.exe at setup.py --pure
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27925
diff
changeset
|
465 if os.name != 'nt' or self.distribution.pure: |
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
466 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
|
467 |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
468 exebuilt = False |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
469 try: |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
470 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
|
471 exebuilt = True |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
472 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
|
473 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
|
474 |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
475 if exebuilt: |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
476 # 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
|
477 # 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
|
478 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
|
479 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
|
480 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
|
481 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
|
482 |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
483 # 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
|
484 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
|
485 |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
486 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
|
487 |
10000
16f49d671c7f
setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents:
9999
diff
changeset
|
488 class hgbuildpy(build_py): |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
489 def finalize_options(self): |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
490 build_py.finalize_options(self) |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
491 |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
492 if self.distribution.pure: |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
493 self.distribution.ext_modules = [] |
29505
2dce3f96ad7b
setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents:
29444
diff
changeset
|
494 elif self.distribution.cffi: |
30356
9cc438bf7d9a
setup: move cffi stuff to mercurial/cffi
Jun Wu <quark@fb.com>
parents:
29844
diff
changeset
|
495 from mercurial.cffi import ( |
32538
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32458
diff
changeset
|
496 bdiffbuild, |
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32458
diff
changeset
|
497 mpatchbuild, |
30356
9cc438bf7d9a
setup: move cffi stuff to mercurial/cffi
Jun Wu <quark@fb.com>
parents:
29844
diff
changeset
|
498 ) |
32538
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32458
diff
changeset
|
499 exts = [mpatchbuild.ffi.distutils_extension(), |
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32458
diff
changeset
|
500 bdiffbuild.ffi.distutils_extension()] |
29505
2dce3f96ad7b
setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents:
29444
diff
changeset
|
501 # cffi modules go here |
29600
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
29541
diff
changeset
|
502 if sys.platform == 'darwin': |
32538
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32458
diff
changeset
|
503 from mercurial.cffi import osutilbuild |
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32458
diff
changeset
|
504 exts.append(osutilbuild.ffi.distutils_extension()) |
29505
2dce3f96ad7b
setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents:
29444
diff
changeset
|
505 self.distribution.ext_modules = exts |
12649
6c0e1aee1b19
setup: user-friendly error message if Python headers are missing
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12501
diff
changeset
|
506 else: |
18905
012780620d4f
setup: make error message for missing Python headers more helpful
Mads Kiilerich <mads@kiilerich.com>
parents:
18900
diff
changeset
|
507 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
|
508 if not os.path.exists(h): |
16683 | 509 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
|
510 '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
|
511 |
28430
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
512 def run(self): |
32675
7dab4c0cdb41
setup: do not overwrite local __modulepolicy__.py on out-of-source build
Yuya Nishihara <yuya@tcha.org>
parents:
32670
diff
changeset
|
513 basepath = os.path.join(self.build_lib, 'mercurial') |
7dab4c0cdb41
setup: do not overwrite local __modulepolicy__.py on out-of-source build
Yuya Nishihara <yuya@tcha.org>
parents:
32670
diff
changeset
|
514 self.mkpath(basepath) |
7dab4c0cdb41
setup: do not overwrite local __modulepolicy__.py on out-of-source build
Yuya Nishihara <yuya@tcha.org>
parents:
32670
diff
changeset
|
515 |
28430
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
516 if self.distribution.pure: |
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
517 modulepolicy = 'py' |
32291
a04f5c651e52
policy: relax the default for in-place build
Yuya Nishihara <yuya@tcha.org>
parents:
32273
diff
changeset
|
518 elif self.build_lib == '.': |
a04f5c651e52
policy: relax the default for in-place build
Yuya Nishihara <yuya@tcha.org>
parents:
32273
diff
changeset
|
519 # in-place build should run without rebuilding C extensions |
a04f5c651e52
policy: relax the default for in-place build
Yuya Nishihara <yuya@tcha.org>
parents:
32273
diff
changeset
|
520 modulepolicy = 'allow' |
28430
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
521 else: |
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
522 modulepolicy = 'c' |
35238
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
523 |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
524 content = b''.join([ |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
525 b'# this file is autogenerated by setup.py\n', |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
526 b'modulepolicy = b"%s"\n' % modulepolicy.encode('ascii'), |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
527 ]) |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
528 write_if_changed(os.path.join(basepath, '__modulepolicy__.py'), |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35126
diff
changeset
|
529 content) |
27222
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
530 |
28430
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
531 build_py.run(self) |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
532 |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
533 class buildhgextindex(Command): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
534 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
|
535 user_options = [] |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
536 _indexfilename = 'hgext/__index__.py' |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
537 |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
538 def initialize_options(self): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
539 pass |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
540 |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
541 def finalize_options(self): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
542 pass |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
543 |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
544 def run(self): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
545 if os.path.exists(self._indexfilename): |
28418
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
546 with open(self._indexfilename, 'w') as f: |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
547 f.write('# empty\n') |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
548 |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
549 # 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
|
550 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
|
551 'pprint.pprint(extensions.disabled())') |
33126
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
552 returncode, out, err = runcmd([sys.executable, '-c', code], |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
553 localhgenv()) |
33123
87ee783f7299
setup: update runcmd() to also return the exit status
Adam Simpkins <simpkins@fb.com>
parents:
33122
diff
changeset
|
554 if err or returncode != 0: |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
555 raise DistutilsExecError(err) |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
556 |
28418
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
557 with open(self._indexfilename, 'w') as f: |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
558 f.write('# this file is autogenerated by setup.py\n') |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
559 f.write('docs = ') |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
560 f.write(out) |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
561 |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
562 class buildhgexe(build_ext): |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
563 description = 'compile hg.exe from mercurial/exewrapper.c' |
34530
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
564 user_options = build_ext.user_options + [ |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
565 ('long-paths-support', None, 'enable support for long paths on ' |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
566 'Windows (off by default and ' |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
567 'experimental)'), |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
568 ] |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
569 |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
570 LONG_PATHS_MANIFEST = """ |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
571 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
572 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
573 <application> |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
574 <windowsSettings |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
575 xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings"> |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
576 <ws2:longPathAware>true</ws2:longPathAware> |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
577 </windowsSettings> |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
578 </application> |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
579 </assembly>""" |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
580 |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
581 def initialize_options(self): |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
582 build_ext.initialize_options(self) |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
583 self.long_paths_support = False |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
584 |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
585 def build_extensions(self): |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
586 if os.name != 'nt': |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
587 return |
17246
bf5bb38bcc7c
setup: fix build_hgexe for mingw32 compiler
Adrian Buehlmann <adrian@cadifra.com>
parents:
17121
diff
changeset
|
588 if isinstance(self.compiler, HackedMingw32CCompiler): |
bf5bb38bcc7c
setup: fix build_hgexe for mingw32 compiler
Adrian Buehlmann <adrian@cadifra.com>
parents:
17121
diff
changeset
|
589 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
|
590 self.compiler.dll_libraries = [] # no -lmsrvc90 |
29020
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
591 |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
592 # Different Python installs can have different Python library |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
593 # names. e.g. the official CPython distribution uses pythonXY.dll |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
594 # and MinGW uses libpythonX.Y.dll. |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
595 _kernel32 = ctypes.windll.kernel32 |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
596 _kernel32.GetModuleFileNameA.argtypes = [ctypes.c_void_p, |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
597 ctypes.c_void_p, |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
598 ctypes.c_ulong] |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
599 _kernel32.GetModuleFileNameA.restype = ctypes.c_ulong |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
600 size = 1000 |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
601 buf = ctypes.create_string_buffer(size + 1) |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
602 filelen = _kernel32.GetModuleFileNameA(sys.dllhandle, ctypes.byref(buf), |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
603 size) |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
604 |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
605 if filelen > 0 and filelen != size: |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
606 dllbasename = os.path.basename(buf.value) |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
607 if not dllbasename.lower().endswith('.dll'): |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
608 raise SystemExit('Python DLL does not end with .dll: %s' % |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
609 dllbasename) |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
610 pythonlib = dllbasename[:-4] |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
611 else: |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
612 log.warn('could not determine Python DLL filename; ' |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
613 'assuming pythonXY') |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
614 |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
615 hv = sys.hexversion |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
616 pythonlib = 'python%d%d' % (hv >> 24, (hv >> 16) & 0xff) |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
617 |
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
618 log.info('using %s as Python library name' % pythonlib) |
28418
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
619 with open('mercurial/hgpythonlib.h', 'wb') as f: |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
620 f.write('/* this file is autogenerated by setup.py */\n') |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
621 f.write('#define HGPYTHONLIB "%s"\n' % pythonlib) |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
622 objects = self.compiler.compile(['mercurial/exewrapper.c'], |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
623 output_dir=self.build_temp) |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
624 dir = os.path.dirname(self.get_ext_fullpath('dummy')) |
34530
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
625 self.hgtarget = os.path.join(dir, 'hg') |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
626 self.compiler.link_executable(objects, self.hgtarget, |
17732
93d97a212559
exewrapper: adapt for legacy HackableMercurial
Adrian Buehlmann <adrian@cadifra.com>
parents:
17709
diff
changeset
|
627 libraries=[], |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
628 output_dir=self.build_temp) |
34530
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
629 if self.long_paths_support: |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
630 self.addlongpathsmanifest() |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
631 |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
632 def addlongpathsmanifest(self): |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
633 """Add manifest pieces so that hg.exe understands long paths |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
634 |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
635 This is an EXPERIMENTAL feature, use with care. |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
636 To enable long paths support, one needs to do two things: |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
637 - build Mercurial with --long-paths-support option |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
638 - change HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\ |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
639 LongPathsEnabled to have value 1. |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
640 |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
641 Please ignore 'warning 81010002: Unrecognized Element "longPathAware"'; |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
642 it happens because Mercurial uses mt.exe circa 2008, which is not |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
643 yet aware of long paths support in the manifest (I think so at least). |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
644 This does not stop mt.exe from embedding/merging the XML properly. |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
645 |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
646 Why resource #1 should be used for .exe manifests? I don't know and |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
647 wasn't able to find an explanation for mortals. But it seems to work. |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
648 """ |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
649 exefname = self.compiler.executable_filename(self.hgtarget) |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
650 fdauto, manfname = tempfile.mkstemp(suffix='.hg.exe.manifest') |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
651 os.close(fdauto) |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
652 with open(manfname, 'w') as f: |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
653 f.write(self.LONG_PATHS_MANIFEST) |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
654 log.info("long paths manifest is written to '%s'" % manfname) |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
655 inputresource = '-inputresource:%s;#1' % exefname |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
656 outputresource = '-outputresource:%s;#1' % exefname |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
657 log.info("running mt.exe to update hg.exe's manifest in-place") |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
658 # supplying both -manifest and -inputresource to mt.exe makes |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
659 # it merge the embedded and supplied manifests in the -outputresource |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
660 self.spawn(['mt.exe', '-nologo', '-manifest', manfname, |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
661 inputresource, outputresource]) |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
662 log.info("done updating hg.exe's manifest") |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34398
diff
changeset
|
663 os.remove(manfname) |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
664 |
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
665 @property |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
666 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
|
667 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
|
668 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
|
669 |
32670
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32539
diff
changeset
|
670 class hginstall(install): |
32745
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
671 |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
672 user_options = install.user_options + [ |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
673 ('old-and-unmanageable', None, |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
674 'noop, present for eggless setuptools compat'), |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
675 ('single-version-externally-managed', None, |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
676 'noop, present for eggless setuptools compat'), |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
677 ] |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
678 |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
679 # Also helps setuptools not be sad while we refuse to create eggs. |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
680 single_version_externally_managed = True |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32675
diff
changeset
|
681 |
32670
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32539
diff
changeset
|
682 def get_sub_commands(self): |
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32539
diff
changeset
|
683 # Screen out egg related commands to prevent egg generation. But allow |
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32539
diff
changeset
|
684 # mercurial.egg-info generation, since that is part of modern |
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32539
diff
changeset
|
685 # packaging. |
33589
a0bfcd08f5fe
setup: drop use of set literal so parsable on Python 2.6
Yuya Nishihara <yuya@tcha.org>
parents:
33588
diff
changeset
|
686 excl = set(['bdist_egg']) |
32670
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32539
diff
changeset
|
687 return filter(lambda x: x not in excl, install.get_sub_commands(self)) |
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32539
diff
changeset
|
688 |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
689 class hginstalllib(install_lib): |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
690 ''' |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
691 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
|
692 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
|
693 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
|
694 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
|
695 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
|
696 |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
697 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
|
698 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
|
699 ''' |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
700 |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
701 def run(self): |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
702 realcopyfile = file_util.copy_file |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
703 def copyfileandsetmode(*args, **kwargs): |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
704 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
|
705 dst, copied = realcopyfile(*args, **kwargs) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
706 if copied: |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
707 st = os.stat(src) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
708 # 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
|
709 # has it) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
710 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
|
711 setmode = int('0755', 8) |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
712 else: |
24941
9c1942635c1f
setup: hide octal literals inside strings so they're portable (issue4554)
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
713 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
|
714 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
|
715 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
|
716 os.chmod(dst, m) |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
717 file_util.copy_file = copyfileandsetmode |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
718 try: |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
719 install_lib.run(self) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
720 finally: |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
721 file_util.copy_file = realcopyfile |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
722 |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
723 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
|
724 ''' |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
725 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
|
726 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
|
727 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
|
728 ''' |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
729 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
730 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
|
731 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
|
732 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
733 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
|
734 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
735 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
|
736 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
|
737 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
|
738 ('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
|
739 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
740 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
|
741 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
|
742 |
27269
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
743 # 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
|
744 # 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
|
745 # 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
|
746 # wheel archive looks like: |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
747 # |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
748 # 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
|
749 # mercurial/__init__.py |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
750 # |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
751 # 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
|
752 # 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
|
753 # 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
|
754 # 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
|
755 # 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
|
756 # 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
|
757 # 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
|
758 # 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
|
759 # 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
|
760 # 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
|
761 |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
762 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
|
763 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
|
764 # 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
|
765 # 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
|
766 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
|
767 else: |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
768 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
|
769 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
|
770 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
|
771 |
27637
b502138f5faa
cleanup: remove superfluous space after space after equals (python)
timeless <timeless@mozdev.org>
parents:
27374
diff
changeset
|
772 libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):] |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
773 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
774 for outfile in self.outfiles: |
28418
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
775 with open(outfile, 'rb') as fp: |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
776 data = fp.read() |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
777 |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
778 # skip binary files |
27348
83a8219fb790
setup.py: use bytes literals
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27269
diff
changeset
|
779 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
|
780 continue |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
781 |
27269
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
782 # 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
|
783 # 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
|
784 # value. |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
785 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
|
786 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
|
787 'not known' % outfile) |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
788 continue |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
789 |
27348
83a8219fb790
setup.py: use bytes literals
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27269
diff
changeset
|
790 data = data.replace(b'@LIBDIR@', libdir.encode(libdir_escape)) |
28418
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
791 with open(outfile, 'wb') as fp: |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
792 fp.write(data) |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
793 |
15460
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
794 cmdclass = {'build': hgbuild, |
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
795 'build_mo': hgbuildmo, |
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
796 '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
|
797 '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
|
798 'build_scripts': hgbuildscripts, |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
799 'build_hgextindex': buildhgextindex, |
32670
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32539
diff
changeset
|
800 'install': hginstall, |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
801 'install_lib': hginstalllib, |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
802 'install_scripts': hginstallscripts, |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
803 'build_hgexe': buildhgexe, |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
804 } |
3238
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
805 |
32251
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
806 packages = ['mercurial', |
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
807 'mercurial.cext', |
32539
2dcb3d52ef41
cffi: put compiled modules into mercurial.cffi package
Yuya Nishihara <yuya@tcha.org>
parents:
32538
diff
changeset
|
808 'mercurial.cffi', |
32251
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
809 'mercurial.hgweb', |
27222
511a4384b033
setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27220
diff
changeset
|
810 'mercurial.pure', |
34398 | 811 'mercurial.thirdparty', |
812 'mercurial.thirdparty.attr', | |
37133
a1d2d0420e22
setup: install cbor packages
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36772
diff
changeset
|
813 'mercurial.thirdparty.cbor', |
a1d2d0420e22
setup: install cbor packages
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36772
diff
changeset
|
814 'mercurial.thirdparty.cbor.cbor2', |
37182
922b3fae9c7d
setup: register zope.interface packages and compile C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37133
diff
changeset
|
815 'mercurial.thirdparty.zope', |
922b3fae9c7d
setup: register zope.interface packages and compile C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37133
diff
changeset
|
816 'mercurial.thirdparty.zope.interface', |
36636
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36456
diff
changeset
|
817 'mercurial.utils', |
28625
776fd2e2cf5a
setup: add missing hgext.fsmonitor
Sean Farley <sean@farley.io>
parents:
28609
diff
changeset
|
818 'hgext', 'hgext.convert', 'hgext.fsmonitor', |
37305
611e466662af
setup: add overlooked hgext.infinitepush package declaration
Augie Fackler <augie@google.com>
parents:
37182
diff
changeset
|
819 'hgext.fsmonitor.pywatchman', |
611e466662af
setup: add overlooked hgext.infinitepush package declaration
Augie Fackler <augie@google.com>
parents:
37182
diff
changeset
|
820 'hgext.infinitepush', |
611e466662af
setup: add overlooked hgext.infinitepush package declaration
Augie Fackler <augie@google.com>
parents:
37182
diff
changeset
|
821 'hgext.highlight', |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
35774
diff
changeset
|
822 'hgext.largefiles', 'hgext.lfs', 'hgext.narrow', |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
35774
diff
changeset
|
823 'hgext.zeroconf', 'hgext3rd', |
32458
0906b85bf222
demandimport: move to separate package
Siddharth Agarwal <sid0@fb.com>
parents:
32423
diff
changeset
|
824 'hgdemandimport'] |
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
|
825 |
29444
284d742e5611
internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
29020
diff
changeset
|
826 common_depends = ['mercurial/bitmanipulation.h', |
284d742e5611
internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
29020
diff
changeset
|
827 'mercurial/compat.h', |
32423
34bd3cd28dcb
cext: move util.h to cext tree
Yuya Nishihara <yuya@tcha.org>
parents:
32417
diff
changeset
|
828 'mercurial/cext/util.h'] |
32251
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
829 common_include_dirs = ['mercurial'] |
19724
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
830 |
30418
ce9a3033c118
setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents:
30356
diff
changeset
|
831 osutil_cflags = [] |
25073
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
832 osutil_ldflags = [] |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
833 |
31567 | 834 # platform specific macros |
31627
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31601
diff
changeset
|
835 for plat, func in [('bsd', 'setproctitle')]: |
31567 | 836 if re.search(plat, sys.platform) and hasfunction(new_compiler(), func): |
30418
ce9a3033c118
setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents:
30356
diff
changeset
|
837 osutil_cflags.append('-DHAVE_%s' % func.upper()) |
ce9a3033c118
setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents:
30356
diff
changeset
|
838 |
31601
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
839 for plat, macro, code in [ |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
840 ('bsd|darwin', 'BSD_STATFS', ''' |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
841 #include <sys/param.h> |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
842 #include <sys/mount.h> |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
843 int main() { struct statfs s; return sizeof(s.f_fstypename); } |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
844 '''), |
31627
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31601
diff
changeset
|
845 ('linux', 'LINUX_STATFS', ''' |
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31601
diff
changeset
|
846 #include <linux/magic.h> |
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31601
diff
changeset
|
847 #include <sys/vfs.h> |
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31601
diff
changeset
|
848 int main() { struct statfs s; return sizeof(s.f_type); } |
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31601
diff
changeset
|
849 '''), |
31601
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
850 ]: |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
851 if re.search(plat, sys.platform) and cancompile(new_compiler(), code): |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
852 osutil_cflags.append('-DHAVE_%s' % macro) |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31568
diff
changeset
|
853 |
25073
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
854 if sys.platform == 'darwin': |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
855 osutil_ldflags += ['-framework', 'ApplicationServices'] |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
856 |
36704 | 857 xdiff_srcs = [ |
858 'mercurial/thirdparty/xdiff/xdiffi.c', | |
859 'mercurial/thirdparty/xdiff/xprepare.c', | |
860 'mercurial/thirdparty/xdiff/xutils.c', | |
861 ] | |
862 | |
863 xdiff_headers = [ | |
864 'mercurial/thirdparty/xdiff/xdiff.h', | |
865 'mercurial/thirdparty/xdiff/xdiffi.h', | |
866 'mercurial/thirdparty/xdiff/xinclude.h', | |
867 'mercurial/thirdparty/xdiff/xmacros.h', | |
868 'mercurial/thirdparty/xdiff/xprepare.h', | |
869 'mercurial/thirdparty/xdiff/xtypes.h', | |
870 'mercurial/thirdparty/xdiff/xutils.h', | |
871 ] | |
872 | |
10000
16f49d671c7f
setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents:
9999
diff
changeset
|
873 extmodules = [ |
32407
008d37c4d783
base85: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32406
diff
changeset
|
874 Extension('mercurial.cext.base85', ['mercurial/cext/base85.c'], |
32251
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
875 include_dirs=common_include_dirs, |
19724
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
876 depends=common_depends), |
32408
3b88a7fa97d8
bdiff: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32407
diff
changeset
|
877 Extension('mercurial.cext.bdiff', ['mercurial/bdiff.c', |
36704 | 878 'mercurial/cext/bdiff.c'] + xdiff_srcs, |
32251
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
879 include_dirs=common_include_dirs, |
36704 | 880 depends=common_depends + ['mercurial/bdiff.h'] + xdiff_headers), |
32409
017ad85e5ac8
diffhelpers: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32408
diff
changeset
|
881 Extension('mercurial.cext.diffhelpers', ['mercurial/cext/diffhelpers.c'], |
32251
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
882 include_dirs=common_include_dirs, |
19724
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
883 depends=common_depends), |
32410
151cc3b3d799
mpatch: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32409
diff
changeset
|
884 Extension('mercurial.cext.mpatch', ['mercurial/mpatch.c', |
151cc3b3d799
mpatch: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32409
diff
changeset
|
885 'mercurial/cext/mpatch.c'], |
32251
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
886 include_dirs=common_include_dirs, |
19724
2b2a2e858fb7
setup: check if mercurial/util.h has been modified
Wei, Elson <elson.wei@gmail.com>
parents:
18905
diff
changeset
|
887 depends=common_depends), |
33778
e9996bd7203f
cext: split character encoding functions to new compilation unit
Yuya Nishihara <yuya@tcha.org>
parents:
33600
diff
changeset
|
888 Extension('mercurial.cext.parsers', ['mercurial/cext/charencode.c', |
e9996bd7203f
cext: split character encoding functions to new compilation unit
Yuya Nishihara <yuya@tcha.org>
parents:
33600
diff
changeset
|
889 'mercurial/cext/dirs.c', |
32411
df448de7cf3b
parsers: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
890 'mercurial/cext/manifest.c', |
df448de7cf3b
parsers: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
891 'mercurial/cext/parsers.c', |
32417
7d0c69505a66
cext: extract revlog/index parsing code to own C file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32411
diff
changeset
|
892 'mercurial/cext/pathencode.c', |
7d0c69505a66
cext: extract revlog/index parsing code to own C file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32411
diff
changeset
|
893 'mercurial/cext/revlog.c'], |
32251
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
894 include_dirs=common_include_dirs, |
33779
0f4ac3b6dee4
cext: factor out header for charencode.c
Yuya Nishihara <yuya@tcha.org>
parents:
33778
diff
changeset
|
895 depends=common_depends + ['mercurial/cext/charencode.h']), |
32406
a9c71d578a1c
osutil: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32291
diff
changeset
|
896 Extension('mercurial.cext.osutil', ['mercurial/cext/osutil.c'], |
32251
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32178
diff
changeset
|
897 include_dirs=common_include_dirs, |
30418
ce9a3033c118
setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents:
30356
diff
changeset
|
898 extra_compile_args=osutil_cflags, |
25074
0021ad4c2309
setup: integrate osutil C extension into extmodules initialization
Adrian Buehlmann <adrian@cadifra.com>
parents:
25073
diff
changeset
|
899 extra_link_args=osutil_ldflags, |
0021ad4c2309
setup: integrate osutil C extension into extmodules initialization
Adrian Buehlmann <adrian@cadifra.com>
parents:
25073
diff
changeset
|
900 depends=common_depends), |
37182
922b3fae9c7d
setup: register zope.interface packages and compile C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37133
diff
changeset
|
901 Extension( |
922b3fae9c7d
setup: register zope.interface packages and compile C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37133
diff
changeset
|
902 'mercurial.thirdparty.zope.interface._zope_interface_coptimizations', [ |
922b3fae9c7d
setup: register zope.interface packages and compile C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37133
diff
changeset
|
903 'mercurial/thirdparty/zope/interface/_zope_interface_coptimizations.c', |
922b3fae9c7d
setup: register zope.interface packages and compile C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37133
diff
changeset
|
904 ]), |
28432
2377c4ac4eec
fsmonitor: dependencies for new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
28431
diff
changeset
|
905 Extension('hgext.fsmonitor.pywatchman.bser', |
2377c4ac4eec
fsmonitor: dependencies for new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
28431
diff
changeset
|
906 ['hgext/fsmonitor/pywatchman/bser.c']), |
5396
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
907 ] |
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
908 |
30445
788ea4ac4388
setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30418
diff
changeset
|
909 sys.path.insert(0, 'contrib/python-zstandard') |
788ea4ac4388
setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30418
diff
changeset
|
910 import setup_zstd |
30698
c3db3bb4699f
setup: pass named argument to setup_zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30467
diff
changeset
|
911 extmodules.append(setup_zstd.get_c_extension(name='mercurial.zstd')) |
30445
788ea4ac4388
setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30418
diff
changeset
|
912 |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
913 try: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
914 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
|
915 |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
916 # the -mno-cygwin option has been deprecated for years |
33663
7686cbb0ba41
setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents:
33600
diff
changeset
|
917 mingw32compilerclass = cygwinccompiler.Mingw32CCompiler |
17121
d13f47c800fd
setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents:
17061
diff
changeset
|
918 |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
919 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
|
920 def __init__(self, *args, **kwargs): |
33663
7686cbb0ba41
setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents:
33600
diff
changeset
|
921 mingw32compilerclass.__init__(self, *args, **kwargs) |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
922 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
|
923 try: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
924 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
|
925 except ValueError: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
926 pass |
17121
d13f47c800fd
setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents:
17061
diff
changeset
|
927 |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
928 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
|
929 except ImportError: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
930 # 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
|
931 # 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
|
932 # DiskStation boxes |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
933 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
|
934 pass |
17121
d13f47c800fd
setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents:
17061
diff
changeset
|
935 |
32802
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
936 if os.name == 'nt': |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
937 # Allow compiler/linker flags to be added to Visual Studio builds. Passing |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
938 # extra_link_args to distutils.extensions.Extension() doesn't have any |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
939 # effect. |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
940 from distutils import msvccompiler |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
941 |
33663
7686cbb0ba41
setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents:
33600
diff
changeset
|
942 msvccompilerclass = msvccompiler.MSVCCompiler |
32802
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
943 |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
944 class HackedMSVCCompiler(msvccompiler.MSVCCompiler): |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
945 def initialize(self): |
33663
7686cbb0ba41
setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents:
33600
diff
changeset
|
946 msvccompilerclass.initialize(self) |
32802
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
947 # "warning LNK4197: export 'func' specified multiple times" |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
948 self.ldflags_shared.append('/ignore:4197') |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
949 self.ldflags_shared_debug.append('/ignore:4197') |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
950 |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
951 msvccompiler.MSVCCompiler = HackedMSVCCompiler |
9a4adc76c88a
setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents:
32745
diff
changeset
|
952 |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
953 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
|
954 'help/*.txt', |
27374
7a70ae647e54
setup.py: package internals help files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27348
diff
changeset
|
955 'help/internals/*.txt', |
23142
c4ce077588d0
config: introduce "built-in" default configuration settings in default.d
Mads Kiilerich <madski@unity3d.com>
parents:
22640
diff
changeset
|
956 '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
|
957 'dummycert.pem']} |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
958 |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
959 def ordinarypath(p): |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
960 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
|
961 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
962 for root in ('templates',): |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
963 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
|
964 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
|
965 dirs[:] = filter(ordinarypath, dirs) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
966 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
|
967 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
|
968 packagedata['mercurial'].append(f) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
969 |
7648
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
970 datafiles = [] |
31325
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31317
diff
changeset
|
971 |
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31317
diff
changeset
|
972 # distutils expects version to be str/unicode. Converting it to |
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31317
diff
changeset
|
973 # unicode on Python 2 still works because it won't contain any |
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31317
diff
changeset
|
974 # non-ascii bytes and will be implicitly converted back to bytes |
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31317
diff
changeset
|
975 # when operated on. |
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31317
diff
changeset
|
976 assert isinstance(version, bytes) |
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31317
diff
changeset
|
977 setupversion = version.decode('ascii') |
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31317
diff
changeset
|
978 |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
979 extra = {} |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
980 |
33600
47829b89c8c6
setup: silence warning of unknown option python_requires on distutils
Yuya Nishihara <yuya@tcha.org>
parents:
33599
diff
changeset
|
981 if issetuptools: |
47829b89c8c6
setup: silence warning of unknown option python_requires on distutils
Yuya Nishihara <yuya@tcha.org>
parents:
33599
diff
changeset
|
982 extra['python_requires'] = supportedpy |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
983 if py2exeloaded: |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
984 extra['console'] = [ |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
985 {'script':'hg', |
35774
854a7315603e
copyright: update to 2018
Anton Shestakov <av6@dwimlabs.net>
parents:
35255
diff
changeset
|
986 'copyright':'Copyright (C) 2005-2018 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
|
987 'product_version':version}] |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
988 # 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
|
989 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
|
990 # 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
|
991 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
|
992 |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
993 if os.name == 'nt': |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
994 # 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
|
995 # 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
|
996 setupversion = version.split('+', 1)[0] |
7648
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
997 |
13583
e42d18538e1d
fix compiling of extensions for OS X and XCode 4.0
Alexander Solovyov <alexander@solovyov.net>
parents:
13400
diff
changeset
|
998 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'): |
33131
176030f695ca
setup: fix runcmd() usage on darwin
Adam Simpkins <simpkins@fb.com>
parents:
33129
diff
changeset
|
999 version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[1].splitlines() |
16187
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
1000 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
|
1001 version = version[0] |
25043
facaceeb85ac
setup: decode xcode version number on python3
Augie Fackler <augie@google.com>
parents:
25009
diff
changeset
|
1002 if sys.version_info[0] == 3: |
facaceeb85ac
setup: decode xcode version number on python3
Augie Fackler <augie@google.com>
parents:
25009
diff
changeset
|
1003 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
|
1004 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
|
1005 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
|
1006 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
|
1007 else: |
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
1008 # 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
|
1009 # 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
|
1010 # 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
|
1011 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
|
1012 xcode51 = False |
16187
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
1013 |
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
|
1014 # 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
|
1015 # distutils.sysconfig |
16187
82ce91a9fd94
setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents:
15527
diff
changeset
|
1016 if xcode4: |
14324
d3a49a52f117
Hardcoding ARCHFLAGS breaks the build against fink's python
Brendan Cully <brendan@kublai.com>
parents:
14295
diff
changeset
|
1017 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
|
1018 |
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
|
1019 # 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
|
1020 # -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
|
1021 # 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
|
1022 # 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
|
1023 # 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
|
1024 # 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
|
1025 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
|
1026 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
|
1027 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
|
1028 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
|
1029 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
|
1030 |
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
|
1031 setup(name='mercurial', |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
1032 version=setupversion, |
18753
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1033 author='Matt Mackall and many others', |
30866
561a019c0268
misc: replace domain of mercurial ML address by mercurial-scm.org
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30698
diff
changeset
|
1034 author_email='mercurial@mercurial-scm.org', |
26421
4b0fc75f9403
urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents:
25409
diff
changeset
|
1035 url='https://mercurial-scm.org/', |
4b0fc75f9403
urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents:
25409
diff
changeset
|
1036 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
|
1037 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
|
1038 'control) system'), |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1039 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
|
1040 ' 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
|
1041 ' 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
|
1042 'Mozilla.'), |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1043 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
|
1044 classifiers=[ |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1045 '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
|
1046 'Environment :: Console', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1047 'Intended Audience :: Developers', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1048 '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
|
1049 '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
|
1050 'Natural Language :: Danish', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1051 'Natural Language :: English', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1052 'Natural Language :: German', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1053 'Natural Language :: Italian', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1054 'Natural Language :: Japanese', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1055 '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
|
1056 '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
|
1057 '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
|
1058 'Operating System :: POSIX', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1059 'Programming Language :: C', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1060 'Programming Language :: Python', |
3f59cb1ccc73
setup.py: add metadata to register package to PyPI
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
17926
diff
changeset
|
1061 '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
|
1062 ], |
6513
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
1063 scripts=scripts, |
6239
39cfcef4f463
Add inotify extension
Bryan O'Sullivan <bos@serpentine.com>
parents:
6009
diff
changeset
|
1064 packages=packages, |
10000
16f49d671c7f
setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents:
9999
diff
changeset
|
1065 ext_modules=extmodules, |
7648
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
1066 data_files=datafiles, |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
1067 package_data=packagedata, |
3238
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
1068 cmdclass=cmdclass, |
15458
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
1069 distclass=hgdist, |
33599
cfa08b06d8b5
setup: forcibly include cext/pure packages in py2exe (issue5625)
Yuya Nishihara <yuya@tcha.org>
parents:
33598
diff
changeset
|
1070 options={'py2exe': {'packages': ['hgdemandimport', 'hgext', 'email', |
cfa08b06d8b5
setup: forcibly include cext/pure packages in py2exe (issue5625)
Yuya Nishihara <yuya@tcha.org>
parents:
33598
diff
changeset
|
1071 # implicitly imported per module policy |
cfa08b06d8b5
setup: forcibly include cext/pure packages in py2exe (issue5625)
Yuya Nishihara <yuya@tcha.org>
parents:
33598
diff
changeset
|
1072 # (cffi wouldn't be used as a frozen exe) |
cfa08b06d8b5
setup: forcibly include cext/pure packages in py2exe (issue5625)
Yuya Nishihara <yuya@tcha.org>
parents:
33598
diff
changeset
|
1073 'mercurial.cext', |
cfa08b06d8b5
setup: forcibly include cext/pure packages in py2exe (issue5625)
Yuya Nishihara <yuya@tcha.org>
parents:
33598
diff
changeset
|
1074 #'mercurial.cffi', |
cfa08b06d8b5
setup: forcibly include cext/pure packages in py2exe (issue5625)
Yuya Nishihara <yuya@tcha.org>
parents:
33598
diff
changeset
|
1075 'mercurial.pure']}, |
22358
198e2da3ee20
osx: create dmg with installer instead of zip
Mads Kiilerich <madski@unity3d.com>
parents:
22198
diff
changeset
|
1076 'bdist_mpkg': {'zipdist': False, |
20687
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
1077 'license': 'COPYING', |
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
1078 'readme': 'contrib/macosx/Readme.html', |
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
1079 'welcome': 'contrib/macosx/Welcome.html', |
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
1080 }, |
7d4d04299927
setup.py: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20644
diff
changeset
|
1081 }, |
3893 | 1082 **extra) |