author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Wed, 06 Nov 2024 16:32:15 +0100 | |
branch | stable |
changeset 52198 | 2c4283c9fa93 |
parent 52003 | d4b275587847 |
child 52218 | 9048a0d782e1 |
permissions | -rw-r--r-- |
575 | 1 |
# |
2 |
# This is the mercurial setup script. |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
3 |
# |
4816
c10d3bc05a8d
setup.py not executable: change instructions at beginning of file
Christian Ebert <blacktrash@gmx.net>
parents:
4628
diff
changeset
|
4 |
# 'python setup.py install', or |
c10d3bc05a8d
setup.py not executable: change instructions at beginning of file
Christian Ebert <blacktrash@gmx.net>
parents:
4628
diff
changeset
|
5 |
# 'python setup.py --help' for more options |
33591
ee11d18fcd3c
setup: fix mistake that prevented Python 3 from being excluded
Augie Fackler <augie@google.com>
parents:
33589
diff
changeset
|
6 |
import os |
ee11d18fcd3c
setup: fix mistake that prevented Python 3 from being excluded
Augie Fackler <augie@google.com>
parents:
33589
diff
changeset
|
7 |
|
43349
c3e10f705a6c
setup: allow py3 install without env vars
Ian Moody <moz-ian@perix.co.uk>
parents:
43076
diff
changeset
|
8 |
supportedpy = ','.join( |
c3e10f705a6c
setup: allow py3 install without env vars
Ian Moody <moz-ian@perix.co.uk>
parents:
43076
diff
changeset
|
9 |
[ |
51836
905bc9d0a149
python-compat: drop support for Python3.6 and 3.7
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51834
diff
changeset
|
10 |
'>=3.8.0', |
43349
c3e10f705a6c
setup: allow py3 install without env vars
Ian Moody <moz-ian@perix.co.uk>
parents:
43076
diff
changeset
|
11 |
] |
c3e10f705a6c
setup: allow py3 install without env vars
Ian Moody <moz-ian@perix.co.uk>
parents:
43076
diff
changeset
|
12 |
) |
33587
e0bbe32d8b55
setup: explicitly declare supported Python versions
Augie Fackler <augie@google.com>
parents:
33119
diff
changeset
|
13 |
|
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
14 |
import sys, platform |
42457
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
15 |
import sysconfig |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
16 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
17 |
|
48826
3ce8001fd768
setup: remove more Python 2 support code
Augie Fackler <augie@google.com>
parents:
48825
diff
changeset
|
18 |
def sysstr(s): |
3ce8001fd768
setup: remove more Python 2 support code
Augie Fackler <augie@google.com>
parents:
48825
diff
changeset
|
19 |
return s.decode('latin-1') |
11532
f3732ab1149f
setup.py: Adjustments to make setup.py run in py3k.
Renato Cunha <renatoc@gmail.com>
parents:
11468
diff
changeset
|
20 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
21 |
|
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
22 |
def eprint(*args, **kwargs): |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
23 |
kwargs['file'] = sys.stderr |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
24 |
print(*args, **kwargs) |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
25 |
|
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
26 |
|
44874
4c53c12b92d5
setup: require a Python version with modern SSL features
Manuel Jacob <me@manueljacob.de>
parents:
44852
diff
changeset
|
27 |
import ssl |
4c53c12b92d5
setup: require a Python version with modern SSL features
Manuel Jacob <me@manueljacob.de>
parents:
44852
diff
changeset
|
28 |
|
44893
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
29 |
# ssl.HAS_TLSv1* are preferred to check support but they were added in Python |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
30 |
# 3.7. Prior to CPython commit 6e8cda91d92da72800d891b2fc2073ecbc134d98 |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
31 |
# (backported to the 3.7 branch), ssl.PROTOCOL_TLSv1_1 / ssl.PROTOCOL_TLSv1_2 |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
32 |
# were defined only if compiled against a OpenSSL version with TLS 1.1 / 1.2 |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
33 |
# support. At the mentioned commit, they were unconditionally defined. |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
34 |
_notset = object() |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
35 |
has_tlsv1_1 = getattr(ssl, 'HAS_TLSv1_1', _notset) |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
36 |
if has_tlsv1_1 is _notset: |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
37 |
has_tlsv1_1 = getattr(ssl, 'PROTOCOL_TLSv1_1', _notset) is not _notset |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
38 |
has_tlsv1_2 = getattr(ssl, 'HAS_TLSv1_2', _notset) |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
39 |
if has_tlsv1_2 is _notset: |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
40 |
has_tlsv1_2 = getattr(ssl, 'PROTOCOL_TLSv1_2', _notset) is not _notset |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
41 |
if not (has_tlsv1_1 or has_tlsv1_2): |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
42 |
error = """ |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
43 |
The `ssl` module does not advertise support for TLS 1.1 or TLS 1.2. |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
44 |
Please make sure that your Python installation was compiled against an OpenSSL |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
45 |
version enabling these features (likely this requires the OpenSSL version to |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
46 |
be at least 1.0.1). |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
47 |
""" |
48827
1371c18e467d
setup: remove printf trampoline
Augie Fackler <augie@google.com>
parents:
48826
diff
changeset
|
48 |
print(error, file=sys.stderr) |
44893
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
49 |
sys.exit(1) |
95c832849955
setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents:
44874
diff
changeset
|
50 |
|
48830
3491c450dcae
setup: remove Python 2 support code for determining dylib suffix
Augie Fackler <augie@google.com>
parents:
48829
diff
changeset
|
51 |
DYLIB_SUFFIX = sysconfig.get_config_vars()['EXT_SUFFIX'] |
42457
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
52 |
|
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
53 |
# Solaris Python packaging brain damage |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
54 |
try: |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
55 |
import hashlib |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
56 |
|
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
57 |
sha = hashlib.sha1() |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
58 |
except ImportError: |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
59 |
try: |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
60 |
import sha |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
61 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
62 |
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
|
63 |
except ImportError: |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
64 |
raise SystemExit( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
65 |
"Couldn't import standard hashlib (incomplete Python install)." |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
66 |
) |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
67 |
|
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
68 |
try: |
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
69 |
import zlib |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
70 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
71 |
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
|
72 |
except ImportError: |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
73 |
raise SystemExit( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
74 |
"Couldn't import standard zlib (incomplete Python install)." |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
75 |
) |
7558
dc211ad8d681
setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents:
7081
diff
changeset
|
76 |
|
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
77 |
# 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
|
78 |
isironpython = False |
10761
16a13fdb4b36
setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10521
diff
changeset
|
79 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
80 |
isironpython = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
81 |
platform.python_implementation().lower().find("ironpython") != -1 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
82 |
) |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
83 |
except AttributeError: |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
84 |
pass |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
85 |
|
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
86 |
if isironpython: |
15492
36f076d03b34
setup: make script executable with python3
Simon Heimberg <simohe@besonet.ch>
parents:
15460
diff
changeset
|
87 |
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
|
88 |
else: |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
89 |
try: |
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
90 |
import bz2 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
91 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
92 |
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
|
93 |
except ImportError: |
14295
bb7e3b3e6e11
setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14243
diff
changeset
|
94 |
raise SystemExit( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
95 |
"Couldn't import standard bz2 (incomplete Python install)." |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
96 |
) |
10761
16a13fdb4b36
setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10521
diff
changeset
|
97 |
|
24192
390410a6545d
setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents:
24191
diff
changeset
|
98 |
ispypy = "PyPy" in sys.version |
390410a6545d
setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents:
24191
diff
changeset
|
99 |
|
29020
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
100 |
import ctypes |
33591
ee11d18fcd3c
setup: fix mistake that prevented Python 3 from being excluded
Augie Fackler <augie@google.com>
parents:
33589
diff
changeset
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
import tempfile |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
105 |
|
31289
718a57e95a89
setup: use setuptools on Windows (issue5400)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30907
diff
changeset
|
106 |
# 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:
30907
diff
changeset
|
107 |
# 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:
30907
diff
changeset
|
108 |
# we don't have issues. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
109 |
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
|
110 |
if issetuptools: |
26600
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
111 |
from setuptools import setup |
e8497889edab
setup: import setup from setuptools if FORCE_SETUPTOOLS is set
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
26421
diff
changeset
|
112 |
else: |
50733
b1ac55606eb7
setup: fall back to setuptools setup if distutils isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
50643
diff
changeset
|
113 |
try: |
b1ac55606eb7
setup: fall back to setuptools setup if distutils isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
50643
diff
changeset
|
114 |
from distutils.core import setup |
b1ac55606eb7
setup: fall back to setuptools setup if distutils isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
50643
diff
changeset
|
115 |
except ModuleNotFoundError: |
b1ac55606eb7
setup: fall back to setuptools setup if distutils isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
50643
diff
changeset
|
116 |
from setuptools import setup |
30408
ce9a3033c118
setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents:
30346
diff
changeset
|
117 |
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
|
118 |
from distutils.core import Command, Extension |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
119 |
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
|
120 |
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
|
121 |
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
|
122 |
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
|
123 |
from distutils.command.build_scripts import build_scripts |
32647
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32506
diff
changeset
|
124 |
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
|
125 |
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
|
126 |
from distutils.command.install_scripts import install_scripts |
46233
172b294b6d65
setup: don't import distutils prior to checking FORCE_SETUPTOOLS
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
46136
diff
changeset
|
127 |
from distutils import log |
51849
4dc1fc2b2f3a
setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents:
51848
diff
changeset
|
128 |
from distutils.spawn import spawn |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
129 |
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
|
130 |
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
|
131 |
CCompilerError, |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
132 |
DistutilsError, |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
133 |
DistutilsExecError, |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
134 |
) |
49879
dd804d83822c
setup: drop legacy osx compiler tuning to enable universal builds
Matt Harbison <matt_harbison@yahoo.com>
parents:
49845
diff
changeset
|
135 |
from distutils.sysconfig import get_python_inc |
40446
b6bc2293cdf3
setup: explain to distutils how we write rc versions
"Paul Morelle <paul.morelle@octobus.net"
parents:
40397
diff
changeset
|
136 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
137 |
|
35229
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
138 |
def write_if_changed(path, content): |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
139 |
"""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:
35103
diff
changeset
|
140 |
if os.path.exists(path): |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
141 |
with open(path, 'rb') as fh: |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
142 |
current = fh.read() |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
143 |
else: |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
144 |
current = b'' |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
145 |
|
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
146 |
if current != content: |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
147 |
with open(path, 'wb') as fh: |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
148 |
fh.write(content) |
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
149 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
150 |
|
6513
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
151 |
scripts = ['hg'] |
66e87c11447d
Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents:
6389
diff
changeset
|
152 |
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
|
153 |
# 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
|
154 |
scripts.append('contrib/win32/hg.bat') |
3893 | 155 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
156 |
|
31559
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31316
diff
changeset
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
try: |
31559
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31316
diff
changeset
|
161 |
fname = os.path.join(tmpdir, 'testcomp.c') |
25089
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
162 |
f = open(fname, 'w') |
31559
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31316
diff
changeset
|
163 |
f.write(code) |
25089
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
164 |
f.close() |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
165 |
# 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
|
166 |
# from the compiler. |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
167 |
# 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
|
168 |
# for a function on Windows. |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
169 |
devnull = open('/dev/null', 'w') |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
170 |
oldstderr = os.dup(sys.stderr.fileno()) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
171 |
os.dup2(devnull.fileno(), sys.stderr.fileno()) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
172 |
objects = cc.compile([fname], output_dir=tmpdir) |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
173 |
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
|
174 |
return True |
25089
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
175 |
except Exception: |
c6427cd45760
setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
25074
diff
changeset
|
176 |
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
|
177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
184 |
|
31559
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31316
diff
changeset
|
185 |
# simplified version of distutils.ccompiler.CCompiler.has_function |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31316
diff
changeset
|
186 |
# that actually removes its temporary files. |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31316
diff
changeset
|
187 |
def hasfunction(cc, funcname): |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31316
diff
changeset
|
188 |
code = 'int main(void) { %s(); }\n' % funcname |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31316
diff
changeset
|
189 |
return cancompile(cc, code) |
9639ff4a93ae
setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents:
31316
diff
changeset
|
190 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
191 |
|
31560
5a0460219649
setup: add a function to test header files
Jun Wu <quark@fb.com>
parents:
31559
diff
changeset
|
192 |
def hasheader(cc, headername): |
5a0460219649
setup: add a function to test header files
Jun Wu <quark@fb.com>
parents:
31559
diff
changeset
|
193 |
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:
31559
diff
changeset
|
194 |
return cancompile(cc, code) |
5a0460219649
setup: add a function to test header files
Jun Wu <quark@fb.com>
parents:
31559
diff
changeset
|
195 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
196 |
|
1283
f5faab34f32e
Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents:
575
diff
changeset
|
197 |
# py2exe needs to be installed to work |
f5faab34f32e
Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents:
575
diff
changeset
|
198 |
try: |
1294
372971e1c40d
Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1284
diff
changeset
|
199 |
import py2exe |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
200 |
|
49073
97f2554cb647
setup: fix the py2exe logic to work with py3
Matt Harbison <matt_harbison@yahoo.com>
parents:
49038
diff
changeset
|
201 |
py2exe.patch_distutils() |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
202 |
py2exeloaded = True |
15527
9926aab3d0b5
setup: fix py2exe generation broken by c3a6ec304055 (issue3116)
Pascal Quantin <pascal.quantin@gmail.com>
parents:
15523
diff
changeset
|
203 |
# 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
|
204 |
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
|
205 |
except ImportError: |
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
206 |
py2exeloaded = False |
1283
f5faab34f32e
Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents:
575
diff
changeset
|
207 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
208 |
|
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
209 |
def runcmd(cmd, env, cwd=None): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
210 |
p = subprocess.Popen( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
211 |
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
|
212 |
) |
32886
19b0fd4b5570
plan9: drop py26 hacks
Matt Harbison <matt_harbison@yahoo.com>
parents:
32782
diff
changeset
|
213 |
out, err = p.communicate() |
33111
87ee783f7299
setup: update runcmd() to also return the exit status
Adam Simpkins <simpkins@fb.com>
parents:
33110
diff
changeset
|
214 |
return p.returncode, out, err |
13636
4bfff063aed6
setup: fix mac build broken by e42d18538e1d
Jon M. Dugan <jdugan@x1024.net>
parents:
13594
diff
changeset
|
215 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
216 |
|
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48850
diff
changeset
|
217 |
class hgcommand: |
33114
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
218 |
def __init__(self, cmd, env): |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
219 |
self.cmd = cmd |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
220 |
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
|
221 |
|
51160
3c5b66d03c37
setup: make debug simpler by adding a `__repr__` to `hgcommand`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50987
diff
changeset
|
222 |
def __repr__(self): |
3c5b66d03c37
setup: make debug simpler by adding a `__repr__` to `hgcommand`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50987
diff
changeset
|
223 |
return f"<hgcommand cmd={self.cmd} env={self.env}>" |
3c5b66d03c37
setup: make debug simpler by adding a `__repr__` to `hgcommand`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50987
diff
changeset
|
224 |
|
33113
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33112
diff
changeset
|
225 |
def run(self, args): |
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33112
diff
changeset
|
226 |
cmd = self.cmd + args |
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33112
diff
changeset
|
227 |
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
|
228 |
err = filterhgerr(err) |
49971
ac93876ea2df
setup: treat error output and non-zero return code differently
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49970
diff
changeset
|
229 |
if err: |
48827
1371c18e467d
setup: remove printf trampoline
Augie Fackler <augie@google.com>
parents:
48826
diff
changeset
|
230 |
print("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) |
1371c18e467d
setup: remove printf trampoline
Augie Fackler <augie@google.com>
parents:
48826
diff
changeset
|
231 |
print(err, file=sys.stderr) |
49971
ac93876ea2df
setup: treat error output and non-zero return code differently
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49970
diff
changeset
|
232 |
if returncode != 0: |
51559
ee132657647d
setup: display return code information about failed `hg` call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51161
diff
changeset
|
233 |
print( |
ee132657647d
setup: display return code information about failed `hg` call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51161
diff
changeset
|
234 |
"non zero-return '%s': %d" % (' '.join(cmd), returncode), |
ee132657647d
setup: display return code information about failed `hg` call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51161
diff
changeset
|
235 |
file=sys.stderr, |
ee132657647d
setup: display return code information about failed `hg` call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51161
diff
changeset
|
236 |
) |
44603
bda050bc9987
py3: make setup.py's hgcommand() consistently return bytes
Martin von Zweigbergk <martinvonz@google.com>
parents:
44378
diff
changeset
|
237 |
return b'' |
33113
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33112
diff
changeset
|
238 |
return out |
8548
3ccbe42ff72f
setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
8547
diff
changeset
|
239 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
240 |
|
33598
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
241 |
def filterhgerr(err): |
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
242 |
# 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
|
243 |
# 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
|
244 |
# 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
|
245 |
# 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
|
246 |
# 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
|
247 |
err = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
248 |
e |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
249 |
for e in err.splitlines() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
250 |
if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
251 |
not e.startswith(b'not trusting file') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
252 |
and not e.startswith(b'warning: Not importing') |
51631
bf1d26bd5b6a
obsolete: quote the feature name
Joerg Sonnenberger <joerg@bec.de>
parents:
51559
diff
changeset
|
253 |
and not ( |
bf1d26bd5b6a
obsolete: quote the feature name
Joerg Sonnenberger <joerg@bec.de>
parents:
51559
diff
changeset
|
254 |
e.startswith(b'obsolete feature not enabled') |
bf1d26bd5b6a
obsolete: quote the feature name
Joerg Sonnenberger <joerg@bec.de>
parents:
51559
diff
changeset
|
255 |
or e.startswith(b'"obsolete" feature not enabled') |
bf1d26bd5b6a
obsolete: quote the feature name
Joerg Sonnenberger <joerg@bec.de>
parents:
51559
diff
changeset
|
256 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
257 |
and not e.startswith(b'*** failed to import extension') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
258 |
and not e.startswith(b'devel-warn:') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
259 |
and not ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
260 |
e.startswith(b'(third party extension') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
261 |
and e.endswith(b'or newer of Mercurial; disabling)') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
262 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
263 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
264 |
] |
33598
f30714a55523
setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents:
33591
diff
changeset
|
265 |
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
|
266 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
267 |
|
33114
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
268 |
def findhg(): |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
269 |
"""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:
33113
diff
changeset
|
270 |
repository contents. |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
271 |
|
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
272 |
Returns an hgcommand object.""" |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
273 |
# 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:
33113
diff
changeset
|
274 |
# 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:
33113
diff
changeset
|
275 |
# |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
276 |
# 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:
33113
diff
changeset
|
277 |
# 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:
33113
diff
changeset
|
278 |
hgenv = os.environ.copy() |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
279 |
# 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:
33113
diff
changeset
|
280 |
# 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:
33113
diff
changeset
|
281 |
hgenv['HGPLAIN'] = '1' |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
282 |
hgenv['LANGUAGE'] = 'C' |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
283 |
hgcmd = ['hg'] |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
284 |
# Run a simple "hg log" command just to see if using hg from the user's |
40980
f6987f654356
setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
40967
diff
changeset
|
285 |
# 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:
40967
diff
changeset
|
286 |
# 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:
40967
diff
changeset
|
287 |
# python invocation of local hg, where pythonXY.dll can always be found. |
33114
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
288 |
check_cmd = ['log', '-r.', '-Ttest'] |
50930
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
289 |
attempts = [] |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
290 |
|
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
291 |
def attempt(cmd, env): |
40980
f6987f654356
setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
40967
diff
changeset
|
292 |
try: |
f6987f654356
setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
40967
diff
changeset
|
293 |
retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) |
50930
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
294 |
res = (True, retcode, out, err) |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
295 |
if retcode == 0 and not filterhgerr(err): |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
296 |
return True |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
297 |
except EnvironmentError as e: |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
298 |
res = (False, e) |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
299 |
attempts.append((cmd, res)) |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
300 |
return False |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
301 |
|
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
302 |
if os.name != 'nt' or not os.path.exists("hg.exe"): |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
303 |
if attempt(hgcmd + check_cmd, hgenv): |
40980
f6987f654356
setup: avoid attempting to invoke the system-wide hg.exe on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
40967
diff
changeset
|
304 |
return hgcommand(hgcmd, hgenv) |
33114
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
305 |
|
51161
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
306 |
# Fall back to trying the local hg installation (pure python) |
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
307 |
repo_hg = os.path.join(os.path.dirname(__file__), 'hg') |
33114
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
308 |
hgenv = localhgenv() |
51161
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
309 |
hgcmd = [sys.executable, repo_hg] |
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
310 |
if attempt(hgcmd + check_cmd, hgenv): |
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
311 |
return hgcommand(hgcmd, hgenv) |
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
312 |
# Fall back to trying the local hg installation (whatever we can) |
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
313 |
hgenv = localhgenv(pure_python=False) |
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
314 |
hgcmd = [sys.executable, repo_hg] |
50930
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
315 |
if attempt(hgcmd + check_cmd, hgenv): |
33114
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
316 |
return hgcommand(hgcmd, hgenv) |
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
317 |
|
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
318 |
eprint("/!\\") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
319 |
eprint(r"/!\ Unable to find a working hg binary") |
50930
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
320 |
eprint(r"/!\ Version cannot be extracted from the repository") |
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
321 |
eprint(r"/!\ Re-run the setup once a first version is built") |
50930
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
322 |
eprint(r"/!\ Attempts:") |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
323 |
for i, e in enumerate(attempts): |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
324 |
eprint(r"/!\ attempt #%d:" % (i)) |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
325 |
eprint(r"/!\ cmd: ", e[0]) |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
326 |
res = e[1] |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
327 |
if res[0]: |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
328 |
eprint(r"/!\ return code:", res[1]) |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
329 |
eprint("/!\\ std output:\n%s" % (res[2].decode()), end="") |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
330 |
eprint("/!\\ std error:\n%s" % (res[3].decode()), end="") |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
331 |
else: |
5dc7e1907e48
setup: make the error "Unable to find a working hg binary" more informative
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50733
diff
changeset
|
332 |
eprint(r"/!\ exception: ", res[1]) |
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
333 |
return None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
334 |
|
33114
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
335 |
|
51161
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
336 |
def localhgenv(pure_python=True): |
33114
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
337 |
"""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:
33113
diff
changeset
|
338 |
mercurial from the local repository.""" |
33112
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33111
diff
changeset
|
339 |
# 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:
33111
diff
changeset
|
340 |
# 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
|
341 |
env = { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
342 |
'HGRCPATH': '', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
343 |
'LANGUAGE': 'C', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
344 |
'PATH': '', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
345 |
} # make pypi modules that use os.environ['PATH'] happy |
51161
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
346 |
if pure_python: |
f816ca29a285
setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51160
diff
changeset
|
347 |
env['HGMODULEPOLICY'] = 'py' |
33112
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33111
diff
changeset
|
348 |
if 'LD_LIBRARY_PATH' in os.environ: |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33111
diff
changeset
|
349 |
env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33111
diff
changeset
|
350 |
if 'SystemRoot' in os.environ: |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33111
diff
changeset
|
351 |
# 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:
33111
diff
changeset
|
352 |
# https://bugs.python.org/issue13524#msg148850 |
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33111
diff
changeset
|
353 |
env['SystemRoot'] = os.environ['SystemRoot'] |
33117 | 354 |
return env |
33112
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33111
diff
changeset
|
355 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
356 |
|
33112
155d760da7b2
setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents:
33111
diff
changeset
|
357 |
version = '' |
15367
b357a972d6cd
setup: set env global earlier (3073)
Matt Mackall <mpm@selenic.com>
parents:
15215
diff
changeset
|
358 |
|
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
359 |
|
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
360 |
def _try_get_version(): |
33114
8b20338b989e
setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents:
33113
diff
changeset
|
361 |
hg = findhg() |
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
362 |
if hg is None: |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
363 |
return '' |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
364 |
hgid = None |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
365 |
numerictags = [] |
33113
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33112
diff
changeset
|
366 |
cmd = ['log', '-r', '.', '--template', '{tags}\n'] |
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
367 |
pieces = sysstr(hg.run(cmd)).split() |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
368 |
numerictags = [t for t in pieces if t[0:1].isdigit()] |
35246
d73ccc63b8f9
setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
35229
diff
changeset
|
369 |
hgid = sysstr(hg.run(['id', '-i'])).strip() |
50168
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
370 |
if hgid.count('+') == 2: |
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
371 |
hgid = hgid.replace("+", ".", 1) |
33110
6fdc1518983e
setup: fail if we cannot determine the version number
Adam Simpkins <simpkins@fb.com>
parents:
33103
diff
changeset
|
372 |
if not hgid: |
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
373 |
eprint("/!\\") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
374 |
eprint(r"/!\ Unable to determine hg version from local repository") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
375 |
eprint(r"/!\ Failed to retrieve current revision tags") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
376 |
return '' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
377 |
if numerictags: # tag(s) found |
17709
b7fff47bb128
setup: calculate version more correctly
Bryan O'Sullivan <bryano@fb.com>
parents:
17606
diff
changeset
|
378 |
version = numerictags[-1] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
379 |
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
|
380 |
version += '+' |
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
381 |
else: # no tag found on the checked out revision |
50168
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
382 |
ltagcmd = ['log', '--rev', 'wdir()', '--template', '{latesttag}'] |
35246
d73ccc63b8f9
setup: convert version strings to unicode on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
35229
diff
changeset
|
383 |
ltag = sysstr(hg.run(ltagcmd)) |
49970
8d390a13474d
setup: make the version computation process more resistant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49830
diff
changeset
|
384 |
if not ltag: |
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
385 |
eprint("/!\\") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
386 |
eprint(r"/!\ Unable to determine hg version from local repository") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
387 |
eprint( |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
388 |
r"/!\ Failed to retrieve current revision distance to lated tag" |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
389 |
) |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
390 |
return '' |
50168
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
391 |
changessincecmd = [ |
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
392 |
'log', |
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
393 |
'-T', |
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
394 |
'x\n', |
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
395 |
'-r', |
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
396 |
"only(parents(),'%s')" % ltag, |
593f5e4076ff
setup: support building from an ongoing merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50092
diff
changeset
|
397 |
] |
33113
fc290a39590d
setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents:
33112
diff
changeset
|
398 |
changessince = len(hg.run(changessincecmd).splitlines()) |
46512
866eb4d6bd9f
build: fake PEP440 versions
Joerg Sonnenberger <joerg@bec.de>
parents:
46414
diff
changeset
|
399 |
version = '%s+hg%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
|
400 |
if version.endswith('+'): |
46512
866eb4d6bd9f
build: fake PEP440 versions
Joerg Sonnenberger <joerg@bec.de>
parents:
46414
diff
changeset
|
401 |
version = version[:-1] + 'local' + time.strftime('%Y%m%d') |
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
402 |
return version |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
403 |
|
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
404 |
|
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
405 |
if os.path.isdir('.hg'): |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
406 |
version = _try_get_version() |
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
|
407 |
elif os.path.exists('.hg_archival.txt'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
408 |
kw = dict( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
409 |
[[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
|
410 |
) |
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
|
411 |
if 'tag' in kw: |
27637
b502138f5faa
cleanup: remove superfluous space after space after equals (python)
timeless <timeless@mozdev.org>
parents:
27374
diff
changeset
|
412 |
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
|
413 |
elif 'latesttag' in kw: |
23646
9641643fac71
setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents:
23392
diff
changeset
|
414 |
if 'changessincelatesttag' in kw: |
46512
866eb4d6bd9f
build: fake PEP440 versions
Joerg Sonnenberger <joerg@bec.de>
parents:
46414
diff
changeset
|
415 |
version = ( |
46523
359bdd8fc60a
build: make version from .hg_archival.txt consistent with that from .hg/
Martin von Zweigbergk <martinvonz@google.com>
parents:
46512
diff
changeset
|
416 |
'%(latesttag)s+hg%(changessincelatesttag)s.%(node).12s' % kw |
46512
866eb4d6bd9f
build: fake PEP440 versions
Joerg Sonnenberger <joerg@bec.de>
parents:
46414
diff
changeset
|
417 |
) |
23646
9641643fac71
setup: use changessincelatesttag from archive if present
Siddharth Agarwal <sid0@fb.com>
parents:
23392
diff
changeset
|
418 |
else: |
46523
359bdd8fc60a
build: make version from .hg_archival.txt consistent with that from .hg/
Martin von Zweigbergk <martinvonz@google.com>
parents:
46512
diff
changeset
|
419 |
version = '%(latesttag)s+hg%(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
|
420 |
else: |
46523
359bdd8fc60a
build: make version from .hg_archival.txt consistent with that from .hg/
Martin von Zweigbergk <martinvonz@google.com>
parents:
46512
diff
changeset
|
421 |
version = '0+hg' + kw.get('node', '')[:12] |
46996
8d2b62d716b0
packaging: extract pre-computed version when running from plain tarball
Joerg Sonnenberger <joerg@bec.de>
parents:
46869
diff
changeset
|
422 |
elif os.path.exists('mercurial/__version__.py'): |
47007
fceccc36873d
lint: fix failing code check
Raphaël Gomès <rgomes@octobus.net>
parents:
46996
diff
changeset
|
423 |
with open('mercurial/__version__.py') as f: |
fceccc36873d
lint: fix failing code check
Raphaël Gomès <rgomes@octobus.net>
parents:
46996
diff
changeset
|
424 |
data = f.read() |
46996
8d2b62d716b0
packaging: extract pre-computed version when running from plain tarball
Joerg Sonnenberger <joerg@bec.de>
parents:
46869
diff
changeset
|
425 |
version = re.search('version = b"(.*)"', data).group(1) |
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
426 |
if not version: |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
427 |
if os.environ.get("MERCURIAL_SETUP_MAKE_LOCAL") == "1": |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
428 |
version = "0.0+0" |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
429 |
eprint("/!\\") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
430 |
eprint(r"/!\ Using '0.0+0' as the default version") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
431 |
eprint(r"/!\ Re-run make local once that first version is built") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
432 |
eprint("/!\\") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
433 |
else: |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
434 |
eprint("/!\\") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
435 |
eprint(r"/!\ Could not determine the Mercurial version") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
436 |
eprint(r"/!\ You need to build a local version first") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
437 |
eprint(r"/!\ Run `make local` and try again") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
438 |
eprint("/!\\") |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
439 |
msg = "Run `make local` first to get a working local version" |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
440 |
raise SystemExit(msg) |
35229
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
441 |
|
50092
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
442 |
versionb = version |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
443 |
if not isinstance(versionb, bytes): |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
444 |
versionb = versionb.encode('ascii') |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
445 |
|
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
446 |
write_if_changed( |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
447 |
'mercurial/__version__.py', |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
448 |
b''.join( |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
449 |
[ |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
450 |
b'# this file is autogenerated by setup.py\n' |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
451 |
b'version = b"%s"\n' % versionb, |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
452 |
] |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
453 |
), |
010a1e73f69e
setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49971
diff
changeset
|
454 |
) |
8493
4c030ada58d2
Fix how setup.py identifies the Mercurial version.
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
7826
diff
changeset
|
455 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
456 |
|
15460
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
457 |
class hgbuild(build): |
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
458 |
# 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
|
459 |
# when build_py is run next. |
28398
712298942c82
setup: remove support for 2to3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28041
diff
changeset
|
460 |
sub_commands = [('build_mo', None)] + build.sub_commands |
15460
f9f0731dbc56
setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents:
15459
diff
changeset
|
461 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
462 |
|
15523
f9da84a950d0
setup: backout 8504699d1aa6
Matt Mackall <mpm@selenic.com>
parents:
15500
diff
changeset
|
463 |
class hgbuildmo(build): |
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
464 |
description = "build translations (.mo files)" |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
465 |
|
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
466 |
def run(self): |
52198
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
467 |
result = self._run() |
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
468 |
if ( |
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
469 |
not result |
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
470 |
and os.environ.get('MERCURIAL_SETUP_FORCE_TRANSLATIONS') == '1' |
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
471 |
): |
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
472 |
raise DistutilsExecError("failed to build translations") |
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
473 |
|
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
474 |
def _run(self): |
51849
4dc1fc2b2f3a
setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents:
51848
diff
changeset
|
475 |
try: |
4dc1fc2b2f3a
setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents:
51848
diff
changeset
|
476 |
from shutil import which as find_executable |
4dc1fc2b2f3a
setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents:
51848
diff
changeset
|
477 |
except ImportError: |
4dc1fc2b2f3a
setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents:
51848
diff
changeset
|
478 |
# Deprecated in py3.12 |
4dc1fc2b2f3a
setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents:
51848
diff
changeset
|
479 |
from distutils.spawn import find_executable |
4dc1fc2b2f3a
setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents:
51848
diff
changeset
|
480 |
|
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
481 |
if not find_executable('msgfmt'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
482 |
self.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
483 |
"could not find msgfmt executable, no translations " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
484 |
"will be built" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
485 |
) |
52198
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
486 |
return False |
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
487 |
|
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
488 |
podir = 'i18n' |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
489 |
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
|
490 |
self.warn("could not find %s/ directory" % podir) |
52198
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
491 |
return False |
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
492 |
|
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
493 |
join = os.path.join |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
494 |
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
|
495 |
if not po.endswith('.po'): |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
496 |
continue |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
497 |
pofile = join(podir, po) |
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
498 |
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
|
499 |
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
|
500 |
mobuildfile = join('mercurial', mofile) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
501 |
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
|
502 |
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
|
503 |
# 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
|
504 |
cmd.append('-c') |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
505 |
self.mkpath(join('mercurial', modir)) |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
506 |
self.make_file([pofile], mobuildfile, spawn, (cmd,)) |
52198
2c4283c9fa93
setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52003
diff
changeset
|
507 |
return True |
7649
a489e3a94443
i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7648
diff
changeset
|
508 |
|
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
509 |
|
15458
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
510 |
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
|
511 |
pure = False |
44487
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
512 |
rust = False |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
513 |
no_rust = False |
29505
2dce3f96ad7b
setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents:
29444
diff
changeset
|
514 |
cffi = ispypy |
15458
c3a6ec304055
setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents:
15388
diff
changeset
|
515 |
|
41759
aaad36b88298
cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents:
41533
diff
changeset
|
516 |
global_options = Distribution.global_options + [ |
aaad36b88298
cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents:
41533
diff
changeset
|
517 |
('pure', None, "use pure (slow) Python code instead of C extensions"), |
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
518 |
('rust', None, "use Rust extensions additionally to C extensions"), |
44487
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
519 |
( |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
520 |
'no-rust', |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
521 |
None, |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
522 |
"do not use Rust extensions additionally to C extensions", |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
523 |
), |
41759
aaad36b88298
cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents:
41533
diff
changeset
|
524 |
] |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
525 |
|
44487
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
526 |
negative_opt = Distribution.negative_opt.copy() |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
527 |
boolean_options = ['pure', 'rust', 'no-rust'] |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
528 |
negative_opt['no-rust'] = 'rust' |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
529 |
|
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
530 |
def _set_command_options(self, command_obj, option_dict=None): |
44630
4c6189d45d67
setup: work around old versions of distutils breaking setup.py
Augie Fackler <augie@google.com>
parents:
44605
diff
changeset
|
531 |
# Not all distutils versions in the wild have boolean_options. |
4c6189d45d67
setup: work around old versions of distutils breaking setup.py
Augie Fackler <augie@google.com>
parents:
44605
diff
changeset
|
532 |
# This should be cleaned up when we're Python 3 only. |
4c6189d45d67
setup: work around old versions of distutils breaking setup.py
Augie Fackler <augie@google.com>
parents:
44605
diff
changeset
|
533 |
command_obj.boolean_options = ( |
4c6189d45d67
setup: work around old versions of distutils breaking setup.py
Augie Fackler <augie@google.com>
parents:
44605
diff
changeset
|
534 |
getattr(command_obj, 'boolean_options', []) + self.boolean_options |
4c6189d45d67
setup: work around old versions of distutils breaking setup.py
Augie Fackler <augie@google.com>
parents:
44605
diff
changeset
|
535 |
) |
44487
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
536 |
return Distribution._set_command_options( |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
537 |
self, command_obj, option_dict=option_dict |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
538 |
) |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
539 |
|
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
540 |
def parse_command_line(self): |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
541 |
ret = Distribution.parse_command_line(self) |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
542 |
if not (self.rust or self.no_rust): |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
543 |
hgrustext = os.environ.get('HGWITHRUSTEXT') |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
544 |
# TODO record it for proper rebuild upon changes |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
545 |
# (see mercurial/__modulepolicy__.py) |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
546 |
if hgrustext != 'cpython' and hgrustext is not None: |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
547 |
if hgrustext: |
48423
fff5942d445f
typo: s/unkown/unknown across the codebase
Raphaël Gomès <rgomes@octobus.net>
parents:
48303
diff
changeset
|
548 |
msg = 'unknown HGWITHRUSTEXT value: %s' % hgrustext |
48827
1371c18e467d
setup: remove printf trampoline
Augie Fackler <augie@google.com>
parents:
48826
diff
changeset
|
549 |
print(msg, file=sys.stderr) |
44487
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
550 |
hgrustext = None |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
551 |
self.rust = hgrustext is not None |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
552 |
self.no_rust = not self.rust |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
553 |
return ret |
06b0aa048007
setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44485
diff
changeset
|
554 |
|
15459
434c48e981b8
setup: has_ext_modules always returns false when pure is specified
Simon Heimberg <simohe@besonet.ch>
parents:
15458
diff
changeset
|
555 |
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
|
556 |
# 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
|
557 |
# 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
|
558 |
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
|
559 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
560 |
|
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
561 |
# 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:
30436
diff
changeset
|
562 |
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:
30436
diff
changeset
|
563 |
buildextnegops['no-zstd'] = 'zstd' |
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
564 |
buildextnegops['no-rust'] = 'rust' |
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
565 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
566 |
|
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
567 |
class hgbuildext(build_ext): |
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
568 |
user_options = build_ext.user_options + [ |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
569 |
('zstd', None, 'compile zstd bindings [default]'), |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
570 |
('no-zstd', None, 'do not compile zstd bindings'), |
43076
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 |
'rust', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
573 |
None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
574 |
'compile Rust extensions if they are in use ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
575 |
'(requires Cargo) [default]', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
576 |
), |
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
577 |
('no-rust', None, 'do not compile Rust extensions'), |
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
578 |
] |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
579 |
|
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
580 |
boolean_options = build_ext.boolean_options + ['zstd', 'rust'] |
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
581 |
negative_opt = buildextnegops |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
582 |
|
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
583 |
def initialize_options(self): |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
584 |
self.zstd = True |
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
585 |
self.rust = True |
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
586 |
|
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
587 |
return build_ext.initialize_options(self) |
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
588 |
|
43044
f9d35f01b8b3
setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42813
diff
changeset
|
589 |
def finalize_options(self): |
f9d35f01b8b3
setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42813
diff
changeset
|
590 |
# 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:
42813
diff
changeset
|
591 |
# Only influences behavior on Python 3.5+. |
f9d35f01b8b3
setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42813
diff
changeset
|
592 |
if getattr(self, 'parallel', None) is None: |
f9d35f01b8b3
setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42813
diff
changeset
|
593 |
self.parallel = True |
f9d35f01b8b3
setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42813
diff
changeset
|
594 |
|
f9d35f01b8b3
setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42813
diff
changeset
|
595 |
return build_ext.finalize_options(self) |
f9d35f01b8b3
setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42813
diff
changeset
|
596 |
|
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
597 |
def build_extensions(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
598 |
ruststandalones = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
599 |
e for e in self.extensions if isinstance(e, RustStandaloneExtension) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
600 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
601 |
self.extensions = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
602 |
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
|
603 |
] |
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
604 |
# 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:
30436
diff
changeset
|
605 |
if not self.zstd: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
606 |
self.extensions = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
607 |
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
|
608 |
] |
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
609 |
|
48502
23ce9e7bf1e5
setup.py: fix some documentation typos
Matt Harbison <matt_harbison@yahoo.com>
parents:
48423
diff
changeset
|
610 |
# Build Rust standalone extensions if it'll be used |
23ce9e7bf1e5
setup.py: fix some documentation typos
Matt Harbison <matt_harbison@yahoo.com>
parents:
48423
diff
changeset
|
611 |
# and its build is not explicitly disabled (for external build |
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
612 |
# as Linux distributions would do) |
44466
79ac59d3f73d
setup-rust: remove the legacy 'direct-ffi' variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44452
diff
changeset
|
613 |
if self.distribution.rust and self.rust: |
46369
cabc5e9366c5
rust: lower compile error on non-linux platforms to a warning
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
46315
diff
changeset
|
614 |
if not sys.platform.startswith('linux'): |
cabc5e9366c5
rust: lower compile error on non-linux platforms to a warning
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
46315
diff
changeset
|
615 |
self.warn( |
cabc5e9366c5
rust: lower compile error on non-linux platforms to a warning
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
46315
diff
changeset
|
616 |
"rust extensions have only been tested on Linux " |
cabc5e9366c5
rust: lower compile error on non-linux platforms to a warning
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
46315
diff
changeset
|
617 |
"and may not behave correctly on other platforms" |
cabc5e9366c5
rust: lower compile error on non-linux platforms to a warning
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
46315
diff
changeset
|
618 |
) |
cabc5e9366c5
rust: lower compile error on non-linux platforms to a warning
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
46315
diff
changeset
|
619 |
|
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
620 |
for rustext in ruststandalones: |
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
621 |
rustext.build('' if self.inplace else self.build_lib) |
40967
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
622 |
|
30450
0acf3fd718f1
setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30436
diff
changeset
|
623 |
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
|
624 |
|
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
625 |
def build_extension(self, ext): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
626 |
if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
627 |
self.distribution.rust |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
628 |
and self.rust |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
629 |
and isinstance(ext, RustExtension) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
630 |
): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
631 |
ext.rustbuild() |
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
632 |
try: |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
633 |
build_ext.build_extension(self, ext) |
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
634 |
except CCompilerError: |
12501
98f21e4d9633
setup: slight simplification
Martin Geisler <mg@lazybytes.net>
parents:
11533
diff
changeset
|
635 |
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
|
636 |
raise |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
637 |
log.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
638 |
"Failed to build optional extension '%s' (skipping)", ext.name |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
639 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
640 |
|
11468
1c1126b1d919
setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents:
10905
diff
changeset
|
641 |
|
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
642 |
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
|
643 |
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
|
644 |
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
|
645 |
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
|
646 |
|
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
647 |
exebuilt = False |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
648 |
try: |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
649 |
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
|
650 |
exebuilt = True |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
651 |
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
|
652 |
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
|
653 |
|
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
654 |
if exebuilt: |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
655 |
# 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
|
656 |
# 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
|
657 |
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
|
658 |
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
|
659 |
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
|
660 |
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
|
661 |
|
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
662 |
# 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
|
663 |
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
|
664 |
|
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
665 |
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
|
666 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
667 |
|
10000
16f49d671c7f
setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents:
9999
diff
changeset
|
668 |
class hgbuildpy(build_py): |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
669 |
def finalize_options(self): |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
670 |
build_py.finalize_options(self) |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
671 |
|
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
672 |
if self.distribution.pure: |
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
673 |
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
|
674 |
elif self.distribution.cffi: |
30346
9cc438bf7d9a
setup: move cffi stuff to mercurial/cffi
Jun Wu <quark@fb.com>
parents:
29833
diff
changeset
|
675 |
from mercurial.cffi import ( |
32505
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32420
diff
changeset
|
676 |
bdiffbuild, |
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32420
diff
changeset
|
677 |
mpatchbuild, |
30346
9cc438bf7d9a
setup: move cffi stuff to mercurial/cffi
Jun Wu <quark@fb.com>
parents:
29833
diff
changeset
|
678 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
679 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
680 |
exts = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
681 |
mpatchbuild.ffi.distutils_extension(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
682 |
bdiffbuild.ffi.distutils_extension(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
683 |
] |
29505
2dce3f96ad7b
setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents:
29444
diff
changeset
|
684 |
# 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
|
685 |
if sys.platform == 'darwin': |
32505
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32420
diff
changeset
|
686 |
from mercurial.cffi import osutilbuild |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
687 |
|
32505
05a16c19967e
cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents:
32420
diff
changeset
|
688 |
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
|
689 |
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
|
690 |
else: |
18905
012780620d4f
setup: make error message for missing Python headers more helpful
Mads Kiilerich <mads@kiilerich.com>
parents:
18900
diff
changeset
|
691 |
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
|
692 |
if not os.path.exists(h): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
693 |
raise SystemExit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
694 |
'Python headers are required to build ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
695 |
'Mercurial but weren\'t found in %s' % h |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
696 |
) |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
697 |
|
28430
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
698 |
def run(self): |
32655
7dab4c0cdb41
setup: do not overwrite local __modulepolicy__.py on out-of-source build
Yuya Nishihara <yuya@tcha.org>
parents:
32647
diff
changeset
|
699 |
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:
32647
diff
changeset
|
700 |
self.mkpath(basepath) |
7dab4c0cdb41
setup: do not overwrite local __modulepolicy__.py on out-of-source build
Yuya Nishihara <yuya@tcha.org>
parents:
32647
diff
changeset
|
701 |
|
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
702 |
rust = self.distribution.rust |
28430
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
703 |
if self.distribution.pure: |
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
704 |
modulepolicy = 'py' |
32251
a04f5c651e52
policy: relax the default for in-place build
Yuya Nishihara <yuya@tcha.org>
parents:
32233
diff
changeset
|
705 |
elif self.build_lib == '.': |
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
706 |
# 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:
42451
diff
changeset
|
707 |
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
|
708 |
else: |
42453
94167e701e12
rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42451
diff
changeset
|
709 |
modulepolicy = 'rust+c' if rust else 'c' |
35229
61ff0d7d56fd
setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35103
diff
changeset
|
710 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
711 |
content = b''.join( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
712 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
713 |
b'# this file is autogenerated by setup.py\n', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
714 |
b'modulepolicy = b"%s"\n' % modulepolicy.encode('ascii'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
715 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
716 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
717 |
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
|
718 |
|
28430
17b85d739b62
setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents:
28418
diff
changeset
|
719 |
build_py.run(self) |
7722
103127a8cbdb
add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents:
7721
diff
changeset
|
720 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
721 |
|
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
722 |
class buildhgextindex(Command): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
723 |
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
|
724 |
user_options = [] |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
725 |
_indexfilename = 'hgext/__index__.py' |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
726 |
|
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
727 |
def initialize_options(self): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
728 |
pass |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
729 |
|
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
730 |
def finalize_options(self): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
731 |
pass |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
732 |
|
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
733 |
def run(self): |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
734 |
if os.path.exists(self._indexfilename): |
28418
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
735 |
with open(self._indexfilename, 'w') as f: |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
736 |
f.write('# empty\n') |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
737 |
|
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
738 |
# here no extension enabled, disabled() lists up everything |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
739 |
code = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
740 |
'import pprint; from mercurial import extensions; ' |
44378
bb58931d0c4f
setup: exclude the __index__ module from itself when generating
Matt Harbison <matt_harbison@yahoo.com>
parents:
44170
diff
changeset
|
741 |
'ext = extensions.disabled();' |
bb58931d0c4f
setup: exclude the __index__ module from itself when generating
Matt Harbison <matt_harbison@yahoo.com>
parents:
44170
diff
changeset
|
742 |
'ext.pop("__index__", None);' |
bb58931d0c4f
setup: exclude the __index__ module from itself when generating
Matt Harbison <matt_harbison@yahoo.com>
parents:
44170
diff
changeset
|
743 |
'pprint.pprint(ext)' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
744 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
745 |
returncode, out, err = runcmd( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
746 |
[sys.executable, '-c', code], localhgenv() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
747 |
) |
33111
87ee783f7299
setup: update runcmd() to also return the exit status
Adam Simpkins <simpkins@fb.com>
parents:
33110
diff
changeset
|
748 |
if err or returncode != 0: |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
749 |
raise DistutilsExecError(err) |
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
750 |
|
42075
456c37433c43
py3: write out hgextindex as bytes in setup.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
42074
diff
changeset
|
751 |
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
|
752 |
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
|
753 |
f.write(b'docs = ') |
28418
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
754 |
f.write(out) |
14538
3818c67a501e
setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents:
14324
diff
changeset
|
755 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
756 |
|
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
757 |
class buildhgexe(build_ext): |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
758 |
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:
34397
diff
changeset
|
759 |
|
49396
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
760 |
LONG_PATHS_MANIFEST = """\ |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
761 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
762 |
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
763 |
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
764 |
<security> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
765 |
<requestedPrivileges> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
766 |
<requestedExecutionLevel |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
767 |
level="asInvoker" |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
768 |
uiAccess="false" |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
769 |
/> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
770 |
</requestedPrivileges> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
771 |
</security> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
772 |
</trustInfo> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
773 |
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
774 |
<application> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
775 |
<!-- Windows Vista --> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
776 |
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
777 |
<!-- Windows 7 --> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
778 |
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
779 |
<!-- Windows 8 --> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
780 |
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
781 |
<!-- Windows 8.1 --> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
782 |
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
783 |
<!-- Windows 10 and Windows 11 --> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
784 |
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
785 |
</application> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
786 |
</compatibility> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
787 |
<application xmlns="urn:schemas-microsoft-com:asm.v3"> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
788 |
<windowsSettings |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
789 |
xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings"> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
790 |
<ws2:longPathAware>true</ws2:longPathAware> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
791 |
</windowsSettings> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
792 |
</application> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
793 |
<dependency> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
794 |
<dependentAssembly> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
795 |
<assemblyIdentity type="win32" |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
796 |
name="Microsoft.Windows.Common-Controls" |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
797 |
version="6.0.0.0" |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
798 |
processorArchitecture="*" |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
799 |
publicKeyToken="6595b64144ccf1df" |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
800 |
language="*" /> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
801 |
</dependentAssembly> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
802 |
</dependency> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
803 |
</assembly> |
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
804 |
""" |
34530
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
805 |
|
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
806 |
def initialize_options(self): |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
807 |
build_ext.initialize_options(self) |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
808 |
|
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
809 |
def build_extensions(self): |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
810 |
if os.name != 'nt': |
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
811 |
return |
17246
bf5bb38bcc7c
setup: fix build_hgexe for mingw32 compiler
Adrian Buehlmann <adrian@cadifra.com>
parents:
17121
diff
changeset
|
812 |
if isinstance(self.compiler, HackedMingw32CCompiler): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
813 |
self.compiler.compiler_so = self.compiler.compiler # no -mdll |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
814 |
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
|
815 |
|
43678
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
816 |
pythonlib = None |
29020
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
817 |
|
49394
5cf73de964e1
setup: stop shadowing the builtin `dir` symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
49310
diff
changeset
|
818 |
dirname = os.path.dirname(self.get_ext_fullpath('dummy')) |
5cf73de964e1
setup: stop shadowing the builtin `dir` symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
49310
diff
changeset
|
819 |
self.hgtarget = os.path.join(dirname, 'hg') |
48303
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
820 |
|
43678
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
821 |
if getattr(sys, 'dllhandle', None): |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
822 |
# Different Python installs can have different Python library |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
823 |
# names. e.g. the official CPython distribution uses pythonXY.dll |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
824 |
# and MinGW uses libpythonX.Y.dll. |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
825 |
_kernel32 = ctypes.windll.kernel32 |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
826 |
_kernel32.GetModuleFileNameA.argtypes = [ |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
827 |
ctypes.c_void_p, |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
828 |
ctypes.c_void_p, |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
829 |
ctypes.c_ulong, |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
830 |
] |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
831 |
_kernel32.GetModuleFileNameA.restype = ctypes.c_ulong |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
832 |
size = 1000 |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
833 |
buf = ctypes.create_string_buffer(size + 1) |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
834 |
filelen = _kernel32.GetModuleFileNameA( |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
835 |
sys.dllhandle, ctypes.byref(buf), size |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
836 |
) |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
837 |
|
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
838 |
if filelen > 0 and filelen != size: |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
839 |
dllbasename = os.path.basename(buf.value) |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
840 |
if not dllbasename.lower().endswith(b'.dll'): |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
841 |
raise SystemExit( |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
842 |
'Python DLL does not end with .dll: %s' % dllbasename |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
843 |
) |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
844 |
pythonlib = dllbasename[:-4] |
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
845 |
|
48303
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
846 |
# Copy the pythonXY.dll next to the binary so that it runs |
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
847 |
# without tampering with PATH. |
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
848 |
dest = os.path.join( |
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
849 |
os.path.dirname(self.hgtarget), |
48829
fef4198c855c
setup: inline os.fsdecode now that we're done with Python 2
Augie Fackler <augie@google.com>
parents:
48828
diff
changeset
|
850 |
os.fsdecode(dllbasename), |
48303
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
851 |
) |
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
852 |
|
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
853 |
if not os.path.exists(dest): |
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
854 |
shutil.copy(buf.value, dest) |
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
855 |
|
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
856 |
# Also overwrite python3.dll so that hgext.git is usable. |
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
857 |
# TODO: also handle the MSYS flavor |
48831
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
858 |
python_x = os.path.join( |
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
859 |
os.path.dirname(os.fsdecode(buf.value)), |
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
860 |
"python3.dll", |
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
861 |
) |
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
862 |
|
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
863 |
if os.path.exists(python_x): |
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
864 |
dest = os.path.join( |
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
865 |
os.path.dirname(self.hgtarget), |
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
866 |
os.path.basename(python_x), |
48303
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
867 |
) |
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
868 |
|
48831
40e35034eac8
setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents:
48830
diff
changeset
|
869 |
shutil.copy(python_x, dest) |
48303
2ce31dbde4b1
backout: backed out changeset f78d8b8c46d7
Raphaël Gomès <rgomes@octobus.net>
parents:
48182
diff
changeset
|
870 |
|
43678
52e4bfebc4ba
setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents:
43676
diff
changeset
|
871 |
if not pythonlib: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
872 |
log.warn( |
43675
666441b649e4
setup: combine two contiguous string literals
Matt Harbison <matt_harbison@yahoo.com>
parents:
43632
diff
changeset
|
873 |
'could not determine Python DLL filename; assuming pythonXY' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
874 |
) |
29020
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
875 |
|
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
876 |
hv = sys.hexversion |
43676
6a5dc4d767a0
setup: use bytes for assumed python version
Matt Harbison <matt_harbison@yahoo.com>
parents:
43675
diff
changeset
|
877 |
pythonlib = b'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
|
878 |
|
ee2e4a2c3690
setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28625
diff
changeset
|
879 |
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
|
880 |
with open('mercurial/hgpythonlib.h', 'wb') as f: |
39608
ec68135a8935
py3: add b'' to some setup.py strings for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
39572
diff
changeset
|
881 |
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:
39572
diff
changeset
|
882 |
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
|
883 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
884 |
objects = self.compiler.compile( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
885 |
['mercurial/exewrapper.c'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
886 |
output_dir=self.build_temp, |
48832
b07b034cf548
setup: inline now-constant list
Augie Fackler <augie@google.com>
parents:
48831
diff
changeset
|
887 |
macros=[('_UNICODE', None), ('UNICODE', None)], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
888 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
889 |
self.compiler.link_executable( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
890 |
objects, self.hgtarget, libraries=[], output_dir=self.build_temp |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
891 |
) |
49395
747c4fc20886
setup: unconditionally enable the `long-paths-support` option on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
49394
diff
changeset
|
892 |
|
747c4fc20886
setup: unconditionally enable the `long-paths-support` option on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
49394
diff
changeset
|
893 |
self.addlongpathsmanifest() |
34530
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
894 |
|
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
895 |
def addlongpathsmanifest(self): |
49395
747c4fc20886
setup: unconditionally enable the `long-paths-support` option on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
49394
diff
changeset
|
896 |
"""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:
34397
diff
changeset
|
897 |
|
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
898 |
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:
34397
diff
changeset
|
899 |
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:
34397
diff
changeset
|
900 |
""" |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
901 |
exefname = self.compiler.executable_filename(self.hgtarget) |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
902 |
fdauto, manfname = tempfile.mkstemp(suffix='.hg.exe.manifest') |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
903 |
os.close(fdauto) |
49396
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
904 |
with open(manfname, 'w', encoding="UTF-8") as f: |
34530
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
905 |
f.write(self.LONG_PATHS_MANIFEST) |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
906 |
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:
34397
diff
changeset
|
907 |
outputresource = '-outputresource:%s;#1' % exefname |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
908 |
log.info("running mt.exe to update hg.exe's manifest in-place") |
49396
ece490b02a9b
setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49395
diff
changeset
|
909 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
910 |
self.spawn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
911 |
[ |
49395
747c4fc20886
setup: unconditionally enable the `long-paths-support` option on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
49394
diff
changeset
|
912 |
self.compiler.mt, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
913 |
'-nologo', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
914 |
'-manifest', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
915 |
manfname, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
916 |
outputresource, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
917 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
918 |
) |
34530
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
919 |
log.info("done updating hg.exe's manifest") |
ed5acd3fd7e1
windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents:
34397
diff
changeset
|
920 |
os.remove(manfname) |
17061
f20e4d76b711
setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents:
16775
diff
changeset
|
921 |
|
27268
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
922 |
@property |
ed1660ce99d9
setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27222
diff
changeset
|
923 |
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
|
924 |
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
|
925 |
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
|
926 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
927 |
|
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
928 |
class hgbuilddoc(Command): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
929 |
description = 'build documentation' |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
930 |
user_options = [ |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
931 |
('man', None, 'generate man pages'), |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
932 |
('html', None, 'generate html pages'), |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
933 |
] |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
934 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
935 |
def initialize_options(self): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
936 |
self.man = None |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
937 |
self.html = None |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
938 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
939 |
def finalize_options(self): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
940 |
# 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:
41759
diff
changeset
|
941 |
# Otherwise generate everything. |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
942 |
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:
41759
diff
changeset
|
943 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
944 |
if have_subset: |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
945 |
self.man = True if self.man else False |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
946 |
self.html = True if self.html else False |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
947 |
else: |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
948 |
self.man = True |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
949 |
self.html = True |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
950 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
951 |
def run(self): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
952 |
def normalizecrlf(p): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
953 |
with open(p, 'rb') as fh: |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
954 |
orig = fh.read() |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
955 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
956 |
if b'\r\n' not in orig: |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
957 |
return |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
958 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
959 |
log.info('normalizing %s to LF line endings' % p) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
960 |
with open(p, 'wb') as fh: |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
961 |
fh.write(orig.replace(b'\r\n', b'\n')) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
962 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
963 |
def gentxt(root): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
964 |
txt = 'doc/%s.txt' % root |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
965 |
log.info('generating %s' % txt) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
966 |
res, out, err = runcmd( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
967 |
[sys.executable, 'gendoc.py', root], os.environ, cwd='doc' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
968 |
) |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
969 |
if res: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
970 |
raise SystemExit( |
44742
380959c6f75e
setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44729
diff
changeset
|
971 |
'error running gendoc.py: %s' |
380959c6f75e
setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44729
diff
changeset
|
972 |
% '\n'.join([sysstr(out), sysstr(err)]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
973 |
) |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
974 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
975 |
with open(txt, 'wb') as fh: |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
976 |
fh.write(out) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
977 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
978 |
def gengendoc(root): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
979 |
gendoc = 'doc/%s.gendoc.txt' % root |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
980 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
981 |
log.info('generating %s' % gendoc) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
982 |
res, out, err = runcmd( |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
983 |
[sys.executable, 'gendoc.py', '%s.gendoc' % root], |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
984 |
os.environ, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
985 |
cwd='doc', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
986 |
) |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
987 |
if res: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
988 |
raise SystemExit( |
44742
380959c6f75e
setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44729
diff
changeset
|
989 |
'error running gendoc: %s' |
380959c6f75e
setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44729
diff
changeset
|
990 |
% '\n'.join([sysstr(out), sysstr(err)]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
991 |
) |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
992 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
993 |
with open(gendoc, 'wb') as fh: |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
994 |
fh.write(out) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
995 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
996 |
def genman(root): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
997 |
log.info('generating doc/%s' % root) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
998 |
res, out, err = runcmd( |
43076
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 |
sys.executable, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1001 |
'runrst', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1002 |
'hgmanpage', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1003 |
'--halt', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1004 |
'warning', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1005 |
'--strip-elements-with-class', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1006 |
'htmlonly', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1007 |
'%s.txt' % root, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1008 |
root, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1009 |
], |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1010 |
os.environ, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1011 |
cwd='doc', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1012 |
) |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1013 |
if res: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1014 |
raise SystemExit( |
44742
380959c6f75e
setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44729
diff
changeset
|
1015 |
'error running runrst: %s' |
380959c6f75e
setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44729
diff
changeset
|
1016 |
% '\n'.join([sysstr(out), sysstr(err)]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1017 |
) |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1018 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1019 |
normalizecrlf('doc/%s' % root) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1020 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1021 |
def genhtml(root): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1022 |
log.info('generating doc/%s.html' % root) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1023 |
res, out, err = runcmd( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1024 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1025 |
sys.executable, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1026 |
'runrst', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1027 |
'html', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1028 |
'--halt', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1029 |
'warning', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1030 |
'--link-stylesheet', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1031 |
'--stylesheet-path', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1032 |
'style.css', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1033 |
'%s.txt' % root, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1034 |
'%s.html' % root, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1035 |
], |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1036 |
os.environ, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1037 |
cwd='doc', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1038 |
) |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1039 |
if res: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1040 |
raise SystemExit( |
44742
380959c6f75e
setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44729
diff
changeset
|
1041 |
'error running runrst: %s' |
380959c6f75e
setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44729
diff
changeset
|
1042 |
% '\n'.join([sysstr(out), sysstr(err)]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1043 |
) |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1044 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1045 |
normalizecrlf('doc/%s.html' % root) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1046 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1047 |
# This logic is duplicated in doc/Makefile. |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44440
diff
changeset
|
1048 |
sources = { |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1049 |
f |
43749
c7fc2d92067e
windows: further build fixes for the WiX installer
Augie Fackler <augie@google.com>
parents:
43678
diff
changeset
|
1050 |
for f in os.listdir('mercurial/helptext') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1051 |
if re.search(r'[0-9]\.txt$', f) |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44440
diff
changeset
|
1052 |
} |
41850
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1053 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1054 |
# common.txt is a one-off. |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1055 |
gentxt('common') |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1056 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1057 |
for source in sorted(sources): |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1058 |
assert source[-4:] == '.txt' |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1059 |
root = source[:-4] |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1060 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1061 |
gentxt(root) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1062 |
gengendoc(root) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1063 |
|
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1064 |
if self.man: |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1065 |
genman(root) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1066 |
if self.html: |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1067 |
genhtml(root) |
d80d48928eb1
setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41759
diff
changeset
|
1068 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1069 |
|
32647
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32506
diff
changeset
|
1070 |
class hginstall(install): |
32725
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32655
diff
changeset
|
1071 |
user_options = install.user_options + [ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1072 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1073 |
'old-and-unmanageable', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1074 |
None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1075 |
'noop, present for eggless setuptools compat', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1076 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1077 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1078 |
'single-version-externally-managed', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1079 |
None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1080 |
'noop, present for eggless setuptools compat', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1081 |
), |
32725
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32655
diff
changeset
|
1082 |
] |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32655
diff
changeset
|
1083 |
|
48988
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1084 |
sub_commands = install.sub_commands + [ |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1085 |
('install_completion', lambda self: True) |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1086 |
] |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1087 |
|
32725
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32655
diff
changeset
|
1088 |
# 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:
32655
diff
changeset
|
1089 |
single_version_externally_managed = True |
6c4b58422974
setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents:
32655
diff
changeset
|
1090 |
|
32647
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32506
diff
changeset
|
1091 |
def get_sub_commands(self): |
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32506
diff
changeset
|
1092 |
# 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:
32506
diff
changeset
|
1093 |
# 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:
32506
diff
changeset
|
1094 |
# packaging. |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44440
diff
changeset
|
1095 |
excl = {'bdist_egg'} |
46315
2ef575c62f10
test-regression: backing out D9640 (63c923fd7fa8)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46243
diff
changeset
|
1096 |
return filter(lambda x: x not in excl, install.get_sub_commands(self)) |
32647
331dcf199039
setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents:
32506
diff
changeset
|
1097 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1098 |
|
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1099 |
class hginstalllib(install_lib): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1100 |
""" |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1101 |
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
|
1102 |
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
|
1103 |
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
|
1104 |
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
|
1105 |
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
|
1106 |
|
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1107 |
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
|
1108 |
insufficient, as it might still be applying a umask. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1109 |
""" |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1110 |
|
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1111 |
def run(self): |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1112 |
realcopyfile = file_util.copy_file |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1113 |
|
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1114 |
def copyfileandsetmode(*args, **kwargs): |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1115 |
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
|
1116 |
dst, copied = realcopyfile(*args, **kwargs) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1117 |
if copied: |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1118 |
st = os.stat(src) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1119 |
# 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
|
1120 |
# has it) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1121 |
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
|
1122 |
setmode = int('0755', 8) |
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1123 |
else: |
24941
9c1942635c1f
setup: hide octal literals inside strings so they're portable (issue4554)
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
1124 |
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
|
1125 |
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
|
1126 |
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
|
1127 |
os.chmod(dst, m) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1128 |
|
22640
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1129 |
file_util.copy_file = copyfileandsetmode |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1130 |
try: |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1131 |
install_lib.run(self) |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1132 |
finally: |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1133 |
file_util.copy_file = realcopyfile |
e88a634e0195
setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents:
22575
diff
changeset
|
1134 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1135 |
|
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1136 |
class hginstallscripts(install_scripts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1137 |
""" |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1138 |
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
|
1139 |
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
|
1140 |
to the directory for scripts. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1141 |
""" |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1142 |
|
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1143 |
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
|
1144 |
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
|
1145 |
|
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1146 |
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
|
1147 |
|
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1148 |
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
|
1149 |
install_scripts.finalize_options(self) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1150 |
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
|
1151 |
|
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1152 |
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
|
1153 |
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
|
1154 |
|
27269
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
1155 |
# 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
|
1156 |
# 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
|
1157 |
# 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
|
1158 |
# wheel archive looks like: |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
1159 |
# |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
1160 |
# 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
|
1161 |
# mercurial/__init__.py |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
1162 |
# |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
1163 |
# 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
|
1164 |
# 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
|
1165 |
# 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
|
1166 |
# 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
|
1167 |
# 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
|
1168 |
# 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
|
1169 |
# 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
|
1170 |
# 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
|
1171 |
# 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
|
1172 |
# 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
|
1173 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1174 |
if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1175 |
os.path.splitdrive(self.install_dir)[0] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1176 |
!= os.path.splitdrive(self.install_lib)[0] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1177 |
): |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1178 |
# 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
|
1179 |
# 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
|
1180 |
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
|
1181 |
else: |
44080
4e05272dd681
packaging: leverage os.path.relpath() in setup.py
Martin von Zweigbergk <martinvonz@google.com>
parents:
44058
diff
changeset
|
1182 |
libdir = os.path.relpath(self.install_lib, self.install_dir) |
12661
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1183 |
|
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1184 |
for outfile in self.outfiles: |
28418
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
1185 |
with open(outfile, 'rb') as fp: |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
1186 |
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
|
1187 |
|
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1188 |
# skip binary files |
27348
83a8219fb790
setup.py: use bytes literals
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27269
diff
changeset
|
1189 |
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
|
1190 |
continue |
10da5a1f25dd
setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12649
diff
changeset
|
1191 |
|
27269
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
1192 |
# 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
|
1193 |
# 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
|
1194 |
# value. |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
1195 |
if data.startswith(b'#!python'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1196 |
log.info( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1197 |
'not rewriting @LIBDIR@ in %s because install path ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1198 |
'not known' % outfile |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1199 |
) |
27269
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
1200 |
continue |
bdcbec65750b
setup.py: don't rewrite @LIBDIR@ when creating wheels
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27268
diff
changeset
|
1201 |
|
48828
40a65f5594f5
setup: inline encoding constant that is only used once
Augie Fackler <augie@google.com>
parents:
48827
diff
changeset
|
1202 |
data = data.replace(b'@LIBDIR@', libdir.encode('unicode_escape')) |
28418
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
1203 |
with open(outfile, 'wb') as fp: |
121d25719e92
setup: switch to with open as
timeless <timeless@mozdev.org>
parents:
28398
diff
changeset
|
1204 |
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
|
1205 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1206 |
|
48988
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1207 |
class hginstallcompletion(Command): |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1208 |
description = 'Install shell completion' |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1209 |
|
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1210 |
def initialize_options(self): |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1211 |
self.install_dir = None |
49038
b6f535f3beda
setup: fix incomplete implementation of Command
Raphaël Gomès <rgomes@octobus.net>
parents:
48988
diff
changeset
|
1212 |
self.outputs = [] |
48988
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1213 |
|
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1214 |
def finalize_options(self): |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1215 |
self.set_undefined_options( |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1216 |
'install_data', ('install_dir', 'install_dir') |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1217 |
) |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1218 |
|
49038
b6f535f3beda
setup: fix incomplete implementation of Command
Raphaël Gomès <rgomes@octobus.net>
parents:
48988
diff
changeset
|
1219 |
def get_outputs(self): |
b6f535f3beda
setup: fix incomplete implementation of Command
Raphaël Gomès <rgomes@octobus.net>
parents:
48988
diff
changeset
|
1220 |
return self.outputs |
b6f535f3beda
setup: fix incomplete implementation of Command
Raphaël Gomès <rgomes@octobus.net>
parents:
48988
diff
changeset
|
1221 |
|
48988
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1222 |
def run(self): |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1223 |
for src, dir_path, dest in ( |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1224 |
( |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1225 |
'bash_completion', |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1226 |
('share', 'bash-completion', 'completions'), |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1227 |
'hg', |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1228 |
), |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1229 |
('zsh_completion', ('share', 'zsh', 'site-functions'), '_hg'), |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1230 |
): |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1231 |
dir = os.path.join(self.install_dir, *dir_path) |
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1232 |
self.mkpath(dir) |
49038
b6f535f3beda
setup: fix incomplete implementation of Command
Raphaël Gomès <rgomes@octobus.net>
parents:
48988
diff
changeset
|
1233 |
|
b6f535f3beda
setup: fix incomplete implementation of Command
Raphaël Gomès <rgomes@octobus.net>
parents:
48988
diff
changeset
|
1234 |
dest = os.path.join(dir, dest) |
b6f535f3beda
setup: fix incomplete implementation of Command
Raphaël Gomès <rgomes@octobus.net>
parents:
48988
diff
changeset
|
1235 |
self.outputs.append(dest) |
b6f535f3beda
setup: fix incomplete implementation of Command
Raphaël Gomès <rgomes@octobus.net>
parents:
48988
diff
changeset
|
1236 |
self.copy_file(os.path.join('contrib', src), dest) |
48988
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1237 |
|
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1238 |
|
42172
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1239 |
# 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
|
1240 |
# 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
|
1241 |
# "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
|
1242 |
# 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
|
1243 |
# 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
|
1244 |
# 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
|
1245 |
# |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1246 |
# 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
|
1247 |
# 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
|
1248 |
# 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
|
1249 |
# 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
|
1250 |
# deterministic and reproducible. |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1251 |
# |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1252 |
# 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
|
1253 |
# 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
|
1254 |
# 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
|
1255 |
# 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
|
1256 |
# 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
|
1257 |
# 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
|
1258 |
# is less brittle. |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1259 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1260 |
# 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
|
1261 |
# 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
|
1262 |
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
|
1263 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1264 |
if py2exehacked: |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1265 |
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
|
1266 |
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
|
1267 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1268 |
class hgbuildpy2exe(buildpy2exe): |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1269 |
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
|
1270 |
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
|
1271 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1272 |
# Replace virtualenv's distutils modules with the real ones. |
42174
bd92dd3eff42
setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42172
diff
changeset
|
1273 |
modules = {} |
bd92dd3eff42
setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42172
diff
changeset
|
1274 |
for k, v in res.modules.items(): |
bd92dd3eff42
setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42172
diff
changeset
|
1275 |
if k != 'distutils' and not k.startswith('distutils.'): |
bd92dd3eff42
setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42172
diff
changeset
|
1276 |
modules[k] = v |
bd92dd3eff42
setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42172
diff
changeset
|
1277 |
|
bd92dd3eff42
setup: remove set and dict comprehensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42172
diff
changeset
|
1278 |
res.modules = modules |
42172
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1279 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1280 |
import opcode |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1281 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1282 |
distutilsreal = os.path.join( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1283 |
os.path.dirname(opcode.__file__), 'distutils' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1284 |
) |
42172
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1285 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1286 |
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
|
1287 |
for f in sorted(files): |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1288 |
if not f.endswith('.py'): |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1289 |
continue |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1290 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1291 |
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
|
1292 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1293 |
parents = ['distutils'] |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1294 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1295 |
if root != distutilsreal: |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1296 |
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
|
1297 |
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
|
1298 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1299 |
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
|
1300 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1301 |
if modname.startswith('distutils.tests.'): |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1302 |
continue |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1303 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1304 |
if modname.endswith('.__init__'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1305 |
modname = modname[: -len('.__init__')] |
42172
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1306 |
path = os.path.dirname(full) |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1307 |
else: |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1308 |
path = None |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1309 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1310 |
res.modules[modname] = py2exemodule( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1311 |
modname, full, path=path |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1312 |
) |
42172
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1313 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1314 |
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
|
1315 |
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
|
1316 |
|
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1317 |
return res |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1318 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1319 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1320 |
cmdclass = { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1321 |
'build': hgbuild, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1322 |
'build_doc': hgbuilddoc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1323 |
'build_mo': hgbuildmo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1324 |
'build_ext': hgbuildext, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1325 |
'build_py': hgbuildpy, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1326 |
'build_scripts': hgbuildscripts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1327 |
'build_hgextindex': buildhgextindex, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1328 |
'install': hginstall, |
48988
8d7eaff92f9c
completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents:
48946
diff
changeset
|
1329 |
'install_completion': hginstallcompletion, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1330 |
'install_lib': hginstalllib, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1331 |
'install_scripts': hginstallscripts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1332 |
'build_hgexe': buildhgexe, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1333 |
} |
3238
3dba9ec89164
Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2402
diff
changeset
|
1334 |
|
42172
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1335 |
if py2exehacked: |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1336 |
cmdclass['py2exe'] = hgbuildpy2exe |
71d8b4d91616
setup: properly package distutils in py2exe virtualenv builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42075
diff
changeset
|
1337 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1338 |
packages = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1339 |
'mercurial', |
50987
727428c7e1fc
commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents:
50936
diff
changeset
|
1340 |
'mercurial.admin', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1341 |
'mercurial.cext', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1342 |
'mercurial.cffi', |
51901
f0e07efc199f
rev-branch-cache: move the code in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51849
diff
changeset
|
1343 |
'mercurial.branching', |
44026
44b03c0313aa
setup: include `defaultrc` in the package list
Matt Harbison <matt_harbison@yahoo.com>
parents:
43794
diff
changeset
|
1344 |
'mercurial.defaultrc', |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47007
diff
changeset
|
1345 |
'mercurial.dirstateutils', |
43632
2e017696181f
help: create packages for the help text
Matt Harbison <matt_harbison@yahoo.com>
parents:
43349
diff
changeset
|
1346 |
'mercurial.helptext', |
2e017696181f
help: create packages for the help text
Matt Harbison <matt_harbison@yahoo.com>
parents:
43349
diff
changeset
|
1347 |
'mercurial.helptext.internals', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1348 |
'mercurial.hgweb', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1349 |
'mercurial.interfaces', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1350 |
'mercurial.pure', |
50426
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50408
diff
changeset
|
1351 |
'mercurial.stabletailgraph', |
45304
41ff8a463e10
packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents:
45270
diff
changeset
|
1352 |
'mercurial.templates', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1353 |
'mercurial.thirdparty', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1354 |
'mercurial.thirdparty.attr', |
50761
2c34c9b61a4f
thirdparty: vendor tomli
Raphaël Gomès <rgomes@octobus.net>
parents:
50733
diff
changeset
|
1355 |
'mercurial.thirdparty.tomli', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1356 |
'mercurial.thirdparty.zope', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1357 |
'mercurial.thirdparty.zope.interface', |
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45942
diff
changeset
|
1358 |
'mercurial.upgrade_utils', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1359 |
'mercurial.utils', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1360 |
'mercurial.revlogutils', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1361 |
'mercurial.testing', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1362 |
'hgext', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1363 |
'hgext.convert', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1364 |
'hgext.fsmonitor', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1365 |
'hgext.fastannotate', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1366 |
'hgext.fsmonitor.pywatchman', |
44477
ad718271a9eb
git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents:
44466
diff
changeset
|
1367 |
'hgext.git', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1368 |
'hgext.highlight', |
44413
4cabeea6d214
hgext: start building a library for simple hooks
Joerg Sonnenberger <joerg@bec.de>
parents:
44305
diff
changeset
|
1369 |
'hgext.hooklib', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1370 |
'hgext.largefiles', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1371 |
'hgext.lfs', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1372 |
'hgext.narrow', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1373 |
'hgext.remotefilelog', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1374 |
'hgext.zeroconf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1375 |
'hgext3rd', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1376 |
'hgdemandimport', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1377 |
] |
45304
41ff8a463e10
packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents:
45270
diff
changeset
|
1378 |
|
41ff8a463e10
packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents:
45270
diff
changeset
|
1379 |
for name in os.listdir(os.path.join('mercurial', 'templates')): |
41ff8a463e10
packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents:
45270
diff
changeset
|
1380 |
if name != '__pycache__' and os.path.isdir( |
41ff8a463e10
packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents:
45270
diff
changeset
|
1381 |
os.path.join('mercurial', 'templates', name) |
41ff8a463e10
packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents:
45270
diff
changeset
|
1382 |
): |
41ff8a463e10
packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents:
45270
diff
changeset
|
1383 |
packages.append('mercurial.templates.%s' % name) |
41ff8a463e10
packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents:
45270
diff
changeset
|
1384 |
|
42054
399ed3e86a49
py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents:
41954
diff
changeset
|
1385 |
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:
41954
diff
changeset
|
1386 |
# 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:
41954
diff
changeset
|
1387 |
# 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:
41954
diff
changeset
|
1388 |
# 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:
41954
diff
changeset
|
1389 |
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:
41954
diff
changeset
|
1390 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1391 |
common_depends = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1392 |
'mercurial/bitmanipulation.h', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1393 |
'mercurial/compat.h', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1394 |
'mercurial/cext/util.h', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1395 |
] |
32211
c48583859e04
policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents:
32125
diff
changeset
|
1396 |
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
|
1397 |
|
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1398 |
common_cflags = [] |
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1399 |
|
44605
960770add699
setup: relax -Werror for declaration-after-statement on Python 3.9
Augie Fackler <augie@google.com>
parents:
44588
diff
changeset
|
1400 |
# MSVC 2008 still needs declarations at the top of the scope, but Python 3.9 |
960770add699
setup: relax -Werror for declaration-after-statement on Python 3.9
Augie Fackler <augie@google.com>
parents:
44588
diff
changeset
|
1401 |
# makes declarations not at the top of a scope in the headers. |
960770add699
setup: relax -Werror for declaration-after-statement on Python 3.9
Augie Fackler <augie@google.com>
parents:
44588
diff
changeset
|
1402 |
if os.name != 'nt' and sys.version_info[1] < 9: |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1403 |
common_cflags = ['-Werror=declaration-after-statement'] |
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1404 |
|
30408
ce9a3033c118
setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents:
30346
diff
changeset
|
1405 |
osutil_cflags = [] |
25073
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
1406 |
osutil_ldflags = [] |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
1407 |
|
31561 | 1408 |
# platform specific macros |
31622
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31596
diff
changeset
|
1409 |
for plat, func in [('bsd', 'setproctitle')]: |
31561 | 1410 |
if re.search(plat, sys.platform) and hasfunction(new_compiler(), func): |
30408
ce9a3033c118
setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents:
30346
diff
changeset
|
1411 |
osutil_cflags.append('-DHAVE_%s' % func.upper()) |
ce9a3033c118
setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents:
30346
diff
changeset
|
1412 |
|
31596
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31562
diff
changeset
|
1413 |
for plat, macro, code in [ |
43076
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 |
'bsd|darwin', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1416 |
'BSD_STATFS', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1417 |
''' |
31596
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31562
diff
changeset
|
1418 |
#include <sys/param.h> |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31562
diff
changeset
|
1419 |
#include <sys/mount.h> |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31562
diff
changeset
|
1420 |
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
|
1421 |
''', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1422 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1423 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1424 |
'linux', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1425 |
'LINUX_STATFS', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1426 |
''' |
31622
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31596
diff
changeset
|
1427 |
#include <linux/magic.h> |
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31596
diff
changeset
|
1428 |
#include <sys/vfs.h> |
2243ba216f66
statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents:
31596
diff
changeset
|
1429 |
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
|
1430 |
''', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1431 |
), |
31596
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31562
diff
changeset
|
1432 |
]: |
ab51a2b18f87
setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents:
31562
diff
changeset
|
1433 |
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:
31562
diff
changeset
|
1434 |
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:
31562
diff
changeset
|
1435 |
|
25073
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
1436 |
if sys.platform == 'darwin': |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
1437 |
osutil_ldflags += ['-framework', 'ApplicationServices'] |
c1a9e31bec0f
setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents:
25072
diff
changeset
|
1438 |
|
44692
539490756a72
setup: link osutil.so to libsocket on Solaris/illumos (issue6299)
Alexander Pyhalov <apyhalov@gmail.com>
parents:
44603
diff
changeset
|
1439 |
if sys.platform == 'sunos5': |
539490756a72
setup: link osutil.so to libsocket on Solaris/illumos (issue6299)
Alexander Pyhalov <apyhalov@gmail.com>
parents:
44603
diff
changeset
|
1440 |
osutil_ldflags += ['-lsocket'] |
539490756a72
setup: link osutil.so to libsocket on Solaris/illumos (issue6299)
Alexander Pyhalov <apyhalov@gmail.com>
parents:
44603
diff
changeset
|
1441 |
|
36675 | 1442 |
xdiff_srcs = [ |
1443 |
'mercurial/thirdparty/xdiff/xdiffi.c', |
|
1444 |
'mercurial/thirdparty/xdiff/xprepare.c', |
|
1445 |
'mercurial/thirdparty/xdiff/xutils.c', |
|
1446 |
] |
|
1447 |
||
1448 |
xdiff_headers = [ |
|
1449 |
'mercurial/thirdparty/xdiff/xdiff.h', |
|
1450 |
'mercurial/thirdparty/xdiff/xdiffi.h', |
|
1451 |
'mercurial/thirdparty/xdiff/xinclude.h', |
|
1452 |
'mercurial/thirdparty/xdiff/xmacros.h', |
|
1453 |
'mercurial/thirdparty/xdiff/xprepare.h', |
|
1454 |
'mercurial/thirdparty/xdiff/xtypes.h', |
|
1455 |
'mercurial/thirdparty/xdiff/xutils.h', |
|
1456 |
] |
|
1457 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1458 |
|
40966
1eaf62a67c1a
rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents:
40859
diff
changeset
|
1459 |
class RustCompilationError(CCompilerError): |
1eaf62a67c1a
rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents:
40859
diff
changeset
|
1460 |
"""Exception class for Rust compilation errors.""" |
1eaf62a67c1a
rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents:
40859
diff
changeset
|
1461 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1462 |
|
40273
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1463 |
class RustExtension(Extension): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1464 |
"""Base classes for concrete Rust Extension classes.""" |
40273
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1465 |
|
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1466 |
rusttargetdir = os.path.join('rust', 'target', 'release') |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1467 |
|
48182
01c3dd208c75
rust: Make the hg-cpython crate default to Python 3
Simon Sapin <simon.sapin@octobus.net>
parents:
48180
diff
changeset
|
1468 |
def __init__(self, mpath, sources, rustlibname, subcrate, **kw): |
40273
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1469 |
Extension.__init__(self, mpath, sources, **kw) |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1470 |
srcdir = self.rustsrcdir = os.path.join('rust', subcrate) |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1471 |
|
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1472 |
# adding Rust source and control files to depends so that the extension |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1473 |
# gets rebuilt if they've changed |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1474 |
self.depends.append(os.path.join(srcdir, 'Cargo.toml')) |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1475 |
cargo_lock = os.path.join(srcdir, 'Cargo.lock') |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1476 |
if os.path.exists(cargo_lock): |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1477 |
self.depends.append(cargo_lock) |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1478 |
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
|
1479 |
self.depends.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1480 |
os.path.join(dirpath, fname) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1481 |
for fname in fnames |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1482 |
if os.path.splitext(fname)[1] == '.rs' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1483 |
) |
40273
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1484 |
|
42457
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1485 |
@staticmethod |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1486 |
def rustdylibsuffix(): |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1487 |
"""Return the suffix for shared libraries produced by rustc. |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1488 |
|
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1489 |
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:
42453
diff
changeset
|
1490 |
""" |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1491 |
if sys.platform == 'darwin': |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1492 |
return '.dylib' |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1493 |
elif os.name == 'nt': |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1494 |
return '.dll' |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1495 |
else: |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1496 |
return '.so' |
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1497 |
|
40273
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1498 |
def rustbuild(self): |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1499 |
env = os.environ.copy() |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1500 |
if 'HGTEST_RESTOREENV' in env: |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1501 |
# Mercurial tests change HOME to a temporary directory, |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1502 |
# but, if installed with rustup, the Rust toolchain needs |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1503 |
# HOME to be correct (otherwise the 'no default toolchain' |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1504 |
# error message is issued and the build fails). |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1505 |
# This happens currently with test-hghave.t, which does |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1506 |
# invoke this build. |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1507 |
|
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1508 |
# Unix only fix (os.path.expanduser not really reliable if |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1509 |
# HOME is shadowed like this) |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1510 |
import pwd |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1511 |
|
40273
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1512 |
env['HOME'] = pwd.getpwuid(os.getuid()).pw_dir |
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1513 |
|
44846
47787a48f469
setup: stop asking cargo to spam
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44742
diff
changeset
|
1514 |
cargocmd = ['cargo', 'rustc', '--release'] |
44305
d8d4fa9a7f18
rust-re2: add wrapper for calling Re2 from Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
44240
diff
changeset
|
1515 |
|
d8d4fa9a7f18
rust-re2: add wrapper for calling Re2 from Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
44240
diff
changeset
|
1516 |
rust_features = env.get("HG_RUST_FEATURES") |
d8d4fa9a7f18
rust-re2: add wrapper for calling Re2 from Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
44240
diff
changeset
|
1517 |
if rust_features: |
48842
649ff7f86f96
rust: enable Python 3 support unconditionally
Simon Sapin <simon.sapin@octobus.net>
parents:
48838
diff
changeset
|
1518 |
cargocmd.extend(('--features', rust_features)) |
44305
d8d4fa9a7f18
rust-re2: add wrapper for calling Re2 from Rust
Raphaël Gomès <rgomes@octobus.net>
parents:
44240
diff
changeset
|
1519 |
|
42459
85041e2b69c7
rust: switched to 'cargo rustc' in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents:
42458
diff
changeset
|
1520 |
cargocmd.append('--') |
42458
8ee0fdf3b087
rust-cpython: fix build for MacOSX
Georges Racinet <georges.racinet@octobus.net>
parents:
42457
diff
changeset
|
1521 |
if sys.platform == 'darwin': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1522 |
cargocmd.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1523 |
("-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1524 |
) |
40966
1eaf62a67c1a
rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents:
40859
diff
changeset
|
1525 |
try: |
1eaf62a67c1a
rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents:
40859
diff
changeset
|
1526 |
subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir) |
49310
050dc8730858
py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents:
49073
diff
changeset
|
1527 |
except FileNotFoundError: |
050dc8730858
py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents:
49073
diff
changeset
|
1528 |
raise RustCompilationError("Cargo not found") |
050dc8730858
py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents:
49073
diff
changeset
|
1529 |
except PermissionError: |
050dc8730858
py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents:
49073
diff
changeset
|
1530 |
raise RustCompilationError( |
050dc8730858
py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents:
49073
diff
changeset
|
1531 |
"Cargo found, but permission to execute it is denied" |
050dc8730858
py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents:
49073
diff
changeset
|
1532 |
) |
40966
1eaf62a67c1a
rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents:
40859
diff
changeset
|
1533 |
except subprocess.CalledProcessError: |
1eaf62a67c1a
rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents:
40859
diff
changeset
|
1534 |
raise RustCompilationError( |
1eaf62a67c1a
rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents:
40859
diff
changeset
|
1535 |
"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
|
1536 |
"command: %r, environment: %r" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1537 |
% (self.rustsrcdir, cargocmd, env) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1538 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1539 |
|
40273
3b275f549777
rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents:
40121
diff
changeset
|
1540 |
|
40967
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1541 |
class RustStandaloneExtension(RustExtension): |
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1542 |
def __init__(self, pydottedname, rustcrate, dylibname, **kw): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1543 |
RustExtension.__init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1544 |
self, pydottedname, [], dylibname, rustcrate, **kw |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1545 |
) |
40967
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1546 |
self.dylibname = dylibname |
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1547 |
|
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1548 |
def build(self, target_dir): |
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1549 |
self.rustbuild() |
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1550 |
target = [target_dir] |
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1551 |
target.extend(self.name.split('.')) |
42457
f4a65077e949
rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents:
42453
diff
changeset
|
1552 |
target[-1] += DYLIB_SUFFIX |
49957
ff4df0954742
setup: Ensure target directory exists with building rust extension
Cédric Krier <ced@b2ck.com>
parents:
49879
diff
changeset
|
1553 |
target = os.path.join(*target) |
ff4df0954742
setup: Ensure target directory exists with building rust extension
Cédric Krier <ced@b2ck.com>
parents:
49879
diff
changeset
|
1554 |
os.makedirs(os.path.dirname(target), exist_ok=True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1555 |
shutil.copy2( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1556 |
os.path.join( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1557 |
self.rusttargetdir, self.dylibname + self.rustdylibsuffix() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1558 |
), |
49957
ff4df0954742
setup: Ensure target directory exists with building rust extension
Cédric Krier <ced@b2ck.com>
parents:
49879
diff
changeset
|
1559 |
target, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1560 |
) |
40967
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1561 |
|
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1562 |
|
10000
16f49d671c7f
setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents:
9999
diff
changeset
|
1563 |
extmodules = [ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1564 |
Extension( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1565 |
'mercurial.cext.base85', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1566 |
['mercurial/cext/base85.c'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1567 |
include_dirs=common_include_dirs, |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1568 |
extra_compile_args=common_cflags, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1569 |
depends=common_depends, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1570 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1571 |
Extension( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1572 |
'mercurial.cext.bdiff', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1573 |
['mercurial/bdiff.c', 'mercurial/cext/bdiff.c'] + xdiff_srcs, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1574 |
include_dirs=common_include_dirs, |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1575 |
extra_compile_args=common_cflags, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1576 |
depends=common_depends + ['mercurial/bdiff.h'] + xdiff_headers, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1577 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1578 |
Extension( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1579 |
'mercurial.cext.mpatch', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1580 |
['mercurial/mpatch.c', 'mercurial/cext/mpatch.c'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1581 |
include_dirs=common_include_dirs, |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1582 |
extra_compile_args=common_cflags, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1583 |
depends=common_depends, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1584 |
), |
44466
79ac59d3f73d
setup-rust: remove the legacy 'direct-ffi' variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44452
diff
changeset
|
1585 |
Extension( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1586 |
'mercurial.cext.parsers', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1587 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1588 |
'mercurial/cext/charencode.c', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1589 |
'mercurial/cext/dirs.c', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1590 |
'mercurial/cext/manifest.c', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1591 |
'mercurial/cext/parsers.c', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1592 |
'mercurial/cext/pathencode.c', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1593 |
'mercurial/cext/revlog.c', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1594 |
], |
40967
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1595 |
include_dirs=common_include_dirs, |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1596 |
extra_compile_args=common_cflags, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1597 |
depends=common_depends |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1598 |
+ [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1599 |
'mercurial/cext/charencode.h', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1600 |
'mercurial/cext/revlog.h', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1601 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1602 |
), |
37180
922b3fae9c7d
setup: register zope.interface packages and compile C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37130
diff
changeset
|
1603 |
Extension( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1604 |
'mercurial.cext.osutil', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1605 |
['mercurial/cext/osutil.c'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1606 |
include_dirs=common_include_dirs, |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1607 |
extra_compile_args=common_cflags + osutil_cflags, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1608 |
extra_link_args=osutil_ldflags, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1609 |
depends=common_depends, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1610 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1611 |
Extension( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1612 |
'mercurial.thirdparty.zope.interface._zope_interface_coptimizations', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1613 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1614 |
'mercurial/thirdparty/zope/interface/_zope_interface_coptimizations.c', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1615 |
], |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1616 |
extra_compile_args=common_cflags, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1617 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1618 |
Extension( |
44058
bde1cd4c99d9
sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents:
44026
diff
changeset
|
1619 |
'mercurial.thirdparty.sha1dc', |
bde1cd4c99d9
sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents:
44026
diff
changeset
|
1620 |
[ |
bde1cd4c99d9
sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents:
44026
diff
changeset
|
1621 |
'mercurial/thirdparty/sha1dc/cext.c', |
bde1cd4c99d9
sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents:
44026
diff
changeset
|
1622 |
'mercurial/thirdparty/sha1dc/lib/sha1.c', |
bde1cd4c99d9
sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents:
44026
diff
changeset
|
1623 |
'mercurial/thirdparty/sha1dc/lib/ubc_check.c', |
bde1cd4c99d9
sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents:
44026
diff
changeset
|
1624 |
], |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1625 |
extra_compile_args=common_cflags, |
44058
bde1cd4c99d9
sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents:
44026
diff
changeset
|
1626 |
), |
bde1cd4c99d9
sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents:
44026
diff
changeset
|
1627 |
Extension( |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1628 |
'hgext.fsmonitor.pywatchman.bser', |
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1629 |
['hgext/fsmonitor/pywatchman/bser.c'], |
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1630 |
extra_compile_args=common_cflags, |
43076
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 |
RustStandaloneExtension( |
48182
01c3dd208c75
rust: Make the hg-cpython crate default to Python 3
Simon Sapin <simon.sapin@octobus.net>
parents:
48180
diff
changeset
|
1633 |
'mercurial.rustext', |
01c3dd208c75
rust: Make the hg-cpython crate default to Python 3
Simon Sapin <simon.sapin@octobus.net>
parents:
48180
diff
changeset
|
1634 |
'hg-cpython', |
01c3dd208c75
rust: Make the hg-cpython crate default to Python 3
Simon Sapin <simon.sapin@octobus.net>
parents:
48180
diff
changeset
|
1635 |
'librusthg', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1636 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1637 |
] |
5396
5105b119edd2
Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5197
diff
changeset
|
1638 |
|
40967
462a26756f70
rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents:
40966
diff
changeset
|
1639 |
|
30436
788ea4ac4388
setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30408
diff
changeset
|
1640 |
sys.path.insert(0, 'contrib/python-zstandard') |
788ea4ac4388
setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30408
diff
changeset
|
1641 |
import setup_zstd |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1642 |
|
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1643 |
zstd = setup_zstd.get_c_extension( |
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1644 |
name='mercurial.zstd', root=os.path.abspath(os.path.dirname(__file__)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1645 |
) |
44588
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1646 |
zstd.extra_compile_args += common_cflags |
2a98b0cd4995
setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
44487
diff
changeset
|
1647 |
extmodules.append(zstd) |
30436
788ea4ac4388
setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30408
diff
changeset
|
1648 |
|
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
1649 |
try: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
1650 |
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
|
1651 |
|
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
1652 |
# the -mno-cygwin option has been deprecated for years |
33669
7686cbb0ba41
setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents:
33600
diff
changeset
|
1653 |
mingw32compilerclass = cygwinccompiler.Mingw32CCompiler |
17121
d13f47c800fd
setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents:
17061
diff
changeset
|
1654 |
|
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
1655 |
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
|
1656 |
def __init__(self, *args, **kwargs): |
33669
7686cbb0ba41
setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents:
33600
diff
changeset
|
1657 |
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
|
1658 |
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
|
1659 |
try: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
1660 |
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
|
1661 |
except ValueError: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
1662 |
pass |
17121
d13f47c800fd
setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents:
17061
diff
changeset
|
1663 |
|
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
1664 |
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
|
1665 |
except ImportError: |
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
1666 |
# 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
|
1667 |
# 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
|
1668 |
# DiskStation boxes |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48850
diff
changeset
|
1669 |
class HackedMingw32CCompiler: |
23677
6bc1702e7333
setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents:
23647
diff
changeset
|
1670 |
pass |
17121
d13f47c800fd
setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents:
17061
diff
changeset
|
1671 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1672 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1673 |
packagedata = { |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1674 |
'mercurial': [ |
50762
c51b178b0b7e
configitems: declare items in a TOML file
Raphaël Gomès <rgomes@octobus.net>
parents:
50761
diff
changeset
|
1675 |
'configitems.toml', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1676 |
'locale/*/LC_MESSAGES/hg.mo', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1677 |
'dummycert.pem', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1678 |
], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1679 |
'mercurial.defaultrc': [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1680 |
'*.rc', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1681 |
], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1682 |
'mercurial.helptext': [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1683 |
'*.txt', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1684 |
], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1685 |
'mercurial.helptext.internals': [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1686 |
'*.txt', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45939
diff
changeset
|
1687 |
], |
49655
54421ef8a423
setup: include vendored 3rd party type stubs
Matt Harbison <matt_harbison@yahoo.com>
parents:
49396
diff
changeset
|
1688 |
'mercurial.thirdparty.attr': [ |
54421ef8a423
setup: include vendored 3rd party type stubs
Matt Harbison <matt_harbison@yahoo.com>
parents:
49396
diff
changeset
|
1689 |
'*.pyi', |
54421ef8a423
setup: include vendored 3rd party type stubs
Matt Harbison <matt_harbison@yahoo.com>
parents:
49396
diff
changeset
|
1690 |
'py.typed', |
54421ef8a423
setup: include vendored 3rd party type stubs
Matt Harbison <matt_harbison@yahoo.com>
parents:
49396
diff
changeset
|
1691 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1692 |
} |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1693 |
|
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
1694 |
|
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
1695 |
def ordinarypath(p): |
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
1696 |
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
|
1697 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1698 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1699 |
for root in ('templates',): |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
1700 |
for curdir, dirs, files in os.walk(os.path.join('mercurial', root)): |
45305
e2320bb7a99f
packaging: include templates with their package as key in package_data
Martin von Zweigbergk <martinvonz@google.com>
parents:
45304
diff
changeset
|
1701 |
packagename = curdir.replace(os.sep, '.') |
e2320bb7a99f
packaging: include templates with their package as key in package_data
Martin von Zweigbergk <martinvonz@google.com>
parents:
45304
diff
changeset
|
1702 |
packagedata[packagename] = list(filter(ordinarypath, files)) |
9999
f91e5630ce7e
setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9998
diff
changeset
|
1703 |
|
7648
02e358a3a8a7
i18n: let Makefile generate i18n/hg.pot
Martin Geisler <mg@daimi.au.dk>
parents:
7647
diff
changeset
|
1704 |
datafiles = [] |
31316
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31308
diff
changeset
|
1705 |
|
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31308
diff
changeset
|
1706 |
# distutils expects version to be str/unicode. Converting it to |
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31308
diff
changeset
|
1707 |
# 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:
31308
diff
changeset
|
1708 |
# non-ascii bytes and will be implicitly converted back to bytes |
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31308
diff
changeset
|
1709 |
# when operated on. |
46512
866eb4d6bd9f
build: fake PEP440 versions
Joerg Sonnenberger <joerg@bec.de>
parents:
46414
diff
changeset
|
1710 |
assert isinstance(version, str) |
866eb4d6bd9f
build: fake PEP440 versions
Joerg Sonnenberger <joerg@bec.de>
parents:
46414
diff
changeset
|
1711 |
setupversion = version |
31316
70bc35df3e54
setup: convert setupversion to unicode
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31308
diff
changeset
|
1712 |
|
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
1713 |
extra = {} |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
1714 |
|
41851
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1715 |
py2exepackages = [ |
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1716 |
'hgdemandimport', |
41918
5d9fdc9b0178
setup: include hgext3rd package in py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41917
diff
changeset
|
1717 |
'hgext3rd', |
41851
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1718 |
'hgext', |
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1719 |
'email', |
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1720 |
# implicitly imported per module policy |
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1721 |
# (cffi wouldn't be used as a frozen exe) |
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1722 |
'mercurial.cext', |
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1723 |
#'mercurial.cffi', |
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1724 |
'mercurial.pure', |
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1725 |
] |
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1726 |
|
46363
d6cfe45afb18
packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents:
46315
diff
changeset
|
1727 |
py2exe_includes = [] |
d6cfe45afb18
packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents:
46315
diff
changeset
|
1728 |
|
41916
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1729 |
py2exeexcludes = [] |
41954
e5ac701e5b7c
setup: exclude crypt32.dll in py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41953
diff
changeset
|
1730 |
py2exedllexcludes = ['crypt32.dll'] |
41916
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1731 |
|
33600
47829b89c8c6
setup: silence warning of unknown option python_requires on distutils
Yuya Nishihara <yuya@tcha.org>
parents:
33599
diff
changeset
|
1732 |
if issetuptools: |
47829b89c8c6
setup: silence warning of unknown option python_requires on distutils
Yuya Nishihara <yuya@tcha.org>
parents:
33599
diff
changeset
|
1733 |
extra['python_requires'] = supportedpy |
41851
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1734 |
|
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
1735 |
if py2exeloaded: |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
1736 |
extra['console'] = [ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1737 |
{ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1738 |
'script': 'hg', |
51668
45ba8416afc4
copyright: update to 2024
Anton Shestakov <av6@dwimlabs.net>
parents:
51631
diff
changeset
|
1739 |
'copyright': 'Copyright (C) 2005-2024 Olivia Mackall and others', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1740 |
'product_version': version, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1741 |
} |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1742 |
] |
41917
ac32e04e887f
setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41916
diff
changeset
|
1743 |
# 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:
41916
diff
changeset
|
1744 |
# 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:
41916
diff
changeset
|
1745 |
# build.sub_commands. |
ac32e04e887f
setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41916
diff
changeset
|
1746 |
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
|
1747 |
# 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
|
1748 |
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
|
1749 |
|
41916
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1750 |
# We allow some configuration to be supplemented via environment |
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1751 |
# 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:
41854
diff
changeset
|
1752 |
# supplementing configs instead of replacing them. |
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1753 |
extrapackages = os.environ.get('HG_PY2EXE_EXTRA_PACKAGES') |
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1754 |
if extrapackages: |
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1755 |
py2exepackages.extend(extrapackages.split(' ')) |
41851
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1756 |
|
46363
d6cfe45afb18
packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents:
46315
diff
changeset
|
1757 |
extra_includes = os.environ.get('HG_PY2EXE_EXTRA_INCLUDES') |
d6cfe45afb18
packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents:
46315
diff
changeset
|
1758 |
if extra_includes: |
d6cfe45afb18
packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents:
46315
diff
changeset
|
1759 |
py2exe_includes.extend(extra_includes.split(' ')) |
d6cfe45afb18
packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents:
46315
diff
changeset
|
1760 |
|
41916
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1761 |
excludes = os.environ.get('HG_PY2EXE_EXTRA_EXCLUDES') |
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1762 |
if excludes: |
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1763 |
py2exeexcludes.extend(excludes.split(' ')) |
41851
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1764 |
|
41916
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1765 |
dllexcludes = os.environ.get('HG_PY2EXE_EXTRA_DLL_EXCLUDES') |
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1766 |
if dllexcludes: |
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41854
diff
changeset
|
1767 |
py2exedllexcludes.extend(dllexcludes.split(' ')) |
41851
ed35057421ae
setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41850
diff
changeset
|
1768 |
|
45132
9d532329ee97
extensions: make `hg help extensions` list disabled extensions with PyOxidizer
Martin von Zweigbergk <martinvonz@google.com>
parents:
44893
diff
changeset
|
1769 |
if os.environ.get('PYOXIDIZER'): |
9d532329ee97
extensions: make `hg help extensions` list disabled extensions with PyOxidizer
Martin von Zweigbergk <martinvonz@google.com>
parents:
44893
diff
changeset
|
1770 |
hgbuild.sub_commands.insert(0, ('build_hgextindex', None)) |
9d532329ee97
extensions: make `hg help extensions` list disabled extensions with PyOxidizer
Martin von Zweigbergk <martinvonz@google.com>
parents:
44893
diff
changeset
|
1771 |
|
10400
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
1772 |
if os.name == 'nt': |
fb203201ce30
setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents:
10282
diff
changeset
|
1773 |
# 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
|
1774 |
# 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
|
1775 |
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
|
1776 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1777 |
setup( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1778 |
version=setupversion, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1779 |
long_description=( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1780 |
'Mercurial is a distributed SCM tool written in Python.' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1781 |
' 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
|
1782 |
' fast, reliable distributed revision control, such as ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1783 |
'Mozilla.' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1784 |
), |
51981
d07034819565
install: add long_description_content_type
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents:
51901
diff
changeset
|
1785 |
long_description_content_type='text/x-rst', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1786 |
scripts=scripts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1787 |
packages=packages, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1788 |
ext_modules=extmodules, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1789 |
data_files=datafiles, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1790 |
package_data=packagedata, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1791 |
cmdclass=cmdclass, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1792 |
distclass=hgdist, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1793 |
options={ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1794 |
'py2exe': { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1795 |
'bundle_files': 3, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1796 |
'dll_excludes': py2exedllexcludes, |
46363
d6cfe45afb18
packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents:
46315
diff
changeset
|
1797 |
'includes': py2exe_includes, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1798 |
'excludes': py2exeexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1799 |
'packages': py2exepackages, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1800 |
}, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1801 |
'bdist_mpkg': { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1802 |
'zipdist': False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1803 |
'license': 'COPYING', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1804 |
'readme': 'contrib/packaging/macosx/Readme.html', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1805 |
'welcome': 'contrib/packaging/macosx/Welcome.html', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1806 |
}, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1807 |
}, |
51160
3c5b66d03c37
setup: make debug simpler by adding a `__repr__` to `hgcommand`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50987
diff
changeset
|
1808 |
**extra, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43044
diff
changeset
|
1809 |
) |