annotate setup.py @ 43137:81efc4a295e7

sidedatacopies: add a new requirement for storing copies into sidedata The end goal is to have changesets centric sidedata information stored into changelog sidedata. This make it possible to use the changeset based copy tracing algorithm on any repository without affecting hashes. The actual implementation is coming. The feature is marked as experimental (do not use in production) until we stabilise details about the format. Differential Revision: https://phab.mercurial-scm.org/D6945
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 06 Oct 2019 23:36:51 -0400
parents 2372284d9457
children c3e10f705a6c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
575
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
1 #
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
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.
39588
b6b9488aae4c setup: don't support py 3.5.0, 3.5.1, 3.5.2 because of bug in codecs
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39356
diff changeset
14 # We cannot support Python 3.5.0, 3.5.1, 3.5.2 because of bug in
b6b9488aae4c setup: don't support py 3.5.0, 3.5.1, 3.5.2 because of bug in codecs
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39356
diff changeset
15 # codecs.escape_encode() where it raises SystemError on empty bytestring
b6b9488aae4c setup: don't support py 3.5.0, 3.5.1, 3.5.2 because of bug in codecs
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39356
diff changeset
16 # bug link: https://bugs.python.org/issue25270
33587
e0bbe32d8b55 setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents: 33131
diff changeset
17 #
e0bbe32d8b55 setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents: 33131
diff changeset
18 # 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
19 # actual supportedpy string.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
20 supportedpy = ','.join(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
21 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
22 '>=2.7',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
23 '!=3.0.*',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
24 '!=3.1.*',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
25 '!=3.2.*',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
26 '!=3.3.*',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
27 '!=3.4.*',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
28 '!=3.5.0',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
29 '!=3.5.1',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
30 '!=3.5.2',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
31 '!=3.6.0',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
32 '!=3.6.1',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
33 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
34 )
33587
e0bbe32d8b55 setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents: 33131
diff changeset
35
14295
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
36 import sys, platform
42473
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
37 import sysconfig
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
38
11532
f3732ab1149f setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents: 11468
diff changeset
39 if sys.version_info[0] >= 3:
20696
77ab0abb08a0 setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents: 20687
diff changeset
40 printf = eval('print')
77ab0abb08a0 setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents: 20687
diff changeset
41 libdir_escape = 'unicode_escape'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
42
35255
d73ccc63b8f9 setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents: 35238
diff changeset
43 def sysstr(s):
d73ccc63b8f9 setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents: 35238
diff changeset
44 return s.decode('latin-1')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
45
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
46
11532
f3732ab1149f setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents: 11468
diff changeset
47 else:
20696
77ab0abb08a0 setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents: 20687
diff changeset
48 libdir_escape = 'string_escape'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
49
20696
77ab0abb08a0 setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents: 20687
diff changeset
50 def printf(*args, **kwargs):
77ab0abb08a0 setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents: 20687
diff changeset
51 f = kwargs.get('file', sys.stdout)
77ab0abb08a0 setup: handle more invalid python3 syntax
Augie Fackler <raf@durin42.com>
parents: 20687
diff changeset
52 end = kwargs.get('end', '\n')
27348
83a8219fb790 setup.py: use bytes literals
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27269
diff changeset
53 f.write(b' '.join(args) + end)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
54
35255
d73ccc63b8f9 setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents: 35238
diff changeset
55 def sysstr(s):
d73ccc63b8f9 setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents: 35238
diff changeset
56 return s
11532
f3732ab1149f setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents: 11468
diff changeset
57
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
58
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
59 # 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
60 # 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
61 # 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
62 # 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
63 if sys.version_info < (2, 7, 0, 'final'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
64 pip_message = (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
65 'This may be due to an out of date pip. '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
66 'Make sure you have pip >= 9.0.1.'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
67 )
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
68 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
69 import pip
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
70
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
71 pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]])
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
72 if pip_version < (9, 0, 1):
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
73 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
74 'Your pip version is out of date, please install '
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
75 'pip >= 9.0.1. pip {} detected.'.format(pip.__version__)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
76 )
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
77 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
78 # 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
79 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
80 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
81 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
82 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
83 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
84 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
85 {pip}
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
86 """.format(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
87 py=sys.version_info, pip=pip_message
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
88 )
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
89 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
90 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
91
35830
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
92 # 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
93 # 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
94 # 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
95 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
96 badpython = True
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
97
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
98 # Allow Python 3 from source checkouts.
38721
dbbe45ae5ad1 setup: allow to run setup.py with python 3 without a mercurial checkout
Mike Hommey <mh@glandium.org>
parents: 38219
diff changeset
99 if os.path.isdir('.hg') or 'HGPYTHON3' in os.environ:
35830
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
100 badpython = False
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
101
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
102 if badpython:
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
103 error = """
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
104 Python {py} detected.
42153
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
105
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
106 Mercurial currently has beta support for Python 3 and use of Python 2.7 is
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
107 recommended for the best experience.
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
108
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
109 Please re-run with Python 2.7 for a faster, less buggy experience.
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
110
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
111 If you would like to beta test Mercurial with Python 3, this error can
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
112 be suppressed by defining the HGPYTHON3 environment variable when invoking
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
113 this command. No special environment variables or configuration changes are
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
114 necessary to run `hg` with Python 3.
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
115
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
116 See https://www.mercurial-scm.org/wiki/Python3 for more on Mercurial's
cd1bede340b0 setup: tweak error message for Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42152
diff changeset
117 Python 3 support.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
118 """.format(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
119 py='.'.join('%d' % x for x in sys.version_info[0:2])
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
120 )
35830
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
121
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
122 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
123 sys.exit(1)
fb39f6a8a864 setup: only allow Python 3 from a source checkout (issue5804)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35774
diff changeset
124
42473
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
125 if sys.version_info[0] >= 3:
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
126 DYLIB_SUFFIX = sysconfig.get_config_vars()['EXT_SUFFIX']
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
127 else:
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
128 # deprecated in Python 3
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
129 DYLIB_SUFFIX = sysconfig.get_config_vars()['SO']
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
130
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
131 # Solaris Python packaging brain damage
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
132 try:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
133 import hashlib
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
134
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
135 sha = hashlib.sha1()
16688
cfb6682961b8 cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 16683
diff changeset
136 except ImportError:
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
137 try:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
138 import sha
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
139
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
140 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
141 except ImportError:
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
142 raise SystemExit(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
143 "Couldn't import standard hashlib (incomplete Python install)."
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
144 )
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
145
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
146 try:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
147 import zlib
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
148
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
149 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
150 except ImportError:
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
151 raise SystemExit(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
152 "Couldn't import standard zlib (incomplete Python install)."
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
153 )
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
154
14295
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
155 # 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
156 isironpython = False
10761
16a13fdb4b36 setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10521
diff changeset
157 try:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
158 isironpython = (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
159 platform.python_implementation().lower().find("ironpython") != -1
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
160 )
16688
cfb6682961b8 cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 16683
diff changeset
161 except AttributeError:
14295
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
162 pass
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
163
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
164 if isironpython:
15492
36f076d03b34 setup: make script executable with python3
Simon Heimberg <simohe@besonet.ch>
parents: 15460
diff changeset
165 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
166 else:
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
167 try:
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
168 import bz2
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
169
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
170 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
171 except ImportError:
14295
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
172 raise SystemExit(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
173 "Couldn't import standard bz2 (incomplete Python install)."
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
174 )
10761
16a13fdb4b36 setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10521
diff changeset
175
24192
390410a6545d setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents: 24191
diff changeset
176 ispypy = "PyPy" in sys.version
390410a6545d setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents: 24191
diff changeset
177
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
178 hgrustext = os.environ.get('HGWITHRUSTEXT')
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
179 # TODO record it for proper rebuild upon changes
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
180 # (see mercurial/__modulepolicy__.py)
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
181 if hgrustext != 'cpython' and hgrustext is not None:
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
182 hgrustext = 'direct-ffi'
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
183
29020
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
184 import ctypes
40979
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
185 import errno
33591
ee11d18fcd3c setup: fix mistake that prevented Python 3 from being excluded
Augie Fackler <augie@google.com>
parents: 33589
diff changeset
186 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
187 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
188 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
189 import tempfile
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
190 from distutils import log
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
191
31298
718a57e95a89 setup: use setuptools on Windows (issue5400)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30869
diff changeset
192 # 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
193 # 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
194 # we don't have issues.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
195 issetuptools = os.name == 'nt' or 'FORCE_SETUPTOOLS' in os.environ
33600
47829b89c8c6 setup: silence warning of unknown option python_requires on distutils
Yuya Nishihara <yuya@tcha.org>
parents: 33599
diff changeset
196 if issetuptools:
26600
e8497889edab setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents: 26421
diff changeset
197 from setuptools import setup
e8497889edab setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents: 26421
diff changeset
198 else:
e8497889edab setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents: 26421
diff changeset
199 from distutils.core import setup
30418
ce9a3033c118 setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents: 30356
diff changeset
200 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
201 from distutils.core import Command, Extension
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
202 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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 CCompilerError,
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
214 DistutilsError,
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
215 DistutilsExecError,
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
216 )
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
217 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
218 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
219
40420
b6bc2293cdf3 setup: explain to distutils how we write rc versions
"Paul Morelle <paul.morelle@octobus.net"
parents: 40397
diff changeset
220 # Explain to distutils.StrictVersion how our release candidates are versionned
b6bc2293cdf3 setup: explain to distutils how we write rc versions
"Paul Morelle <paul.morelle@octobus.net"
parents: 40397
diff changeset
221 StrictVersion.version_re = re.compile(r'^(\d+)\.(\d+)(\.(\d+))?-?(rc(\d+))?$')
b6bc2293cdf3 setup: explain to distutils how we write rc versions
"Paul Morelle <paul.morelle@octobus.net"
parents: 40397
diff changeset
222
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
223
35238
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
224 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
225 """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
226 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
227 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
228 current = fh.read()
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
229 else:
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
230 current = b''
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
231
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
232 if current != content:
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
233 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
234 fh.write(content)
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
235
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
236
6513
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
237 scripts = ['hg']
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
238 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
239 # 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
240 scripts.append('contrib/win32/hg.bat')
3893
070628929e1f Fix setup.py warning
Matt Mackall <mpm@selenic.com>
parents: 3892
diff changeset
241
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
242
31565
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
243 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
244 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
245 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
246 try:
31565
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
247 fname = os.path.join(tmpdir, 'testcomp.c')
25089
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
248 f = open(fname, 'w')
31565
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
249 f.write(code)
25089
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
250 f.close()
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
251 # 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
252 # from the compiler.
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
253 # 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
254 # for a function on Windows.
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
255 devnull = open('/dev/null', 'w')
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
256 oldstderr = os.dup(sys.stderr.fileno())
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
257 os.dup2(devnull.fileno(), sys.stderr.fileno())
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
258 objects = cc.compile([fname], output_dir=tmpdir)
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
259 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
260 return True
25089
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
261 except Exception:
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
262 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
263 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
264 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
265 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
266 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
267 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
268 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
269
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
270
31565
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
271 # 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
272 # that actually removes its temporary files.
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
273 def hasfunction(cc, funcname):
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
274 code = 'int main(void) { %s(); }\n' % funcname
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
275 return cancompile(cc, code)
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
276
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
277
31566
5a0460219649 setup: add a function to test header files
Jun Wu <quark@fb.com>
parents: 31565
diff changeset
278 def hasheader(cc, headername):
5a0460219649 setup: add a function to test header files
Jun Wu <quark@fb.com>
parents: 31565
diff changeset
279 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
280 return cancompile(cc, code)
5a0460219649 setup: add a function to test header files
Jun Wu <quark@fb.com>
parents: 31565
diff changeset
281
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
282
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
283 # py2exe needs to be installed to work
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
284 try:
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
285 import py2exe
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
286
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
287 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
288 py2exeloaded = True
15527
9926aab3d0b5 setup: fix py2exe generation broken by c3a6ec304055 (issue3116)
Pascal Quantin <pascal.quantin@gmail.com>
parents: 15523
diff changeset
289 # 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
290 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
291 except ImportError:
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
292 py2exeloaded = False
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
293
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
294
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
295 def runcmd(cmd, env, cwd=None):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
296 p = subprocess.Popen(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
297 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, cwd=cwd
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
298 )
32904
19b0fd4b5570 plan9: drop py26 hacks
Matt Harbison <matt_harbison@yahoo.com>
parents: 32802
diff changeset
299 out, err = p.communicate()
33123
87ee783f7299 setup: update runcmd() to also return the exit status
Adam Simpkins <simpkins@fb.com>
parents: 33122
diff changeset
300 return p.returncode, out, err
13636
4bfff063aed6 setup: fix mac build broken by e42d18538e1d
Jon M. Dugan <jdugan@x1024.net>
parents: 13594
diff changeset
301
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
302
33125
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
303 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
304 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
305 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
306 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
307
33125
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
308 def run(self, args):
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
309 cmd = self.cmd + args
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
310 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
311 err = filterhgerr(err)
33125
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
312 if err or returncode != 0:
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
313 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
314 printf(err, file=sys.stderr)
33125
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
315 return ''
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
316 return out
8548
3ccbe42ff72f setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 8547
diff changeset
317
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
318
33598
f30714a55523 setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents: 33591
diff changeset
319 def filterhgerr(err):
f30714a55523 setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents: 33591
diff changeset
320 # 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
321 # 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
322 # 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
323 # 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
324 # a missing __init__.py in mercurial/locale, we also ignore that.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
325 err = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
326 e
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
327 for e in err.splitlines()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
328 if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
329 not e.startswith(b'not trusting file')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
330 and not e.startswith(b'warning: Not importing')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
331 and not e.startswith(b'obsolete feature not enabled')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
332 and not e.startswith(b'*** failed to import extension')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
333 and not e.startswith(b'devel-warn:')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
334 and not (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
335 e.startswith(b'(third party extension')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
336 and e.endswith(b'or newer of Mercurial; disabling)')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
337 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
338 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
339 ]
33598
f30714a55523 setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents: 33591
diff changeset
340 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
341
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
342
33126
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
343 def findhg():
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
344 """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
345 repository contents.
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
346
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
347 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
348 # 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
349 # 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
350 #
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
351 # 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
352 # 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
353 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
354 # 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
355 # 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
356 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
357 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
358 hgcmd = ['hg']
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
359 # Run a simple "hg log" command just to see if using hg from the user's
40993
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
360 # path works and can successfully interact with this repository. Windows
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
361 # gives precedence to hg.exe in the current directory, so fall back to the
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
362 # python invocation of local hg, where pythonXY.dll can always be found.
33126
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
363 check_cmd = ['log', '-r.', '-Ttest']
40993
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
364 if os.name != 'nt':
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
365 try:
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
366 retcode, out, err = runcmd(hgcmd + check_cmd, hgenv)
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
367 except EnvironmentError:
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
368 retcode = -1
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
369 if retcode == 0 and not filterhgerr(err):
f6987f654356 setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40980
diff changeset
370 return hgcommand(hgcmd, hgenv)
33126
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
371
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
372 # 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
373 hgenv = localhgenv()
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
374 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
375 try:
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
376 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
377 except EnvironmentError:
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
378 retcode = -1
33598
f30714a55523 setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents: 33591
diff changeset
379 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
380 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
381
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
382 raise SystemExit(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
383 'Unable to find a working hg binary to extract the '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
384 'version from the repository tags'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
385 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
386
33126
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
387
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
388 def localhgenv():
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
389 """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
390 mercurial from the local repository."""
33124
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
391 # 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
392 # care to not use any hgrc files and do no localization.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
393 env = {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
394 'HGMODULEPOLICY': 'py',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
395 'HGRCPATH': '',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
396 'LANGUAGE': 'C',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
397 'PATH': '',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
398 } # make pypi modules that use os.environ['PATH'] happy
33124
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
399 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
400 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
401 if 'SystemRoot' in os.environ:
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
402 # 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
403 # https://bugs.python.org/issue13524#msg148850
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
404 env['SystemRoot'] = os.environ['SystemRoot']
33129
6ef5f0c95d64 setup: fix localhgenv
Jun Wu <quark@fb.com>
parents: 33126
diff changeset
405 return env
33124
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
406
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
407
33124
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
408 version = ''
15367
b357a972d6cd setup: set env global earlier (3073)
Matt Mackall <mpm@selenic.com>
parents: 15215
diff changeset
409
8547
548fd7a05373 setup.py: subprocess instead of os.popen, sys.stderr.write instead of print
Christian Ebert <blacktrash@gmx.net>
parents: 8494
diff changeset
410 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
411 hg = findhg()
33125
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
412 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
413 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
414 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
415 if not hgid:
6fdc1518983e setup: fail if we cannot determine the version number
Adam Simpkins <simpkins@fb.com>
parents: 33115
diff changeset
416 # 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
417 # 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
418 # 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
419 # that define minimumhgversion.
6fdc1518983e setup: fail if we cannot determine the version number
Adam Simpkins <simpkins@fb.com>
parents: 33115
diff changeset
420 raise SystemExit('Unable to determine hg version from local repository')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
421 if numerictags: # tag(s) found
17709
b7fff47bb128 setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents: 17606
diff changeset
422 version = numerictags[-1]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
423 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
424 version += '+'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
425 else: # no tag found
33125
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
426 ltagcmd = ['parents', '--template', '{latesttag}']
35255
d73ccc63b8f9 setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents: 35238
diff changeset
427 ltag = sysstr(hg.run(ltagcmd))
33125
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
428 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
429 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
430 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
431 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
432 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
433 elif os.path.exists('.hg_archival.txt'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
434 kw = dict(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
435 [[t.strip() for t in l.split(':', 1)] for l in open('.hg_archival.txt')]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
436 )
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
437 if 'tag' in kw:
27637
b502138f5faa cleanup: remove superfluous space after space after equals (python)
timeless <timeless@mozdev.org>
parents: 27374
diff changeset
438 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
439 elif 'latesttag' in kw:
23646
9641643fac71 setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents: 23392
diff changeset
440 if 'changessincelatesttag' in kw:
9641643fac71 setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents: 23392
diff changeset
441 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
442 else:
9641643fac71 setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents: 23392
diff changeset
443 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
444 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
445 version = kw.get('node', '')[:12]
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
446
8548
3ccbe42ff72f setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 8547
diff changeset
447 if version:
35238
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
448 versionb = version
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
449 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
450 versionb = versionb.encode('ascii')
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
451
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
452 write_if_changed(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
453 'mercurial/__version__.py',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
454 b''.join(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
455 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
456 b'# this file is autogenerated by setup.py\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
457 b'version = b"%s"\n' % versionb,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
458 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
459 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
460 )
8493
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
461
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
462 try:
28431
a7e3b72cf756 setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents: 28430
diff changeset
463 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
464 os.environ['HGMODULEPOLICY'] = 'py'
8493
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
465 from mercurial import __version__
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
466
8493
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
467 version = __version__.version
4c030ada58d2 Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 7826
diff changeset
468 except ImportError:
38721
dbbe45ae5ad1 setup: allow to run setup.py with python 3 without a mercurial checkout
Mike Hommey <mh@glandium.org>
parents: 38219
diff changeset
469 version = b'unknown'
28431
a7e3b72cf756 setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents: 28430
diff changeset
470 finally:
a7e3b72cf756 setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents: 28430
diff changeset
471 if oldpolicy is None:
a7e3b72cf756 setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents: 28430
diff changeset
472 del os.environ['HGMODULEPOLICY']
a7e3b72cf756 setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents: 28430
diff changeset
473 else:
a7e3b72cf756 setup: show how to set the module policy for imports
timeless <timeless@mozdev.org>
parents: 28430
diff changeset
474 os.environ['HGMODULEPOLICY'] = oldpolicy
7632
9626819b2e3d refactor version code
Matt Mackall <mpm@selenic.com>
parents: 7558
diff changeset
475
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
476
15460
f9f0731dbc56 setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents: 15459
diff changeset
477 class hgbuild(build):
f9f0731dbc56 setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents: 15459
diff changeset
478 # 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
479 # when build_py is run next.
28398
712298942c82 setup: remove support for 2to3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28041
diff changeset
480 sub_commands = [('build_mo', None)] + build.sub_commands
15460
f9f0731dbc56 setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents: 15459
diff changeset
481
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
482
15523
f9da84a950d0 setup: backout 8504699d1aa6
Matt Mackall <mpm@selenic.com>
parents: 15500
diff changeset
483 class hgbuildmo(build):
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
484
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
485 description = "build translations (.mo files)"
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
486
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
487 def run(self):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
488 if not find_executable('msgfmt'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
489 self.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
490 "could not find msgfmt executable, no translations "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
491 "will be built"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
492 )
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
493 return
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
494
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
495 podir = 'i18n'
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
496 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
497 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
498 return
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
499
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
500 join = os.path.join
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
501 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
502 if not po.endswith('.po'):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
503 continue
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
504 pofile = join(podir, po)
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
505 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
506 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
507 mobuildfile = join('mercurial', mofile)
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
508 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
509 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
510 # 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
511 cmd.append('-c')
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
512 self.mkpath(join('mercurial', modir))
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
513 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
514
12661
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
515
15458
c3a6ec304055 setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents: 15388
diff changeset
516 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
517 pure = False
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
518 rust = hgrustext is not None
29505
2dce3f96ad7b setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
519 cffi = ispypy
15458
c3a6ec304055 setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents: 15388
diff changeset
520
41768
aaad36b88298 cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents: 41547
diff changeset
521 global_options = Distribution.global_options + [
aaad36b88298 cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents: 41547
diff changeset
522 ('pure', None, "use pure (slow) Python code instead of C extensions"),
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
523 ('rust', None, "use Rust extensions additionally to C extensions"),
41768
aaad36b88298 cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents: 41547
diff changeset
524 ]
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
525
15459
434c48e981b8 setup: has_ext_modules always returns false when pure is specified
Simon Heimberg <simohe@besonet.ch>
parents: 15458
diff changeset
526 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
527 # 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
528 # 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
529 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
530
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
531
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
532 # 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
533 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
534 buildextnegops['no-zstd'] = 'zstd'
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
535 buildextnegops['no-rust'] = 'rust'
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
536
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
537
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
538 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
539 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
540 ('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
541 ('no-zstd', None, 'do not compile zstd bindings'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
542 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
543 'rust',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
544 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
545 'compile Rust extensions if they are in use '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
546 '(requires Cargo) [default]',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
547 ),
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
548 ('no-rust', None, 'do not compile Rust extensions'),
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
549 ]
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
550
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
551 boolean_options = build_ext.boolean_options + ['zstd', 'rust']
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
552 negative_opt = buildextnegops
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
553
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
554 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
555 self.zstd = True
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
556 self.rust = True
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
557
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
558 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
559
43044
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
560 def finalize_options(self):
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
561 # Unless overridden by the end user, build extensions in parallel.
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
562 # Only influences behavior on Python 3.5+.
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
563 if getattr(self, 'parallel', None) is None:
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
564 self.parallel = True
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
565
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
566 return build_ext.finalize_options(self)
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
567
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
568 def build_extensions(self):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
569 ruststandalones = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
570 e for e in self.extensions if isinstance(e, RustStandaloneExtension)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
571 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
572 self.extensions = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
573 e for e in self.extensions if e not in ruststandalones
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
574 ]
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
575 # 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
576 if not self.zstd:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
577 self.extensions = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
578 e for e in self.extensions if e.name != 'mercurial.zstd'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
579 ]
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
580
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
581 # Build Rust standalon extensions if it'll be used
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
582 # and its build is not explictely disabled (for external build
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
583 # as Linux distributions would do)
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
584 if self.distribution.rust and self.rust and hgrustext != 'direct-ffi':
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
585 for rustext in ruststandalones:
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
586 rustext.build('' if self.inplace else self.build_lib)
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
587
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
588 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
589
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
590 def build_extension(self, ext):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
591 if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
592 self.distribution.rust
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
593 and self.rust
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
594 and isinstance(ext, RustExtension)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
595 ):
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
596 ext.rustbuild()
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
597 try:
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
598 build_ext.build_extension(self, ext)
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
599 except CCompilerError:
12501
98f21e4d9633 setup: slight simplification
Martin Geisler <mg@lazybytes.net>
parents: 11533
diff changeset
600 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
601 raise
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
602 log.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
603 "Failed to build optional extension '%s' (skipping)", ext.name
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
604 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
605
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
606
27268
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
607 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
608 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
609 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
610 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
611
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
612 exebuilt = False
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
613 try:
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
614 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
615 exebuilt = True
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
616 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
617 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
618
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
619 if exebuilt:
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
620 # 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
621 # 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
622 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
623 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
624 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
625 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
626
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
627 # 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
628 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
629
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
630 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
631
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
632
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
633 class hgbuildpy(build_py):
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
634 def finalize_options(self):
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
635 build_py.finalize_options(self)
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
636
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
637 if self.distribution.pure:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
638 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
639 elif self.distribution.cffi:
30356
9cc438bf7d9a setup: move cffi stuff to mercurial/cffi
Jun Wu <quark@fb.com>
parents: 29844
diff changeset
640 from mercurial.cffi import (
32538
05a16c19967e cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents: 32458
diff changeset
641 bdiffbuild,
05a16c19967e cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents: 32458
diff changeset
642 mpatchbuild,
30356
9cc438bf7d9a setup: move cffi stuff to mercurial/cffi
Jun Wu <quark@fb.com>
parents: 29844
diff changeset
643 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
644
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
645 exts = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
646 mpatchbuild.ffi.distutils_extension(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
647 bdiffbuild.ffi.distutils_extension(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
648 ]
29505
2dce3f96ad7b setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
649 # 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
650 if sys.platform == 'darwin':
32538
05a16c19967e cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents: 32458
diff changeset
651 from mercurial.cffi import osutilbuild
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
652
32538
05a16c19967e cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents: 32458
diff changeset
653 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
654 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
655 else:
18905
012780620d4f setup: make error message for missing Python headers more helpful
Mads Kiilerich <mads@kiilerich.com>
parents: 18900
diff changeset
656 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
657 if not os.path.exists(h):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
658 raise SystemExit(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
659 'Python headers are required to build '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
660 'Mercurial but weren\'t found in %s' % h
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
661 )
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
662
28430
17b85d739b62 setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents: 28418
diff changeset
663 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
664 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
665 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
666
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
667 rust = self.distribution.rust
28430
17b85d739b62 setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents: 28418
diff changeset
668 if self.distribution.pure:
17b85d739b62 setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents: 28418
diff changeset
669 modulepolicy = 'py'
32291
a04f5c651e52 policy: relax the default for in-place build
Yuya Nishihara <yuya@tcha.org>
parents: 32273
diff changeset
670 elif self.build_lib == '.':
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
671 # in-place build should run without rebuilding and Rust extensions
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
672 modulepolicy = 'rust+c-allow' if rust else 'allow'
28430
17b85d739b62 setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents: 28418
diff changeset
673 else:
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
674 modulepolicy = 'rust+c' if rust else 'c'
35238
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
675
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
676 content = b''.join(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
677 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
678 b'# this file is autogenerated by setup.py\n',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
679 b'modulepolicy = b"%s"\n' % modulepolicy.encode('ascii'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
680 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
681 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
682 write_if_changed(os.path.join(basepath, '__modulepolicy__.py'), content)
27222
511a4384b033 setup: refactor handling of modules with C/Python implementations
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27220
diff changeset
683
28430
17b85d739b62 setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents: 28418
diff changeset
684 build_py.run(self)
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
685
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
686
14538
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
687 class buildhgextindex(Command):
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
688 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
689 user_options = []
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
690 _indexfilename = 'hgext/__index__.py'
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
691
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
692 def initialize_options(self):
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
693 pass
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
694
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
695 def finalize_options(self):
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
696 pass
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
697
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
698 def run(self):
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
699 if os.path.exists(self._indexfilename):
28418
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
700 with open(self._indexfilename, 'w') as f:
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
701 f.write('# empty\n')
14538
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
702
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
703 # here no extension enabled, disabled() lists up everything
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
704 code = (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
705 'import pprint; from mercurial import extensions; '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
706 'pprint.pprint(extensions.disabled())'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
707 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
708 returncode, out, err = runcmd(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
709 [sys.executable, '-c', code], localhgenv()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
710 )
33123
87ee783f7299 setup: update runcmd() to also return the exit status
Adam Simpkins <simpkins@fb.com>
parents: 33122
diff changeset
711 if err or returncode != 0:
14538
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
712 raise DistutilsExecError(err)
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
713
42075
456c37433c43 py3: write out hgextindex as bytes in setup.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 42074
diff changeset
714 with open(self._indexfilename, 'wb') as f:
456c37433c43 py3: write out hgextindex as bytes in setup.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 42074
diff changeset
715 f.write(b'# this file is autogenerated by setup.py\n')
456c37433c43 py3: write out hgextindex as bytes in setup.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 42074
diff changeset
716 f.write(b'docs = ')
28418
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
717 f.write(out)
14538
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
718
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
719
17061
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
720 class buildhgexe(build_ext):
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
721 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
722 user_options = build_ext.user_options + [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
723 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
724 'long-paths-support',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
725 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
726 'enable support for long paths on '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
727 'Windows (off by default and '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
728 'experimental)',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
729 ),
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
730 ]
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
731
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
732 LONG_PATHS_MANIFEST = """
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
733 <?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
734 <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
735 <application>
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
736 <windowsSettings
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
737 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
738 <ws2:longPathAware>true</ws2:longPathAware>
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
739 </windowsSettings>
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
740 </application>
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
741 </assembly>"""
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
742
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
743 def initialize_options(self):
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
744 build_ext.initialize_options(self)
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
745 self.long_paths_support = False
17061
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
746
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
747 def build_extensions(self):
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
748 if os.name != 'nt':
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
749 return
17246
bf5bb38bcc7c setup: fix build_hgexe for mingw32 compiler
Adrian Buehlmann <adrian@cadifra.com>
parents: 17121
diff changeset
750 if isinstance(self.compiler, HackedMingw32CCompiler):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
751 self.compiler.compiler_so = self.compiler.compiler # no -mdll
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
752 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
753
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
754 # 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
755 # 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
756 # 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
757 _kernel32 = ctypes.windll.kernel32
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
758 _kernel32.GetModuleFileNameA.argtypes = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
759 ctypes.c_void_p,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
760 ctypes.c_void_p,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
761 ctypes.c_ulong,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
762 ]
29020
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
763 _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
764 size = 1000
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
765 buf = ctypes.create_string_buffer(size + 1)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
766 filelen = _kernel32.GetModuleFileNameA(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
767 sys.dllhandle, ctypes.byref(buf), size
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
768 )
29020
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
769
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
770 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
771 dllbasename = os.path.basename(buf.value)
39624
ec68135a8935 py3: add b'' to some setup.py strings for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 39588
diff changeset
772 if not dllbasename.lower().endswith(b'.dll'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
773 raise SystemExit(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
774 'Python DLL does not end with .dll: %s' % dllbasename
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
775 )
29020
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
776 pythonlib = dllbasename[:-4]
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
777 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
778 log.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
779 'could not determine Python DLL filename; ' 'assuming pythonXY'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
780 )
29020
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
781
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
782 hv = sys.hexversion
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
783 pythonlib = 'python%d%d' % (hv >> 24, (hv >> 16) & 0xFF)
29020
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
784
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
785 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
786 with open('mercurial/hgpythonlib.h', 'wb') as f:
39624
ec68135a8935 py3: add b'' to some setup.py strings for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 39588
diff changeset
787 f.write(b'/* this file is autogenerated by setup.py */\n')
ec68135a8935 py3: add b'' to some setup.py strings for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 39588
diff changeset
788 f.write(b'#define HGPYTHONLIB "%s"\n' % pythonlib)
40397
36b134c436b8 setup: build exewrapper with Unicode support on py3
Matt Harbison <matt_harbison@yahoo.com>
parents: 40383
diff changeset
789
36b134c436b8 setup: build exewrapper with Unicode support on py3
Matt Harbison <matt_harbison@yahoo.com>
parents: 40383
diff changeset
790 macros = None
36b134c436b8 setup: build exewrapper with Unicode support on py3
Matt Harbison <matt_harbison@yahoo.com>
parents: 40383
diff changeset
791 if sys.version_info[0] >= 3:
36b134c436b8 setup: build exewrapper with Unicode support on py3
Matt Harbison <matt_harbison@yahoo.com>
parents: 40383
diff changeset
792 macros = [('_UNICODE', None), ('UNICODE', None)]
36b134c436b8 setup: build exewrapper with Unicode support on py3
Matt Harbison <matt_harbison@yahoo.com>
parents: 40383
diff changeset
793
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
794 objects = self.compiler.compile(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
795 ['mercurial/exewrapper.c'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
796 output_dir=self.build_temp,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
797 macros=macros,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
798 )
17061
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
799 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
800 self.hgtarget = os.path.join(dir, 'hg')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
801 self.compiler.link_executable(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
802 objects, self.hgtarget, libraries=[], output_dir=self.build_temp
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
803 )
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
804 if self.long_paths_support:
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
805 self.addlongpathsmanifest()
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
806
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
807 def addlongpathsmanifest(self):
41547
0f64091cc851 global: make some docstrings raw strings
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41313
diff changeset
808 r"""Add manifest pieces so that hg.exe understands long paths
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
809
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
810 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
811 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
812 - 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
813 - 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
814 LongPathsEnabled to have value 1.
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
815
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
816 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
817 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
818 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
819 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
820
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
821 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
822 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
823 """
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
824 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
825 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
826 os.close(fdauto)
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
827 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
828 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
829 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
830 inputresource = '-inputresource:%s;#1' % exefname
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
831 outputresource = '-outputresource:%s;#1' % exefname
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
832 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
833 # 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
834 # it merge the embedded and supplied manifests in the -outputresource
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
835 self.spawn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
836 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
837 'mt.exe',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
838 '-nologo',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
839 '-manifest',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
840 manfname,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
841 inputresource,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
842 outputresource,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
843 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
844 )
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
845 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
846 os.remove(manfname)
17061
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
847
27268
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
848 @property
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
849 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
850 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
851 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
852
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
853
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
854 class hgbuilddoc(Command):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
855 description = 'build documentation'
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
856 user_options = [
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
857 ('man', None, 'generate man pages'),
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
858 ('html', None, 'generate html pages'),
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
859 ]
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
860
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
861 def initialize_options(self):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
862 self.man = None
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
863 self.html = None
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
864
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
865 def finalize_options(self):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
866 # If --man or --html are set, only generate what we're told to.
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
867 # Otherwise generate everything.
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
868 have_subset = self.man is not None or self.html is not None
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
869
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
870 if have_subset:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
871 self.man = True if self.man else False
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
872 self.html = True if self.html else False
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
873 else:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
874 self.man = True
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
875 self.html = True
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
876
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
877 def run(self):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
878 def normalizecrlf(p):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
879 with open(p, 'rb') as fh:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
880 orig = fh.read()
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
881
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
882 if b'\r\n' not in orig:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
883 return
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
884
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
885 log.info('normalizing %s to LF line endings' % p)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
886 with open(p, 'wb') as fh:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
887 fh.write(orig.replace(b'\r\n', b'\n'))
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
888
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
889 def gentxt(root):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
890 txt = 'doc/%s.txt' % root
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
891 log.info('generating %s' % txt)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
892 res, out, err = runcmd(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
893 [sys.executable, 'gendoc.py', root], os.environ, cwd='doc'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
894 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
895 if res:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
896 raise SystemExit(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
897 'error running gendoc.py: %s' % '\n'.join([out, err])
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
898 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
899
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
900 with open(txt, 'wb') as fh:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
901 fh.write(out)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
902
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
903 def gengendoc(root):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
904 gendoc = 'doc/%s.gendoc.txt' % root
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
905
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
906 log.info('generating %s' % gendoc)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
907 res, out, err = runcmd(
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
908 [sys.executable, 'gendoc.py', '%s.gendoc' % root],
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
909 os.environ,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
910 cwd='doc',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
911 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
912 if res:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
913 raise SystemExit(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
914 'error running gendoc: %s' % '\n'.join([out, err])
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
915 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
916
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
917 with open(gendoc, 'wb') as fh:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
918 fh.write(out)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
919
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
920 def genman(root):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
921 log.info('generating doc/%s' % root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
922 res, out, err = runcmd(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
923 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
924 sys.executable,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
925 'runrst',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
926 'hgmanpage',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
927 '--halt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
928 'warning',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
929 '--strip-elements-with-class',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
930 'htmlonly',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
931 '%s.txt' % root,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
932 root,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
933 ],
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
934 os.environ,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
935 cwd='doc',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
936 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
937 if res:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
938 raise SystemExit(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
939 'error running runrst: %s' % '\n'.join([out, err])
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
940 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
941
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
942 normalizecrlf('doc/%s' % root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
943
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
944 def genhtml(root):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
945 log.info('generating doc/%s.html' % root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
946 res, out, err = runcmd(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
947 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
948 sys.executable,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
949 'runrst',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
950 'html',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
951 '--halt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
952 'warning',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
953 '--link-stylesheet',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
954 '--stylesheet-path',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
955 'style.css',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
956 '%s.txt' % root,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
957 '%s.html' % root,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
958 ],
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
959 os.environ,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
960 cwd='doc',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
961 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
962 if res:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
963 raise SystemExit(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
964 'error running runrst: %s' % '\n'.join([out, err])
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
965 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
966
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
967 normalizecrlf('doc/%s.html' % root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
968
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
969 # This logic is duplicated in doc/Makefile.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
970 sources = set(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
971 f
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
972 for f in os.listdir('mercurial/help')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
973 if re.search(r'[0-9]\.txt$', f)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
974 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
975
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
976 # common.txt is a one-off.
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
977 gentxt('common')
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
978
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
979 for source in sorted(sources):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
980 assert source[-4:] == '.txt'
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
981 root = source[:-4]
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
982
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
983 gentxt(root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
984 gengendoc(root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
985
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
986 if self.man:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
987 genman(root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
988 if self.html:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
989 genhtml(root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
990
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
991
32670
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
992 class hginstall(install):
32745
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
993
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
994 user_options = install.user_options + [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
995 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
996 'old-and-unmanageable',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
997 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
998 'noop, present for eggless setuptools compat',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
999 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1000 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1001 'single-version-externally-managed',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1002 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1003 'noop, present for eggless setuptools compat',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1004 ),
32745
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
1005 ]
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
1006
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
1007 # 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
1008 single_version_externally_managed = True
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
1009
32670
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
1010 def get_sub_commands(self):
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
1011 # 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
1012 # 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
1013 # packaging.
33589
a0bfcd08f5fe setup: drop use of set literal so parsable on Python 2.6
Yuya Nishihara <yuya@tcha.org>
parents: 33588
diff changeset
1014 excl = set(['bdist_egg'])
32670
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
1015 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
1016
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1017
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1018 class hginstalllib(install_lib):
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1019 '''
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1020 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
1021 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
1022 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
1023 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
1024 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
1025
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1026 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
1027 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
1028 '''
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1029
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1030 def run(self):
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1031 realcopyfile = file_util.copy_file
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1032
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1033 def copyfileandsetmode(*args, **kwargs):
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1034 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
1035 dst, copied = realcopyfile(*args, **kwargs)
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1036 if copied:
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1037 st = os.stat(src)
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1038 # 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
1039 # has it)
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1040 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
1041 setmode = int('0755', 8)
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1042 else:
24941
9c1942635c1f setup: hide octal literals inside strings so they're portable (issue4554)
Augie Fackler <augie@google.com>
parents: 24214
diff changeset
1043 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
1044 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
1045 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
1046 os.chmod(dst, m)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1047
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1048 file_util.copy_file = copyfileandsetmode
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1049 try:
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1050 install_lib.run(self)
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1051 finally:
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1052 file_util.copy_file = realcopyfile
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
1053
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1054
12661
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1055 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
1056 '''
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1057 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
1058 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
1059 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
1060 '''
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1061
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1062 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
1063 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
1064
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1065 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
1066
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1067 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
1068 install_scripts.finalize_options(self)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1069 self.set_undefined_options('install', ('install_lib', '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
1070
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1071 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
1072 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
1073
27269
bdcbec65750b setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27268
diff changeset
1074 # 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
1075 # 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
1076 # 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
1077 # wheel archive looks like:
bdcbec65750b setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27268
diff changeset
1078 #
bdcbec65750b setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27268
diff changeset
1079 # 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
1080 # mercurial/__init__.py
bdcbec65750b setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27268
diff changeset
1081 #
bdcbec65750b setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27268
diff changeset
1082 # 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
1083 # 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
1084 # 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
1085 # 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
1086 # 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
1087 # 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
1088 # 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
1089 # 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
1090 # 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
1091 # 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
1092
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1093 if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1094 os.path.splitdrive(self.install_dir)[0]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1095 != os.path.splitdrive(self.install_lib)[0]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1096 ):
12661
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1097 # 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
1098 # 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
1099 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
1100 else:
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1101 common = os.path.commonprefix((self.install_dir, self.install_lib))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1102 rest = self.install_dir[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
1103 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
1104
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1105 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
1106
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1107 for outfile in self.outfiles:
28418
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
1108 with open(outfile, 'rb') as fp:
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
1109 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
1110
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1111 # skip binary files
27348
83a8219fb790 setup.py: use bytes literals
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27269
diff changeset
1112 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
1113 continue
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
1114
27269
bdcbec65750b setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27268
diff changeset
1115 # 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
1116 # 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
1117 # value.
bdcbec65750b setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27268
diff changeset
1118 if data.startswith(b'#!python'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1119 log.info(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1120 'not rewriting @LIBDIR@ in %s because install path '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1121 'not known' % outfile
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1122 )
27269
bdcbec65750b setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27268
diff changeset
1123 continue
bdcbec65750b setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27268
diff changeset
1124
27348
83a8219fb790 setup.py: use bytes literals
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27269
diff changeset
1125 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
1126 with open(outfile, 'wb') as fp:
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
1127 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
1128
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1129
42150
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1130 # virtualenv installs custom distutils/__init__.py and
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1131 # distutils/distutils.cfg files which essentially proxy back to the
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1132 # "real" distutils in the main Python install. The presence of this
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1133 # directory causes py2exe to pick up the "hacked" distutils package
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1134 # from the virtualenv and "import distutils" will fail from the py2exe
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1135 # build because the "real" distutils files can't be located.
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1136 #
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1137 # We work around this by monkeypatching the py2exe code finding Python
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1138 # modules to replace the found virtualenv distutils modules with the
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1139 # original versions via filesystem scanning. This is a bit hacky. But
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1140 # it allows us to use virtualenvs for py2exe packaging, which is more
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1141 # deterministic and reproducible.
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1142 #
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1143 # It's worth noting that the common StackOverflow suggestions for this
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1144 # problem involve copying the original distutils files into the
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1145 # virtualenv or into the staging directory after setup() is invoked.
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1146 # The former is very brittle and can easily break setup(). Our hacking
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1147 # of the found modules routine has a similar result as copying the files
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1148 # manually. But it makes fewer assumptions about how py2exe works and
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1149 # is less brittle.
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1150
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1151 # This only catches virtualenvs made with virtualenv (as opposed to
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1152 # venv, which is likely what Python 3 uses).
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1153 py2exehacked = py2exeloaded and getattr(sys, 'real_prefix', None) is not None
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1154
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1155 if py2exehacked:
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1156 from distutils.command.py2exe import py2exe as buildpy2exe
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1157 from py2exe.mf import Module as py2exemodule
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1158
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1159 class hgbuildpy2exe(buildpy2exe):
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1160 def find_needed_modules(self, mf, files, modules):
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1161 res = buildpy2exe.find_needed_modules(self, mf, files, modules)
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1162
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1163 # Replace virtualenv's distutils modules with the real ones.
42152
bd92dd3eff42 setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42150
diff changeset
1164 modules = {}
bd92dd3eff42 setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42150
diff changeset
1165 for k, v in res.modules.items():
bd92dd3eff42 setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42150
diff changeset
1166 if k != 'distutils' and not k.startswith('distutils.'):
bd92dd3eff42 setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42150
diff changeset
1167 modules[k] = v
bd92dd3eff42 setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42150
diff changeset
1168
bd92dd3eff42 setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42150
diff changeset
1169 res.modules = modules
42150
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1170
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1171 import opcode
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1172
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1173 distutilsreal = os.path.join(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1174 os.path.dirname(opcode.__file__), 'distutils'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1175 )
42150
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1176
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1177 for root, dirs, files in os.walk(distutilsreal):
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1178 for f in sorted(files):
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1179 if not f.endswith('.py'):
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1180 continue
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1181
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1182 full = os.path.join(root, f)
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1183
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1184 parents = ['distutils']
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1185
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1186 if root != distutilsreal:
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1187 rel = os.path.relpath(root, distutilsreal)
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1188 parents.extend(p for p in rel.split(os.sep))
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1189
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1190 modname = '%s.%s' % ('.'.join(parents), f[:-3])
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1191
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1192 if modname.startswith('distutils.tests.'):
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1193 continue
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1194
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1195 if modname.endswith('.__init__'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1196 modname = modname[: -len('.__init__')]
42150
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1197 path = os.path.dirname(full)
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1198 else:
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1199 path = None
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1200
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1201 res.modules[modname] = py2exemodule(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1202 modname, full, path=path
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1203 )
42150
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1204
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1205 if 'distutils' not in res.modules:
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1206 raise SystemExit('could not find distutils modules')
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1207
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1208 return res
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1209
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1210
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1211 cmdclass = {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1212 'build': hgbuild,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1213 'build_doc': hgbuilddoc,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1214 'build_mo': hgbuildmo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1215 'build_ext': hgbuildext,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1216 'build_py': hgbuildpy,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1217 'build_scripts': hgbuildscripts,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1218 'build_hgextindex': buildhgextindex,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1219 'install': hginstall,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1220 'install_lib': hginstalllib,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1221 'install_scripts': hginstallscripts,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1222 'build_hgexe': buildhgexe,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1223 }
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
1224
42150
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1225 if py2exehacked:
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1226 cmdclass['py2exe'] = hgbuildpy2exe
71d8b4d91616 setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42075
diff changeset
1227
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1228 packages = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1229 'mercurial',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1230 'mercurial.cext',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1231 'mercurial.cffi',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1232 'mercurial.hgweb',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1233 'mercurial.interfaces',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1234 'mercurial.pure',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1235 'mercurial.thirdparty',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1236 'mercurial.thirdparty.attr',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1237 'mercurial.thirdparty.zope',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1238 'mercurial.thirdparty.zope.interface',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1239 'mercurial.utils',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1240 'mercurial.revlogutils',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1241 'mercurial.testing',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1242 'hgext',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1243 'hgext.convert',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1244 'hgext.fsmonitor',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1245 'hgext.fastannotate',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1246 'hgext.fsmonitor.pywatchman',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1247 'hgext.highlight',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1248 'hgext.infinitepush',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1249 'hgext.largefiles',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1250 'hgext.lfs',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1251 'hgext.narrow',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1252 'hgext.remotefilelog',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1253 'hgext.zeroconf',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1254 'hgext3rd',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1255 'hgdemandimport',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1256 ]
39629
96bffce40f5b setup: exclude vendored futures package on Python 3
Yuya Nishihara <yuya@tcha.org>
parents: 39624
diff changeset
1257 if sys.version_info[0] == 2:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1258 packages.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1259 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1260 'mercurial.thirdparty.concurrent',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1261 'mercurial.thirdparty.concurrent.futures',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1262 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1263 )
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
1264
42054
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1265 if 'HG_PY2EXE_EXTRA_INSTALL_PACKAGES' in os.environ:
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1266 # py2exe can't cope with namespace packages very well, so we have to
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1267 # install any hgext3rd.* extensions that we want in the final py2exe
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1268 # image here. This is gross, but you gotta do what you gotta do.
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1269 packages.extend(os.environ['HG_PY2EXE_EXTRA_INSTALL_PACKAGES'].split(' '))
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1270
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1271 common_depends = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1272 'mercurial/bitmanipulation.h',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1273 'mercurial/compat.h',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1274 'mercurial/cext/util.h',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1275 ]
32251
c48583859e04 policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents: 32178
diff changeset
1276 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
1277
30418
ce9a3033c118 setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents: 30356
diff changeset
1278 osutil_cflags = []
25073
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1279 osutil_ldflags = []
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1280
31567
312e62640798 setup: detect statfs
Jun Wu <quark@fb.com>
parents: 31566
diff changeset
1281 # platform specific macros
31627
2243ba216f66 statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents: 31601
diff changeset
1282 for plat, func in [('bsd', 'setproctitle')]:
31567
312e62640798 setup: detect statfs
Jun Wu <quark@fb.com>
parents: 31566
diff changeset
1283 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
1284 osutil_cflags.append('-DHAVE_%s' % func.upper())
ce9a3033c118 setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents: 30356
diff changeset
1285
31601
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1286 for plat, macro, code in [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1287 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1288 'bsd|darwin',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1289 'BSD_STATFS',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1290 '''
31601
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1291 #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
1292 #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
1293 int main() { struct statfs s; return sizeof(s.f_fstypename); }
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1294 ''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1295 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1296 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1297 'linux',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1298 'LINUX_STATFS',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1299 '''
31627
2243ba216f66 statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents: 31601
diff changeset
1300 #include <linux/magic.h>
2243ba216f66 statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents: 31601
diff changeset
1301 #include <sys/vfs.h>
2243ba216f66 statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents: 31601
diff changeset
1302 int main() { struct statfs s; return sizeof(s.f_type); }
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1303 ''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1304 ),
31601
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1305 ]:
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1306 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
1307 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
1308
25073
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1309 if sys.platform == 'darwin':
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1310 osutil_ldflags += ['-framework', 'ApplicationServices']
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1311
36704
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1312 xdiff_srcs = [
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1313 'mercurial/thirdparty/xdiff/xdiffi.c',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1314 'mercurial/thirdparty/xdiff/xprepare.c',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1315 'mercurial/thirdparty/xdiff/xutils.c',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1316 ]
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1317
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1318 xdiff_headers = [
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1319 'mercurial/thirdparty/xdiff/xdiff.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1320 'mercurial/thirdparty/xdiff/xdiffi.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1321 'mercurial/thirdparty/xdiff/xinclude.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1322 'mercurial/thirdparty/xdiff/xmacros.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1323 'mercurial/thirdparty/xdiff/xprepare.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1324 'mercurial/thirdparty/xdiff/xtypes.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1325 'mercurial/thirdparty/xdiff/xutils.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1326 ]
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1327
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1328
40979
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1329 class RustCompilationError(CCompilerError):
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1330 """Exception class for Rust compilation errors."""
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1331
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1332
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1333 class RustExtension(Extension):
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1334 """Base classes for concrete Rust Extension classes.
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1335 """
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1336
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1337 rusttargetdir = os.path.join('rust', 'target', 'release')
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1338
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1339 def __init__(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1340 self, mpath, sources, rustlibname, subcrate, py3_features=None, **kw
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1341 ):
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1342 Extension.__init__(self, mpath, sources, **kw)
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1343 srcdir = self.rustsrcdir = os.path.join('rust', subcrate)
40998
4277e20cfec4 rust-cpython: build and support for Python3
Georges Racinet <gracinet@anybox.fr>
parents: 40993
diff changeset
1344 self.py3_features = py3_features
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1345
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1346 # adding Rust source and control files to depends so that the extension
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1347 # gets rebuilt if they've changed
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1348 self.depends.append(os.path.join(srcdir, 'Cargo.toml'))
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1349 cargo_lock = os.path.join(srcdir, 'Cargo.lock')
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1350 if os.path.exists(cargo_lock):
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1351 self.depends.append(cargo_lock)
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1352 for dirpath, subdir, fnames in os.walk(os.path.join(srcdir, 'src')):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1353 self.depends.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1354 os.path.join(dirpath, fname)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1355 for fname in fnames
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1356 if os.path.splitext(fname)[1] == '.rs'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1357 )
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1358
42473
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1359 @staticmethod
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1360 def rustdylibsuffix():
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1361 """Return the suffix for shared libraries produced by rustc.
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1362
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1363 See also: https://doc.rust-lang.org/reference/linkage.html
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1364 """
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1365 if sys.platform == 'darwin':
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1366 return '.dylib'
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1367 elif os.name == 'nt':
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1368 return '.dll'
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1369 else:
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1370 return '.so'
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1371
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1372 def rustbuild(self):
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1373 env = os.environ.copy()
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1374 if 'HGTEST_RESTOREENV' in env:
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1375 # Mercurial tests change HOME to a temporary directory,
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1376 # but, if installed with rustup, the Rust toolchain needs
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1377 # HOME to be correct (otherwise the 'no default toolchain'
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1378 # error message is issued and the build fails).
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1379 # This happens currently with test-hghave.t, which does
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1380 # invoke this build.
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1381
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1382 # Unix only fix (os.path.expanduser not really reliable if
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1383 # HOME is shadowed like this)
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1384 import pwd
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1385
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1386 env['HOME'] = pwd.getpwuid(os.getuid()).pw_dir
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1387
42475
85041e2b69c7 rust: switched to 'cargo rustc' in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42474
diff changeset
1388 cargocmd = ['cargo', 'rustc', '-vv', '--release']
40998
4277e20cfec4 rust-cpython: build and support for Python3
Georges Racinet <gracinet@anybox.fr>
parents: 40993
diff changeset
1389 if sys.version_info[0] == 3 and self.py3_features is not None:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1390 cargocmd.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1391 ('--features', self.py3_features, '--no-default-features')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1392 )
42475
85041e2b69c7 rust: switched to 'cargo rustc' in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42474
diff changeset
1393 cargocmd.append('--')
42474
8ee0fdf3b087 rust-cpython: fix build for MacOSX
Georges Racinet <georges.racinet@octobus.net>
parents: 42473
diff changeset
1394 if sys.platform == 'darwin':
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1395 cargocmd.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1396 ("-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1397 )
40979
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1398 try:
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1399 subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir)
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1400 except OSError as exc:
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1401 if exc.errno == errno.ENOENT:
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1402 raise RustCompilationError("Cargo not found")
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1403 elif exc.errno == errno.EACCES:
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1404 raise RustCompilationError(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1405 "Cargo found, but permisssion to execute it is denied"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1406 )
40979
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1407 else:
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1408 raise
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1409 except subprocess.CalledProcessError:
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1410 raise RustCompilationError(
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1411 "Cargo failed. Working directory: %r, "
42074
59b1bdf85b1a setup: fix a possible NameError on rust build
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents: 42065
diff changeset
1412 "command: %r, environment: %r"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1413 % (self.rustsrcdir, cargocmd, env)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1414 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1415
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1416
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1417 class RustEnhancedExtension(RustExtension):
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1418 """A C Extension, conditionally enhanced with Rust code.
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1419
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1420 If the HGRUSTEXT environment variable is set to something else
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1421 than 'cpython', the Rust sources get compiled and linked within the
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1422 C target shared library object.
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1423 """
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1424
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1425 def __init__(self, mpath, sources, rustlibname, subcrate, **kw):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1426 RustExtension.__init__(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1427 self, mpath, sources, rustlibname, subcrate, **kw
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1428 )
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1429 if hgrustext != 'direct-ffi':
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1430 return
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1431 self.extra_compile_args.append('-DWITH_RUST')
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1432 self.libraries.append(rustlibname)
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1433 self.library_dirs.append(self.rusttargetdir)
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1434
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
1435 def rustbuild(self):
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
1436 if hgrustext == 'direct-ffi':
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
1437 RustExtension.rustbuild(self)
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
1438
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1439
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1440 class RustStandaloneExtension(RustExtension):
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1441 def __init__(self, pydottedname, rustcrate, dylibname, **kw):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1442 RustExtension.__init__(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1443 self, pydottedname, [], dylibname, rustcrate, **kw
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1444 )
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1445 self.dylibname = dylibname
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1446
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1447 def build(self, target_dir):
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1448 self.rustbuild()
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1449 target = [target_dir]
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1450 target.extend(self.name.split('.'))
42473
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1451 target[-1] += DYLIB_SUFFIX
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1452 shutil.copy2(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1453 os.path.join(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1454 self.rusttargetdir, self.dylibname + self.rustdylibsuffix()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1455 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1456 os.path.join(*target),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1457 )
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1458
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1459
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
1460 extmodules = [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1461 Extension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1462 'mercurial.cext.base85',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1463 ['mercurial/cext/base85.c'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1464 include_dirs=common_include_dirs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1465 depends=common_depends,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1466 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1467 Extension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1468 'mercurial.cext.bdiff',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1469 ['mercurial/bdiff.c', 'mercurial/cext/bdiff.c'] + xdiff_srcs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1470 include_dirs=common_include_dirs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1471 depends=common_depends + ['mercurial/bdiff.h'] + xdiff_headers,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1472 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1473 Extension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1474 'mercurial.cext.mpatch',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1475 ['mercurial/mpatch.c', 'mercurial/cext/mpatch.c'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1476 include_dirs=common_include_dirs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1477 depends=common_depends,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1478 ),
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1479 RustEnhancedExtension(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1480 'mercurial.cext.parsers',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1481 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1482 'mercurial/cext/charencode.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1483 'mercurial/cext/dirs.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1484 'mercurial/cext/manifest.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1485 'mercurial/cext/parsers.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1486 'mercurial/cext/pathencode.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1487 'mercurial/cext/revlog.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1488 ],
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1489 'hgdirectffi',
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1490 'hg-direct-ffi',
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1491 include_dirs=common_include_dirs,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1492 depends=common_depends
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1493 + [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1494 'mercurial/cext/charencode.h',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1495 'mercurial/cext/revlog.h',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1496 'rust/hg-core/src/ancestors.rs',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1497 'rust/hg-core/src/lib.rs',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1498 ],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1499 ),
37182
922b3fae9c7d setup: register zope.interface packages and compile C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37133
diff changeset
1500 Extension(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1501 'mercurial.cext.osutil',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1502 ['mercurial/cext/osutil.c'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1503 include_dirs=common_include_dirs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1504 extra_compile_args=osutil_cflags,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1505 extra_link_args=osutil_ldflags,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1506 depends=common_depends,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1507 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1508 Extension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1509 'mercurial.thirdparty.zope.interface._zope_interface_coptimizations',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1510 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1511 'mercurial/thirdparty/zope/interface/_zope_interface_coptimizations.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1512 ],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1513 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1514 Extension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1515 'hgext.fsmonitor.pywatchman.bser', ['hgext/fsmonitor/pywatchman/bser.c']
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1516 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1517 RustStandaloneExtension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1518 'mercurial.rustext', 'hg-cpython', 'librusthg', py3_features='python3'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1519 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1520 ]
5396
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
1521
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1522
30445
788ea4ac4388 setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30418
diff changeset
1523 sys.path.insert(0, 'contrib/python-zstandard')
788ea4ac4388 setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30418
diff changeset
1524 import setup_zstd
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1525
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1526 extmodules.append(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1527 setup_zstd.get_c_extension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1528 name='mercurial.zstd', root=os.path.abspath(os.path.dirname(__file__))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1529 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1530 )
30445
788ea4ac4388 setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30418
diff changeset
1531
23677
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1532 try:
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1533 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
1534
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1535 # 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
1536 mingw32compilerclass = cygwinccompiler.Mingw32CCompiler
17121
d13f47c800fd setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents: 17061
diff changeset
1537
23677
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1538 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
1539 def __init__(self, *args, **kwargs):
33663
7686cbb0ba41 setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents: 33600
diff changeset
1540 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
1541 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
1542 try:
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1543 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
1544 except ValueError:
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1545 pass
17121
d13f47c800fd setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents: 17061
diff changeset
1546
23677
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1547 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
1548 except ImportError:
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1549 # 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
1550 # 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
1551 # DiskStation boxes
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1552 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
1553 pass
17121
d13f47c800fd setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents: 17061
diff changeset
1554
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1555
32802
9a4adc76c88a setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents: 32745
diff changeset
1556 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
1557 # 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
1558 # 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
1559 # effect.
9a4adc76c88a setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents: 32745
diff changeset
1560 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
1561
33663
7686cbb0ba41 setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents: 33600
diff changeset
1562 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
1563
9a4adc76c88a setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents: 32745
diff changeset
1564 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
1565 def initialize(self):
33663
7686cbb0ba41 setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents: 33600
diff changeset
1566 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
1567 # "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
1568 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
1569 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
1570
9a4adc76c88a setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents: 32745
diff changeset
1571 msvccompiler.MSVCCompiler = HackedMSVCCompiler
9a4adc76c88a setup: avoid linker warnings on Windows about multiple export specifications
Matt Harbison <matt_harbison@yahoo.com>
parents: 32745
diff changeset
1572
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1573 packagedata = {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1574 'mercurial': [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1575 'locale/*/LC_MESSAGES/hg.mo',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1576 'help/*.txt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1577 'help/internals/*.txt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1578 'default.d/*.rc',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1579 'dummycert.pem',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1580 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1581 }
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1582
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1583
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1584 def ordinarypath(p):
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1585 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
1586
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1587
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
1588 for root in ('templates',):
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1589 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
1590 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
1591 dirs[:] = filter(ordinarypath, dirs)
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1592 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
1593 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
1594 packagedata['mercurial'].append(f)
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1595
7648
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
1596 datafiles = []
31325
70bc35df3e54 setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents: 31317
diff changeset
1597
70bc35df3e54 setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents: 31317
diff changeset
1598 # 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
1599 # 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
1600 # 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
1601 # when operated on.
70bc35df3e54 setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents: 31317
diff changeset
1602 assert isinstance(version, bytes)
70bc35df3e54 setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents: 31317
diff changeset
1603 setupversion = version.decode('ascii')
70bc35df3e54 setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents: 31317
diff changeset
1604
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1605 extra = {}
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1606
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1607 py2exepackages = [
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1608 'hgdemandimport',
41923
5d9fdc9b0178 setup: include hgext3rd package in py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41922
diff changeset
1609 'hgext3rd',
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1610 'hgext',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1611 'email',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1612 # implicitly imported per module policy
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1613 # (cffi wouldn't be used as a frozen exe)
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1614 'mercurial.cext',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1615 #'mercurial.cffi',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1616 'mercurial.pure',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1617 ]
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1618
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1619 py2exeexcludes = []
41959
e5ac701e5b7c setup: exclude crypt32.dll in py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41958
diff changeset
1620 py2exedllexcludes = ['crypt32.dll']
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1621
33600
47829b89c8c6 setup: silence warning of unknown option python_requires on distutils
Yuya Nishihara <yuya@tcha.org>
parents: 33599
diff changeset
1622 if issetuptools:
47829b89c8c6 setup: silence warning of unknown option python_requires on distutils
Yuya Nishihara <yuya@tcha.org>
parents: 33599
diff changeset
1623 extra['python_requires'] = supportedpy
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1624
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1625 if py2exeloaded:
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1626 extra['console'] = [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1627 {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1628 'script': 'hg',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1629 'copyright': 'Copyright (C) 2005-2019 Matt Mackall and others',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1630 'product_version': version,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1631 }
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1632 ]
41922
ac32e04e887f setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41921
diff changeset
1633 # Sub command of 'build' because 'py2exe' does not handle sub_commands.
ac32e04e887f setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41921
diff changeset
1634 # Need to override hgbuild because it has a private copy of
ac32e04e887f setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41921
diff changeset
1635 # build.sub_commands.
ac32e04e887f setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41921
diff changeset
1636 hgbuild.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
1637 # 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
1638 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
1639
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1640 # We allow some configuration to be supplemented via environment
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1641 # variables. This is better than setup.cfg files because it allows
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1642 # supplementing configs instead of replacing them.
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1643 extrapackages = os.environ.get('HG_PY2EXE_EXTRA_PACKAGES')
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1644 if extrapackages:
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1645 py2exepackages.extend(extrapackages.split(' '))
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1646
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1647 excludes = os.environ.get('HG_PY2EXE_EXTRA_EXCLUDES')
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1648 if excludes:
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1649 py2exeexcludes.extend(excludes.split(' '))
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1650
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1651 dllexcludes = os.environ.get('HG_PY2EXE_EXTRA_DLL_EXCLUDES')
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1652 if dllexcludes:
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1653 py2exedllexcludes.extend(dllexcludes.split(' '))
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1654
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1655 if os.name == 'nt':
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1656 # 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
1657 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535
40383
a9e303dcd1e1 py3: stringify setupversion on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 40273
diff changeset
1658 setupversion = setupversion.split(r'+', 1)[0]
7648
02e358a3a8a7 i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents: 7647
diff changeset
1659
13583
e42d18538e1d fix compiling of extensions for OS X and XCode 4.0
Alexander Solovyov <alexander@solovyov.net>
parents: 13400
diff changeset
1660 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
1661 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
1662 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
1663 version = version[0]
25043
facaceeb85ac setup: decode xcode version number on python3
Augie Fackler <augie@google.com>
parents: 25009
diff changeset
1664 if sys.version_info[0] == 3:
facaceeb85ac setup: decode xcode version number on python3
Augie Fackler <augie@google.com>
parents: 25009
diff changeset
1665 version = version.decode('utf-8')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1666 xcode4 = version.startswith('Xcode') and StrictVersion(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1667 version.split()[1]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1668 ) >= StrictVersion('4.0')
21558
8b482d49563b setup: make Xcode 5.1 check less specific
Matt Mackall <mpm@selenic.com>
parents: 21229
diff changeset
1669 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
1670 else:
82ce91a9fd94 setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents: 15527
diff changeset
1671 # 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
1672 # 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
1673 # 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
1674 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
1675 xcode51 = False
16187
82ce91a9fd94 setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents: 15527
diff changeset
1676
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
1677 # 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
1678 # distutils.sysconfig
16187
82ce91a9fd94 setup: handle output from Apple's Xcode 4.3 better (issue3277)
Greg Ward <greg@gerg.ca>
parents: 15527
diff changeset
1679 if xcode4:
14324
d3a49a52f117 Hardcoding ARCHFLAGS breaks the build against fink's python
Brendan Cully <brendan@kublai.com>
parents: 14295
diff changeset
1680 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
1681
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
1682 # 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
1683 # -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
1684 # 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
1685 # 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
1686 # 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
1687 # 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
1688 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
1689 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
1690 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
1691 os.environ['CFLAGS'] = (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1692 os.environ.get('CFLAGS', '') + ' -Qunused-arguments'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1693 )
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
1694
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1695 setup(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1696 name='mercurial',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1697 version=setupversion,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1698 author='Matt Mackall and many others',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1699 author_email='mercurial@mercurial-scm.org',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1700 url='https://mercurial-scm.org/',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1701 download_url='https://mercurial-scm.org/release/',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1702 description=(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1703 'Fast scalable distributed SCM (revision control, version '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1704 'control) system'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1705 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1706 long_description=(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1707 'Mercurial is a distributed SCM tool written in Python.'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1708 ' It is used by a number of large projects that require'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1709 ' fast, reliable distributed revision control, such as '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1710 'Mozilla.'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1711 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1712 license='GNU GPLv2 or any later version',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1713 classifiers=[
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1714 'Development Status :: 6 - Mature',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1715 'Environment :: Console',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1716 'Intended Audience :: Developers',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1717 'Intended Audience :: System Administrators',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1718 'License :: OSI Approved :: GNU General Public License (GPL)',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1719 'Natural Language :: Danish',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1720 'Natural Language :: English',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1721 'Natural Language :: German',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1722 'Natural Language :: Italian',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1723 'Natural Language :: Japanese',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1724 'Natural Language :: Portuguese (Brazilian)',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1725 'Operating System :: Microsoft :: Windows',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1726 'Operating System :: OS Independent',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1727 'Operating System :: POSIX',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1728 'Programming Language :: C',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1729 'Programming Language :: Python',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1730 'Topic :: Software Development :: Version Control',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1731 ],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1732 scripts=scripts,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1733 packages=packages,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1734 ext_modules=extmodules,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1735 data_files=datafiles,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1736 package_data=packagedata,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1737 cmdclass=cmdclass,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1738 distclass=hgdist,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1739 options={
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1740 'py2exe': {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1741 'bundle_files': 3,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1742 'dll_excludes': py2exedllexcludes,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1743 'excludes': py2exeexcludes,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1744 'packages': py2exepackages,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1745 },
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1746 'bdist_mpkg': {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1747 'zipdist': False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1748 'license': 'COPYING',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1749 'readme': 'contrib/packaging/macosx/Readme.html',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1750 'welcome': 'contrib/packaging/macosx/Welcome.html',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1751 },
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1752 },
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1753 **extra
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1754 )