annotate setup.py @ 53039:46603c00a9f2 stable

stream: audit path on encoded path In 5b8f6e198a6e, we wrongly called `vfs._auditpath` on the pre-encoding path, so we would get abort on problem that the encoding is here to handle. So we fix the problem (easily) and update the test to cover this (with significantly more work). Thanks to Matt Harbison for spotting this during the freeze.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 11 Mar 2025 10:37:39 +0100
parents e2c239dae5a2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
575
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
1 # This is the mercurial setup script.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
2
52356
dd8e7d4fe8c3 setup_py: imports standard lib at the top
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52355
diff changeset
3 import ctypes
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
4 import logging
33591
ee11d18fcd3c setup: fix mistake that prevented Python 3 from being excluded
Augie Fackler <augie@google.com>
parents: 33589
diff changeset
5 import os
52356
dd8e7d4fe8c3 setup_py: imports standard lib at the top
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52355
diff changeset
6 import re
dd8e7d4fe8c3 setup_py: imports standard lib at the top
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52355
diff changeset
7 import shutil
44933
4c53c12b92d5 setup: require a Python version with modern SSL features
Manuel Jacob <me@manueljacob.de>
parents: 44911
diff changeset
8 import ssl
52356
dd8e7d4fe8c3 setup_py: imports standard lib at the top
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52355
diff changeset
9 import stat
dd8e7d4fe8c3 setup_py: imports standard lib at the top
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52355
diff changeset
10 import subprocess
52350
737e169b8948 setup_py: first tiny cleanup
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52348
diff changeset
11 import sys
42473
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
12 import sysconfig
52356
dd8e7d4fe8c3 setup_py: imports standard lib at the top
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52355
diff changeset
13 import tempfile
44933
4c53c12b92d5 setup: require a Python version with modern SSL features
Manuel Jacob <me@manueljacob.de>
parents: 44911
diff changeset
14
52352
5d81f4b7e024 setup_py: simplify ssl check
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52351
diff changeset
15 if not ssl.HAS_TLSv1_2:
44952
95c832849955 setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents: 44933
diff changeset
16 error = """
52348
a820a7a1fce0 setup: require TLS 1.2 support from the Python interpreter (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents: 52213
diff changeset
17 The `ssl` module does not advertise support for TLS 1.2.
44952
95c832849955 setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents: 44933
diff changeset
18 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: 44933
diff changeset
19 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: 44933
diff changeset
20 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: 44933
diff changeset
21 """
48918
1371c18e467d setup: remove printf trampoline
Augie Fackler <augie@google.com>
parents: 48917
diff changeset
22 print(error, file=sys.stderr)
44952
95c832849955 setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents: 44933
diff changeset
23 sys.exit(1)
95c832849955 setup: require that Python has TLS 1.1 or TLS 1.2
Manuel Jacob <me@manueljacob.de>
parents: 44933
diff changeset
24
48921
3491c450dcae setup: remove Python 2 support code for determining dylib suffix
Augie Fackler <augie@google.com>
parents: 48920
diff changeset
25 DYLIB_SUFFIX = sysconfig.get_config_vars()['EXT_SUFFIX']
42473
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
26
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
27 # Solaris Python packaging brain damage
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
28 try:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
29 import hashlib
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
30
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
31 sha = hashlib.sha1()
16688
cfb6682961b8 cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 16683
diff changeset
32 except ImportError:
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
33 try:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
34 import sha
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
35
52355
ad23dc96e7d6 setup_py: simpler silence warnings unused-import
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52354
diff changeset
36 del sha # silence unused import warning
16688
cfb6682961b8 cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 16683
diff changeset
37 except ImportError:
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
38 raise SystemExit(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
39 "Couldn't import standard hashlib (incomplete Python install)."
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
40 )
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
41
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
42 try:
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
43 import zlib
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
44
52355
ad23dc96e7d6 setup_py: simpler silence warnings unused-import
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52354
diff changeset
45 del zlib # silence unused import warning
16688
cfb6682961b8 cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 16683
diff changeset
46 except ImportError:
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
47 raise SystemExit(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
48 "Couldn't import standard zlib (incomplete Python install)."
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
49 )
7558
dc211ad8d681 setup: warn about missing standard Python components
Matt Mackall <mpm@selenic.com>
parents: 7081
diff changeset
50
10761
16a13fdb4b36 setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10521
diff changeset
51 try:
52353
7606466300c1 setup_py: remove IronPython Python 2.7 specific code
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52352
diff changeset
52 import bz2
14295
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
53
52355
ad23dc96e7d6 setup_py: simpler silence warnings unused-import
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52354
diff changeset
54 del bz2 # silence unused import warning
52353
7606466300c1 setup_py: remove IronPython Python 2.7 specific code
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52352
diff changeset
55 except ImportError:
7606466300c1 setup_py: remove IronPython Python 2.7 specific code
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52352
diff changeset
56 raise SystemExit(
7606466300c1 setup_py: remove IronPython Python 2.7 specific code
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52352
diff changeset
57 "Couldn't import standard bz2 (incomplete Python install)."
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
58 )
14295
bb7e3b3e6e11 setup.py: workaround for missing bz2 module in IronPython
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents: 14243
diff changeset
59
52689
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
60 from setuptools import setup, Command, Extension, Distribution
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
61 from setuptools.command.build import build
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
62 from setuptools.command.build_ext import build_ext
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
63 from setuptools.command.build_py import build_py
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
64 from setuptools.command.install import install
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
65 from setuptools.command.install_lib import install_lib
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
66
52689
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
67 from setuptools.errors import (
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
68 CCompilerError,
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
69 BaseError as DistutilsError,
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
70 ExecError as DistutilsExecError,
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
71 )
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
72
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
73 # no setuptools.command.build_scripts
27268
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
74 from distutils.command.build_scripts import build_scripts
52689
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
75
51887
4dc1fc2b2f3a setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents: 51886
diff changeset
76 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
77 from distutils import file_util
49958
dd804d83822c setup: drop legacy osx compiler tuning to enable universal builds
Matt Harbison <matt_harbison@yahoo.com>
parents: 49927
diff changeset
78 from distutils.sysconfig import get_python_inc
52689
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
79 from distutils.ccompiler import new_compiler
10761
16a13fdb4b36 setup: fail if bz2 is not available
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 10521
diff changeset
80
52702
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
81 # raise an explicit error if setuptools_scm is not importable
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
82 try:
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
83 import setuptools_scm
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
84 except ImportError:
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
85 raise SystemExit(
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
86 "Couldn't import setuptools_scm (direct call of setup.py?)."
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
87 )
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
88 else:
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
89 del setuptools_scm
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
90
9ec635cc0a29 setup: check that setuptools_scm is importable
Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52697
diff changeset
91
24192
390410a6545d setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents: 24191
diff changeset
92 ispypy = "PyPy" in sys.version
390410a6545d setup.py: do not install c extensions on pypy
Joan Massich <mailsik@gmail.com>
parents: 24191
diff changeset
93
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
94
52354
fcc059b1eed0 setup_py: function defs after imports
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52353
diff changeset
95 def sysstr(s):
fcc059b1eed0 setup_py: function defs after imports
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52353
diff changeset
96 return s.decode('latin-1')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
97
52354
fcc059b1eed0 setup_py: function defs after imports
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52353
diff changeset
98
fcc059b1eed0 setup_py: function defs after imports
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52353
diff changeset
99 def eprint(*args, **kwargs):
fcc059b1eed0 setup_py: function defs after imports
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52353
diff changeset
100 kwargs['file'] = sys.stderr
fcc059b1eed0 setup_py: function defs after imports
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52353
diff changeset
101 print(*args, **kwargs)
40420
b6bc2293cdf3 setup: explain to distutils how we write rc versions
"Paul Morelle <paul.morelle@octobus.net"
parents: 40397
diff changeset
102
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
103
35238
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
104 def write_if_changed(path, content):
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
105 """Write content to a file iff the content hasn't changed."""
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
106 if os.path.exists(path):
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
107 with open(path, 'rb') as fh:
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
108 current = fh.read()
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
109 else:
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
110 current = b''
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
111
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
112 if current != content:
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
113 with open(path, 'wb') as fh:
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
114 fh.write(content)
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
115
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
116
6513
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
117 scripts = ['hg']
66e87c11447d Add a batch file driver for Windows
Paul Moore <p.f.moore@gmail.com>
parents: 6389
diff changeset
118 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
119 # 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
120 scripts.append('contrib/win32/hg.bat')
3893
070628929e1f Fix setup.py warning
Matt Mackall <mpm@selenic.com>
parents: 3892
diff changeset
121
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
122
31565
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
123 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
124 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
52357
40f649592ba9 setup_py: simplify cancompile with 'with open(...)'
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52356
diff changeset
125 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
126 try:
31565
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
127 fname = os.path.join(tmpdir, 'testcomp.c')
52357
40f649592ba9 setup_py: simplify cancompile with 'with open(...)'
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52356
diff changeset
128 with open(fname, 'w') as file:
40f649592ba9 setup_py: simplify cancompile with 'with open(...)'
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52356
diff changeset
129 file.write(code)
40f649592ba9 setup_py: simplify cancompile with 'with open(...)'
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52356
diff changeset
130 oldstderr = os.dup(sys.stderr.fileno())
25089
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
131 # 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
132 # from the compiler.
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
133 # 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
134 # for a function on Windows.
52357
40f649592ba9 setup_py: simplify cancompile with 'with open(...)'
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52356
diff changeset
135 with open('/dev/null', 'w') as devnull:
40f649592ba9 setup_py: simplify cancompile with 'with open(...)'
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52356
diff changeset
136 os.dup2(devnull.fileno(), sys.stderr.fileno())
25089
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
137 objects = cc.compile([fname], output_dir=tmpdir)
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
138 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
139 return True
25089
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
140 except Exception:
c6427cd45760 setup: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 25074
diff changeset
141 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
142 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
143 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
144 os.dup2(oldstderr, sys.stderr.fileno())
6251
87053f0b0fad setup.py: use a simplified custom version of CCompiler.has_function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6245
diff changeset
145 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
146
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
147
31565
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
148 # simplified version of distutils.ccompiler.CCompiler.has_function
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
149 # that actually removes its temporary files.
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
150 def hasfunction(cc, funcname):
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
151 code = 'int main(void) { %s(); }\n' % funcname
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
152 return cancompile(cc, code)
9639ff4a93ae setup: split "hasfunction" to test arbitrary code
Jun Wu <quark@fb.com>
parents: 31325
diff changeset
153
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
154
31566
5a0460219649 setup: add a function to test header files
Jun Wu <quark@fb.com>
parents: 31565
diff changeset
155 def hasheader(cc, headername):
5a0460219649 setup: add a function to test header files
Jun Wu <quark@fb.com>
parents: 31565
diff changeset
156 code = '#include <%s>\nint main(void) { return 0; }\n' % headername
5a0460219649 setup: add a function to test header files
Jun Wu <quark@fb.com>
parents: 31565
diff changeset
157 return cancompile(cc, code)
5a0460219649 setup: add a function to test header files
Jun Wu <quark@fb.com>
parents: 31565
diff changeset
158
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
159
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
160 # py2exe needs to be installed to work
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
161 try:
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
162 import py2exe
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
163
49128
97f2554cb647 setup: fix the py2exe logic to work with py3
Matt Harbison <matt_harbison@yahoo.com>
parents: 49103
diff changeset
164 py2exe.patch_distutils()
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
165 py2exeloaded = True
15527
9926aab3d0b5 setup: fix py2exe generation broken by c3a6ec304055 (issue3116)
Pascal Quantin <pascal.quantin@gmail.com>
parents: 15523
diff changeset
166 # 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
167 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
168 except ImportError:
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
169 py2exeloaded = False
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
170
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
171
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
172 def runcmd(cmd, env, cwd=None):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
173 p = subprocess.Popen(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
174 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
175 )
32904
19b0fd4b5570 plan9: drop py26 hacks
Matt Harbison <matt_harbison@yahoo.com>
parents: 32802
diff changeset
176 out, err = p.communicate()
33123
87ee783f7299 setup: update runcmd() to also return the exit status
Adam Simpkins <simpkins@fb.com>
parents: 33122
diff changeset
177 return p.returncode, out, err
13636
4bfff063aed6 setup: fix mac build broken by e42d18538e1d
Jon M. Dugan <jdugan@x1024.net>
parents: 13594
diff changeset
178
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
179
49037
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48941
diff changeset
180 class hgcommand:
33126
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
181 def __init__(self, cmd, env):
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
182 self.cmd = cmd
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
183 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
184
51191
3c5b66d03c37 setup: make debug simpler by adding a `__repr__` to `hgcommand`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50995
diff changeset
185 def __repr__(self):
3c5b66d03c37 setup: make debug simpler by adding a `__repr__` to `hgcommand`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50995
diff changeset
186 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: 50995
diff changeset
187
33125
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
188 def run(self, args):
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
189 cmd = self.cmd + args
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
190 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
191 err = filterhgerr(err)
49650
ac93876ea2df setup: treat error output and non-zero return code differently
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49649
diff changeset
192 if err:
48918
1371c18e467d setup: remove printf trampoline
Augie Fackler <augie@google.com>
parents: 48917
diff changeset
193 print("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr)
1371c18e467d setup: remove printf trampoline
Augie Fackler <augie@google.com>
parents: 48917
diff changeset
194 print(err, file=sys.stderr)
49650
ac93876ea2df setup: treat error output and non-zero return code differently
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49649
diff changeset
195 if returncode != 0:
51471
ee132657647d setup: display return code information about failed `hg` call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51192
diff changeset
196 print(
ee132657647d setup: display return code information about failed `hg` call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51192
diff changeset
197 "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: 51192
diff changeset
198 file=sys.stderr,
ee132657647d setup: display return code information about failed `hg` call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51192
diff changeset
199 )
44214
bda050bc9987 py3: make setup.py's hgcommand() consistently return bytes
Martin von Zweigbergk <martinvonz@google.com>
parents: 44189
diff changeset
200 return b''
33125
fc290a39590d setup: replace runhg() with an hgcommand helper class
Adam Simpkins <simpkins@fb.com>
parents: 33124
diff changeset
201 return out
8548
3ccbe42ff72f setup: read .hg_archival.txt for version info (issue1670)
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents: 8547
diff changeset
202
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
203
33598
f30714a55523 setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents: 33591
diff changeset
204 def filterhgerr(err):
f30714a55523 setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents: 33591
diff changeset
205 # 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
206 # 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
207 # 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
208 # 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
209 # 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
210 err = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
211 e
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
212 for e in err.splitlines()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
213 if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
214 not e.startswith(b'not trusting file')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
215 and not e.startswith(b'warning: Not importing')
51639
bf1d26bd5b6a obsolete: quote the feature name
Joerg Sonnenberger <joerg@bec.de>
parents: 51471
diff changeset
216 and not (
bf1d26bd5b6a obsolete: quote the feature name
Joerg Sonnenberger <joerg@bec.de>
parents: 51471
diff changeset
217 e.startswith(b'obsolete feature not enabled')
bf1d26bd5b6a obsolete: quote the feature name
Joerg Sonnenberger <joerg@bec.de>
parents: 51471
diff changeset
218 or e.startswith(b'"obsolete" feature not enabled')
bf1d26bd5b6a obsolete: quote the feature name
Joerg Sonnenberger <joerg@bec.de>
parents: 51471
diff changeset
219 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
220 and not e.startswith(b'*** failed to import extension')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
221 and not e.startswith(b'devel-warn:')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
222 and not (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
223 e.startswith(b'(third party extension')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
224 and e.endswith(b'or newer of Mercurial; disabling)')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
225 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
226 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
227 ]
33598
f30714a55523 setup: do not select hg executable that prints unexpected warnings
Yuya Nishihara <yuya@tcha.org>
parents: 33591
diff changeset
228 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
229
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
230
51192
f816ca29a285 setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51191
diff changeset
231 def localhgenv(pure_python=True):
33126
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
232 """Get an environment dictionary to use for invoking or importing
8b20338b989e setup: prefer using the system hg to interact with the local repository
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
233 mercurial from the local repository."""
33124
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
234 # Execute hg out of this directory with a custom environment which takes
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
235 # 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
236 env = {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
237 'HGRCPATH': '',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
238 'LANGUAGE': 'C',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
239 'PATH': '',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
240 } # make pypi modules that use os.environ['PATH'] happy
51192
f816ca29a285 setup: try a non-pure version of the local Mercurial if the pure fails
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51191
diff changeset
241 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: 51191
diff changeset
242 env['HGMODULEPOLICY'] = 'py'
33124
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
243 if 'LD_LIBRARY_PATH' in os.environ:
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
244 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
245 if 'SystemRoot' in os.environ:
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
246 # SystemRoot is required by Windows to load various DLLs. See:
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
247 # https://bugs.python.org/issue13524#msg148850
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
248 env['SystemRoot'] = os.environ['SystemRoot']
33129
6ef5f0c95d64 setup: fix localhgenv
Jun Wu <quark@fb.com>
parents: 33126
diff changeset
249 return env
33124
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
250
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
251
33124
155d760da7b2 setup: move environment computation into a helper function
Adam Simpkins <simpkins@fb.com>
parents: 33123
diff changeset
252 version = ''
15367
b357a972d6cd setup: set env global earlier (3073)
Matt Mackall <mpm@selenic.com>
parents: 15215
diff changeset
253
49656
010a1e73f69e setup: further improve the error path for version retrieval
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49650
diff changeset
254
15460
f9f0731dbc56 setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents: 15459
diff changeset
255 class hgbuild(build):
f9f0731dbc56 setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents: 15459
diff changeset
256 # 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
257 # when build_py is run next.
28398
712298942c82 setup: remove support for 2to3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28041
diff changeset
258 sub_commands = [('build_mo', None)] + build.sub_commands
15460
f9f0731dbc56 setup: subclass build command
Simon Heimberg <simohe@besonet.ch>
parents: 15459
diff changeset
259
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
260
15523
f9da84a950d0 setup: backout 8504699d1aa6
Matt Mackall <mpm@selenic.com>
parents: 15500
diff changeset
261 class hgbuildmo(build):
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
262 description = "build translations (.mo files)"
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
263
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
264 def run(self):
52164
2c4283c9fa93 setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52033
diff changeset
265 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: 52033
diff changeset
266 if (
2c4283c9fa93 setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52033
diff changeset
267 not result
2c4283c9fa93 setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52033
diff changeset
268 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: 52033
diff changeset
269 ):
2c4283c9fa93 setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52033
diff changeset
270 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: 52033
diff changeset
271
2c4283c9fa93 setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52033
diff changeset
272 def _run(self):
51887
4dc1fc2b2f3a setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents: 51886
diff changeset
273 try:
4dc1fc2b2f3a setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents: 51886
diff changeset
274 from shutil import which as find_executable
4dc1fc2b2f3a setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents: 51886
diff changeset
275 except ImportError:
4dc1fc2b2f3a setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents: 51886
diff changeset
276 # Deprecated in py3.12
4dc1fc2b2f3a setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents: 51886
diff changeset
277 from distutils.spawn import find_executable
4dc1fc2b2f3a setup: avoid the deprecated `distutils.spawn.find_executable`
Matt Harbison <mharbison@atto.com>
parents: 51886
diff changeset
278
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
279 if not find_executable('msgfmt'):
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
280 logging.warning(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
281 "could not find msgfmt executable, no translations "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
282 "will be built"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
283 )
52164
2c4283c9fa93 setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52033
diff changeset
284 return False
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
285
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
286 podir = 'i18n'
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
287 if not os.path.isdir(podir):
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
288 logging.warning("could not find %s/ directory", podir)
52164
2c4283c9fa93 setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52033
diff changeset
289 return False
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
290
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
291 join = os.path.join
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
292 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
293 if not po.endswith('.po'):
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
294 continue
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
295 pofile = join(podir, po)
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
296 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
297 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
298 mobuildfile = join('mercurial', mofile)
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
299 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
300 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
301 # 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
302 cmd.append('-c')
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
303 self.mkpath(join('mercurial', modir))
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
304 self.make_file([pofile], mobuildfile, spawn, (cmd,))
52164
2c4283c9fa93 setup: add a way to force the setup to translate (or fail)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52033
diff changeset
305 return True
7649
a489e3a94443 i18n: new build_mo command for setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7648
diff changeset
306
12661
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 12649
diff changeset
307
15458
c3a6ec304055 setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents: 15388
diff changeset
308 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
309 pure = False
44499
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
310 rust = False
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
311 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
312 cffi = ispypy
15458
c3a6ec304055 setup: subclass distribution instead of overwriting original
Simon Heimberg <simohe@besonet.ch>
parents: 15388
diff changeset
313
41768
aaad36b88298 cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents: 41547
diff changeset
314 global_options = Distribution.global_options + [
aaad36b88298 cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents: 41547
diff changeset
315 ('pure', None, "use pure (slow) Python code instead of C extensions"),
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
316 ('rust', None, "use Rust extensions additionally to C extensions"),
44499
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
317 (
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
318 'no-rust',
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
319 None,
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
320 "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: 44497
diff changeset
321 ),
41768
aaad36b88298 cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents: 41547
diff changeset
322 ]
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
323
44499
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
324 negative_opt = Distribution.negative_opt.copy()
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
325 boolean_options = ['pure', 'rust', 'no-rust']
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
326 negative_opt['no-rust'] = 'rust'
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
327
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
328 def _set_command_options(self, command_obj, option_dict=None):
44634
4c6189d45d67 setup: work around old versions of distutils breaking setup.py
Augie Fackler <augie@google.com>
parents: 44610
diff changeset
329 # 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: 44610
diff changeset
330 # 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: 44610
diff changeset
331 command_obj.boolean_options = (
4c6189d45d67 setup: work around old versions of distutils breaking setup.py
Augie Fackler <augie@google.com>
parents: 44610
diff changeset
332 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: 44610
diff changeset
333 )
44499
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
334 return Distribution._set_command_options(
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
335 self, command_obj, option_dict=option_dict
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
336 )
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
337
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
338 def parse_command_line(self):
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
339 ret = Distribution.parse_command_line(self)
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
340 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: 44497
diff changeset
341 hgrustext = os.environ.get('HGWITHRUSTEXT')
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
342 # 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: 44497
diff changeset
343 # (see mercurial/__modulepolicy__.py)
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
344 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: 44497
diff changeset
345 if hgrustext:
48469
fff5942d445f typo: s/unkown/unknown across the codebase
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48303
diff changeset
346 msg = 'unknown HGWITHRUSTEXT value: %s' % hgrustext
48918
1371c18e467d setup: remove printf trampoline
Augie Fackler <augie@google.com>
parents: 48917
diff changeset
347 print(msg, file=sys.stderr)
44499
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
348 hgrustext = None
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
349 self.rust = hgrustext is not None
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
350 self.no_rust = not self.rust
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
351 return ret
06b0aa048007 setup-rust: add a --no-rust flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44497
diff changeset
352
15459
434c48e981b8 setup: has_ext_modules always returns false when pure is specified
Simon Heimberg <simohe@besonet.ch>
parents: 15458
diff changeset
353 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
354 # 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
355 # 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
356 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
357
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
358
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
359 # This is ugly as a one-liner. So use a variable.
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
360 buildextnegops = dict(getattr(build_ext, 'negative_options', {}))
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
361 buildextnegops['no-zstd'] = 'zstd'
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
362 buildextnegops['no-rust'] = 'rust'
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
363
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
364
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
365 class hgbuildext(build_ext):
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
366 user_options = build_ext.user_options + [
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
367 ('zstd', None, 'compile zstd bindings [default]'),
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
368 ('no-zstd', None, 'do not compile zstd bindings'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
369 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
370 'rust',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
371 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
372 'compile Rust extensions if they are in use '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
373 '(requires Cargo) [default]',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
374 ),
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
375 ('no-rust', None, 'do not compile Rust extensions'),
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
376 ]
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
377
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
378 boolean_options = build_ext.boolean_options + ['zstd', 'rust']
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
379 negative_opt = buildextnegops
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
380
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
381 def initialize_options(self):
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
382 self.zstd = True
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
383 self.rust = True
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
384
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
385 return build_ext.initialize_options(self)
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
386
43044
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
387 def finalize_options(self):
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
388 # Unless overridden by the end user, build extensions in parallel.
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
389 # Only influences behavior on Python 3.5+.
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
390 if getattr(self, 'parallel', None) is None:
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
391 self.parallel = True
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
392
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
393 return build_ext.finalize_options(self)
f9d35f01b8b3 setup: build extensions in parallel by default
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42823
diff changeset
394
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
395 def build_extensions(self):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
396 ruststandalones = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
397 e for e in self.extensions if isinstance(e, RustStandaloneExtension)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
398 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
399 self.extensions = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
400 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
401 ]
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
402 # Filter out zstd if disabled via argument.
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
403 if not self.zstd:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
404 self.extensions = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
405 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
406 ]
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
407
48539
23ce9e7bf1e5 setup.py: fix some documentation typos
Matt Harbison <matt_harbison@yahoo.com>
parents: 48469
diff changeset
408 # Build Rust standalone extensions if it'll be used
23ce9e7bf1e5 setup.py: fix some documentation typos
Matt Harbison <matt_harbison@yahoo.com>
parents: 48469
diff changeset
409 # and its build is not explicitly disabled (for external build
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
410 # as Linux distributions would do)
44484
79ac59d3f73d setup-rust: remove the legacy 'direct-ffi' variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44470
diff changeset
411 if self.distribution.rust and self.rust:
46441
cabc5e9366c5 rust: lower compile error on non-linux platforms to a warning
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 46315
diff changeset
412 if not sys.platform.startswith('linux'):
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
413 logging.warning(
46441
cabc5e9366c5 rust: lower compile error on non-linux platforms to a warning
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 46315
diff changeset
414 "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
415 "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
416 )
cabc5e9366c5 rust: lower compile error on non-linux platforms to a warning
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 46315
diff changeset
417
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
418 for rustext in ruststandalones:
52894
0977c6e612fe setup: fix `make local PURE=--rust`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52893
diff changeset
419 rustext.build('' if self.editable_mode else self.build_lib)
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
420
30459
0acf3fd718f1 setup: add flag to build_ext to control building zstd
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30445
diff changeset
421 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
422
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
423 def build_extension(self, ext):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
424 if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
425 self.distribution.rust
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
426 and self.rust
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
427 and isinstance(ext, RustExtension)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
428 ):
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
429 ext.rustbuild()
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
430 try:
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
431 build_ext.build_extension(self, ext)
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
432 except CCompilerError:
12501
98f21e4d9633 setup: slight simplification
Martin Geisler <mg@lazybytes.net>
parents: 11533
diff changeset
433 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
434 raise
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
435 logging.warning(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
436 "Failed to build optional extension '%s' (skipping)", ext.name
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
437 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
438
11468
1c1126b1d919 setup: ignore failures to build optional inotify extension
Christian Boos <cboos@neuf.fr>
parents: 10905
diff changeset
439
27268
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
440 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
441 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
442 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
443 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
444
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
445 exebuilt = False
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
446 try:
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
447 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
448 exebuilt = True
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
449 except (DistutilsError, CCompilerError):
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
450 logging.warning('failed to build optional hg.exe')
27268
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
451
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
452 if exebuilt:
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
453 # 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
454 # 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
455 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
456 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
457 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
458 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
459
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
460 # 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
461 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
462
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
463 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
464
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
465
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
466 class hgbuildpy(build_py):
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
467 def finalize_options(self):
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
468 build_py.finalize_options(self)
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
469
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
470 if self.distribution.pure:
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
471 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
472 elif self.distribution.cffi:
30356
9cc438bf7d9a setup: move cffi stuff to mercurial/cffi
Jun Wu <quark@fb.com>
parents: 29844
diff changeset
473 from mercurial.cffi import (
32538
05a16c19967e cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents: 32458
diff changeset
474 bdiffbuild,
05a16c19967e cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents: 32458
diff changeset
475 mpatchbuild,
30356
9cc438bf7d9a setup: move cffi stuff to mercurial/cffi
Jun Wu <quark@fb.com>
parents: 29844
diff changeset
476 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
477
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
478 exts = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
479 mpatchbuild.ffi.distutils_extension(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
480 bdiffbuild.ffi.distutils_extension(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
481 ]
29505
2dce3f96ad7b setup: prepare for future cffi modules by adding placeholder in setup
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
482 # 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
483 if sys.platform == 'darwin':
32538
05a16c19967e cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents: 32458
diff changeset
484 from mercurial.cffi import osutilbuild
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
485
32538
05a16c19967e cffi: rename build scripts
Yuya Nishihara <yuya@tcha.org>
parents: 32458
diff changeset
486 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
487 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
488 else:
18905
012780620d4f setup: make error message for missing Python headers more helpful
Mads Kiilerich <mads@kiilerich.com>
parents: 18900
diff changeset
489 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
490 if not os.path.exists(h):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
491 raise SystemExit(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
492 'Python headers are required to build '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
493 'Mercurial but weren\'t found in %s' % h
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
494 )
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
495
28430
17b85d739b62 setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents: 28418
diff changeset
496 def run(self):
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
497 rust = self.distribution.rust
28430
17b85d739b62 setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents: 28418
diff changeset
498 if self.distribution.pure:
17b85d739b62 setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents: 28418
diff changeset
499 modulepolicy = 'py'
32291
a04f5c651e52 policy: relax the default for in-place build
Yuya Nishihara <yuya@tcha.org>
parents: 32273
diff changeset
500 elif self.build_lib == '.':
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
501 # in-place build should run without rebuilding and Rust extensions
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
502 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
503 else:
42469
94167e701e12 rust: new rust options in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42467
diff changeset
504 modulepolicy = 'rust+c' if rust else 'c'
35238
61ff0d7d56fd setup: only write some autogenerated files if they change
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35126
diff changeset
505
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
506 content = b''.join(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
507 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
508 b'# this file is autogenerated by setup.py\n',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
509 b'modulepolicy = b"%s"\n' % modulepolicy.encode('ascii'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
510 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
511 )
52706
9ff926737dbc setup: __modulepolicy__.py created in the source dir for editable mode
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52702
diff changeset
512
9ff926737dbc setup: __modulepolicy__.py created in the source dir for editable mode
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52702
diff changeset
513 if self.editable_mode:
9ff926737dbc setup: __modulepolicy__.py created in the source dir for editable mode
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52702
diff changeset
514 here = os.path.dirname(__file__)
9ff926737dbc setup: __modulepolicy__.py created in the source dir for editable mode
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52702
diff changeset
515 basepath = os.path.join(here, 'mercurial')
9ff926737dbc setup: __modulepolicy__.py created in the source dir for editable mode
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52702
diff changeset
516 else:
9ff926737dbc setup: __modulepolicy__.py created in the source dir for editable mode
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52702
diff changeset
517 basepath = os.path.join(self.build_lib, 'mercurial')
9ff926737dbc setup: __modulepolicy__.py created in the source dir for editable mode
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52702
diff changeset
518 self.mkpath(basepath)
9ff926737dbc setup: __modulepolicy__.py created in the source dir for editable mode
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52702
diff changeset
519
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
520 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
521
28430
17b85d739b62 setup: create a module for the modulepolicy
timeless <timeless@mozdev.org>
parents: 28418
diff changeset
522 build_py.run(self)
7722
103127a8cbdb add --pure flag to setup.py
Martin Geisler <mg@daimi.au.dk>
parents: 7721
diff changeset
523
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
524
14538
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
525 class buildhgextindex(Command):
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
526 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
527 user_options = []
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
528 _indexfilename = 'hgext/__index__.py'
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
529
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
530 def initialize_options(self):
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
531 pass
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
532
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
533 def finalize_options(self):
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
534 pass
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
535
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
536 def run(self):
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
537 if os.path.exists(self._indexfilename):
28418
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
538 with open(self._indexfilename, 'w') as f:
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
539 f.write('# empty\n')
14538
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
540
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
541 # here no extension enabled, disabled() lists up everything
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
542 code = (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
543 'import pprint; from mercurial import extensions; '
44189
bb58931d0c4f setup: exclude the __index__ module from itself when generating
Matt Harbison <matt_harbison@yahoo.com>
parents: 44142
diff changeset
544 'ext = extensions.disabled();'
bb58931d0c4f setup: exclude the __index__ module from itself when generating
Matt Harbison <matt_harbison@yahoo.com>
parents: 44142
diff changeset
545 'ext.pop("__index__", None);'
bb58931d0c4f setup: exclude the __index__ module from itself when generating
Matt Harbison <matt_harbison@yahoo.com>
parents: 44142
diff changeset
546 'pprint.pprint(ext)'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
547 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
548 returncode, out, err = runcmd(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
549 [sys.executable, '-c', code], localhgenv()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
550 )
33123
87ee783f7299 setup: update runcmd() to also return the exit status
Adam Simpkins <simpkins@fb.com>
parents: 33122
diff changeset
551 if err or returncode != 0:
14538
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
552 raise DistutilsExecError(err)
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
553
42075
456c37433c43 py3: write out hgextindex as bytes in setup.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 42074
diff changeset
554 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
555 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
556 f.write(b'docs = ')
28418
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
557 f.write(out)
14538
3818c67a501e setup: add command to generate index of extensions
Yuya Nishihara <yuya@tcha.org>
parents: 14324
diff changeset
558
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
559
17061
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
560 class buildhgexe(build_ext):
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
561 description = 'compile hg.exe from mercurial/exewrapper.c'
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
562
49441
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
563 LONG_PATHS_MANIFEST = """\
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
564 <?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: 49440
diff changeset
565 <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: 49440
diff changeset
566 <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: 49440
diff changeset
567 <security>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
568 <requestedPrivileges>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
569 <requestedExecutionLevel
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
570 level="asInvoker"
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
571 uiAccess="false"
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
572 />
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
573 </requestedPrivileges>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
574 </security>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
575 </trustInfo>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
576 <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: 49440
diff changeset
577 <application>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
578 <!-- Windows Vista -->
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
579 <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
580 <!-- Windows 7 -->
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
581 <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
582 <!-- Windows 8 -->
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
583 <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
584 <!-- Windows 8.1 -->
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
585 <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
586 <!-- Windows 10 and Windows 11 -->
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
587 <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
588 </application>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
589 </compatibility>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
590 <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: 49440
diff changeset
591 <windowsSettings
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
592 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: 49440
diff changeset
593 <ws2:longPathAware>true</ws2:longPathAware>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
594 </windowsSettings>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
595 </application>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
596 <dependency>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
597 <dependentAssembly>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
598 <assemblyIdentity type="win32"
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
599 name="Microsoft.Windows.Common-Controls"
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
600 version="6.0.0.0"
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
601 processorArchitecture="*"
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
602 publicKeyToken="6595b64144ccf1df"
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
603 language="*" />
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
604 </dependentAssembly>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
605 </dependency>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
606 </assembly>
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
607 """
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
608
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
609 def initialize_options(self):
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
610 build_ext.initialize_options(self)
17061
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
611
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
612 def build_extensions(self):
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
613 if os.name != 'nt':
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
614 return
17246
bf5bb38bcc7c setup: fix build_hgexe for mingw32 compiler
Adrian Buehlmann <adrian@cadifra.com>
parents: 17121
diff changeset
615 if isinstance(self.compiler, HackedMingw32CCompiler):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
616 self.compiler.compiler_so = self.compiler.compiler # no -mdll
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
617 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
618
43718
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
619 pythonlib = None
29020
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
620
49439
5cf73de964e1 setup: stop shadowing the builtin `dir` symbol
Matt Harbison <matt_harbison@yahoo.com>
parents: 49318
diff changeset
621 dirname = os.path.dirname(self.get_ext_fullpath('dummy'))
5cf73de964e1 setup: stop shadowing the builtin `dir` symbol
Matt Harbison <matt_harbison@yahoo.com>
parents: 49318
diff changeset
622 self.hgtarget = os.path.join(dirname, 'hg')
48303
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
623
43718
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
624 if getattr(sys, 'dllhandle', None):
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
625 # 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: 43717
diff changeset
626 # 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: 43717
diff changeset
627 # and MinGW uses libpythonX.Y.dll.
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
628 _kernel32 = ctypes.windll.kernel32
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
629 _kernel32.GetModuleFileNameA.argtypes = [
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
630 ctypes.c_void_p,
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
631 ctypes.c_void_p,
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
632 ctypes.c_ulong,
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
633 ]
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
634 _kernel32.GetModuleFileNameA.restype = ctypes.c_ulong
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
635 size = 1000
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
636 buf = ctypes.create_string_buffer(size + 1)
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
637 filelen = _kernel32.GetModuleFileNameA(
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
638 sys.dllhandle, ctypes.byref(buf), size
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
639 )
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
640
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
641 if filelen > 0 and filelen != size:
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
642 dllbasename = os.path.basename(buf.value)
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
643 if not dllbasename.lower().endswith(b'.dll'):
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
644 raise SystemExit(
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
645 '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: 43717
diff changeset
646 )
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
647 pythonlib = dllbasename[:-4]
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
648
48303
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
649 # 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: 48194
diff changeset
650 # without tampering with PATH.
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
651 dest = os.path.join(
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
652 os.path.dirname(self.hgtarget),
48920
fef4198c855c setup: inline os.fsdecode now that we're done with Python 2
Augie Fackler <augie@google.com>
parents: 48919
diff changeset
653 os.fsdecode(dllbasename),
48303
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
654 )
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
655
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
656 if not os.path.exists(dest):
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
657 shutil.copy(buf.value, dest)
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
658
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
659 # Also overwrite python3.dll so that hgext.git is usable.
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
660 # TODO: also handle the MSYS flavor
48922
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
661 python_x = os.path.join(
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
662 os.path.dirname(os.fsdecode(buf.value)),
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
663 "python3.dll",
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
664 )
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
665
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
666 if os.path.exists(python_x):
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
667 dest = os.path.join(
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
668 os.path.dirname(self.hgtarget),
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
669 os.path.basename(python_x),
48303
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
670 )
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
671
48922
40e35034eac8 setup: unconditionally do this python 3 step
Augie Fackler <augie@google.com>
parents: 48921
diff changeset
672 shutil.copy(python_x, dest)
48303
2ce31dbde4b1 backout: backed out changeset f78d8b8c46d7
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48194
diff changeset
673
43718
52e4bfebc4ba setup: conditionalize access to `sys.dllhandle` when building extensions
Matt Harbison <matt_harbison@yahoo.com>
parents: 43717
diff changeset
674 if not pythonlib:
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
675 logging.warning(
43716
666441b649e4 setup: combine two contiguous string literals
Matt Harbison <matt_harbison@yahoo.com>
parents: 43676
diff changeset
676 'could not determine Python DLL filename; assuming pythonXY'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
677 )
29020
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
678
ee2e4a2c3690 setup: detect Python DLL filename from loaded DLL
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28625
diff changeset
679 hv = sys.hexversion
43717
6a5dc4d767a0 setup: use bytes for assumed python version
Matt Harbison <matt_harbison@yahoo.com>
parents: 43716
diff changeset
680 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
681
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
682 logging.info('using %s as Python library name', pythonlib)
28418
121d25719e92 setup: switch to with open as
timeless <timeless@mozdev.org>
parents: 28398
diff changeset
683 with open('mercurial/hgpythonlib.h', 'wb') as f:
39624
ec68135a8935 py3: add b'' to some setup.py strings for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 39588
diff changeset
684 f.write(b'/* this file is autogenerated by setup.py */\n')
ec68135a8935 py3: add b'' to some setup.py strings for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 39588
diff changeset
685 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
686
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
687 objects = self.compiler.compile(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
688 ['mercurial/exewrapper.c'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
689 output_dir=self.build_temp,
48923
b07b034cf548 setup: inline now-constant list
Augie Fackler <augie@google.com>
parents: 48922
diff changeset
690 macros=[('_UNICODE', None), ('UNICODE', None)],
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
691 )
52689
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
692 self.compiler.link_executable(objects, self.hgtarget, libraries=[])
49440
747c4fc20886 setup: unconditionally enable the `long-paths-support` option on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 49439
diff changeset
693
747c4fc20886 setup: unconditionally enable the `long-paths-support` option on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 49439
diff changeset
694 self.addlongpathsmanifest()
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
695
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
696 def addlongpathsmanifest(self):
49440
747c4fc20886 setup: unconditionally enable the `long-paths-support` option on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 49439
diff changeset
697 """Add manifest pieces so that hg.exe understands long paths
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
698
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
699 Why resource #1 should be used for .exe manifests? I don't know and
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
700 wasn't able to find an explanation for mortals. But it seems to work.
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
701 """
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
702 exefname = self.compiler.executable_filename(self.hgtarget)
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
703 fdauto, manfname = tempfile.mkstemp(suffix='.hg.exe.manifest')
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
704 os.close(fdauto)
49441
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
705 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: 34398
diff changeset
706 f.write(self.LONG_PATHS_MANIFEST)
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
707 logging.info("long paths manifest is written to '%s'", manfname)
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
708 outputresource = '-outputresource:%s;#1' % exefname
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
709 logging.info("running mt.exe to update hg.exe's manifest in-place")
49441
ece490b02a9b setup: use the full executable manifest from `python.exe`
Matt Harbison <matt_harbison@yahoo.com>
parents: 49440
diff changeset
710
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
711 self.spawn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
712 [
49440
747c4fc20886 setup: unconditionally enable the `long-paths-support` option on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 49439
diff changeset
713 self.compiler.mt,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
714 '-nologo',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
715 '-manifest',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
716 manfname,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
717 outputresource,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
718 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
719 )
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
720 logging.info("done updating hg.exe's manifest")
34530
ed5acd3fd7e1 windows: add an experimental option for long paths support
Kostia Balytskyi <ikostia@fb.com>
parents: 34398
diff changeset
721 os.remove(manfname)
17061
f20e4d76b711 setup: compile hg.exe
Adrian Buehlmann <adrian@cadifra.com>
parents: 16775
diff changeset
722
27268
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
723 @property
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
724 def hgexepath(self):
52689
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
725 return os.path.join(
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
726 os.path.dirname(self.get_ext_fullpath('dummy')), 'hg.exe'
f5091286b10c packaging: modernize (compat PEP 517) with less distutils and setup.py calls
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52688
diff changeset
727 )
27268
ed1660ce99d9 setup.py: attempt to build and install hg.exe on Windows
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27222
diff changeset
728
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
729
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
730 class hgbuilddoc(Command):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
731 description = 'build documentation'
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
732 user_options = [
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
733 ('man', None, 'generate man pages'),
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
734 ('html', None, 'generate html pages'),
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
735 ]
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
736
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
737 def initialize_options(self):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
738 self.man = None
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
739 self.html = None
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
740
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
741 def finalize_options(self):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
742 # If --man or --html are set, only generate what we're told to.
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
743 # Otherwise generate everything.
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
744 have_subset = self.man is not None or self.html is not None
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
745
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
746 if have_subset:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
747 self.man = True if self.man else False
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
748 self.html = True if self.html else False
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
749 else:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
750 self.man = True
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
751 self.html = True
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
752
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
753 def run(self):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
754 def normalizecrlf(p):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
755 with open(p, 'rb') as fh:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
756 orig = fh.read()
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
757
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
758 if b'\r\n' not in orig:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
759 return
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
760
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
761 logging.info('normalizing %s to LF line endings', p)
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
762 with open(p, 'wb') as fh:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
763 fh.write(orig.replace(b'\r\n', b'\n'))
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
764
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
765 def gentxt(root):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
766 txt = 'doc/%s.txt' % root
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
767 logging.info('generating %s', txt)
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
768 res, out, err = runcmd(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
769 [sys.executable, 'gendoc.py', root], os.environ, cwd='doc'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
770 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
771 if res:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
772 raise SystemExit(
44737
380959c6f75e setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44729
diff changeset
773 'error running gendoc.py: %s'
380959c6f75e setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44729
diff changeset
774 % '\n'.join([sysstr(out), sysstr(err)])
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
775 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
776
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
777 with open(txt, 'wb') as fh:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
778 fh.write(out)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
779
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
780 def gengendoc(root):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
781 gendoc = 'doc/%s.gendoc.txt' % root
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
782
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
783 logging.info('generating %s', gendoc)
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
784 res, out, err = runcmd(
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
785 [sys.executable, 'gendoc.py', '%s.gendoc' % root],
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
786 os.environ,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
787 cwd='doc',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
788 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
789 if res:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
790 raise SystemExit(
44737
380959c6f75e setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44729
diff changeset
791 'error running gendoc: %s'
380959c6f75e setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44729
diff changeset
792 % '\n'.join([sysstr(out), sysstr(err)])
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
793 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
794
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
795 with open(gendoc, 'wb') as fh:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
796 fh.write(out)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
797
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
798 def genman(root):
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
799 logging.info('generating doc/%s', root)
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
800 res, out, err = runcmd(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
801 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
802 sys.executable,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
803 'runrst',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
804 'hgmanpage',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
805 '--halt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
806 'warning',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
807 '--strip-elements-with-class',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
808 'htmlonly',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
809 '%s.txt' % root,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
810 root,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
811 ],
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
812 os.environ,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
813 cwd='doc',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
814 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
815 if res:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
816 raise SystemExit(
44737
380959c6f75e setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44729
diff changeset
817 'error running runrst: %s'
380959c6f75e setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44729
diff changeset
818 % '\n'.join([sysstr(out), sysstr(err)])
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
819 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
820
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
821 normalizecrlf('doc/%s' % root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
822
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
823 def genhtml(root):
52358
599b6ce304a7 setup_py: logging without distutils
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 52357
diff changeset
824 logging.info('generating doc/%s.html', root)
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
825 res, out, err = runcmd(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
826 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
827 sys.executable,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
828 'runrst',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
829 'html',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
830 '--halt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
831 'warning',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
832 '--link-stylesheet',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
833 '--stylesheet-path',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
834 'style.css',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
835 '%s.txt' % root,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
836 '%s.html' % root,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
837 ],
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
838 os.environ,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
839 cwd='doc',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
840 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
841 if res:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
842 raise SystemExit(
44737
380959c6f75e setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44729
diff changeset
843 'error running runrst: %s'
380959c6f75e setup: use sysstr() on process output
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44729
diff changeset
844 % '\n'.join([sysstr(out), sysstr(err)])
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
845 )
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
846
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
847 normalizecrlf('doc/%s.html' % root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
848
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
849 # This logic is duplicated in doc/Makefile.
44470
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44460
diff changeset
850 sources = {
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
851 f
43769
c7fc2d92067e windows: further build fixes for the WiX installer
Augie Fackler <augie@google.com>
parents: 43718
diff changeset
852 for f in os.listdir('mercurial/helptext')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
853 if re.search(r'[0-9]\.txt$', f)
44470
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44460
diff changeset
854 }
41855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
855
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
856 # common.txt is a one-off.
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
857 gentxt('common')
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
858
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
859 for source in sorted(sources):
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
860 assert source[-4:] == '.txt'
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
861 root = source[:-4]
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
862
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
863 gentxt(root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
864 gengendoc(root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
865
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
866 if self.man:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
867 genman(root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
868 if self.html:
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
869 genhtml(root)
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41768
diff changeset
870
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
871
32670
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
872 class hginstall(install):
32745
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
873 user_options = install.user_options + [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
874 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
875 'old-and-unmanageable',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
876 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
877 'noop, present for eggless setuptools compat',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
878 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
879 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
880 'single-version-externally-managed',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
881 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
882 'noop, present for eggless setuptools compat',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
883 ),
32745
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
884 ]
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
885
49066
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
886 sub_commands = install.sub_commands + [
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
887 ('install_completion', lambda self: True)
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
888 ]
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
889
32745
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
890 # Also helps setuptools not be sad while we refuse to create eggs.
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
891 single_version_externally_managed = True
6c4b58422974 setup: introduce dummy copies of setuptools flags
Augie Fackler <augie@google.com>
parents: 32675
diff changeset
892
32670
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
893 def get_sub_commands(self):
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
894 # Screen out egg related commands to prevent egg generation. But allow
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
895 # mercurial.egg-info generation, since that is part of modern
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
896 # packaging.
44470
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44460
diff changeset
897 excl = {'bdist_egg'}
46315
2ef575c62f10 test-regression: backing out D9640 (63c923fd7fa8)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46243
diff changeset
898 return filter(lambda x: x not in excl, install.get_sub_commands(self))
32670
331dcf199039 setup: prevent setuptools from laying an egg
Matt Harbison <matt_harbison@yahoo.com>
parents: 32539
diff changeset
899
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
900
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
901 class hginstalllib(install_lib):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
902 """
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
903 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
904 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
905 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
906 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
907 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
908
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
909 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
910 insufficient, as it might still be applying a umask.
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
911 """
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
912
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
913 def run(self):
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
914 realcopyfile = file_util.copy_file
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
915
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
916 def copyfileandsetmode(*args, **kwargs):
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
917 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
918 dst, copied = realcopyfile(*args, **kwargs)
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
919 if copied:
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
920 st = os.stat(src)
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
921 # 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
922 # has it)
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
923 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
924 setmode = int('0755', 8)
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
925 else:
24941
9c1942635c1f setup: hide octal literals inside strings so they're portable (issue4554)
Augie Fackler <augie@google.com>
parents: 24214
diff changeset
926 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
927 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
928 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
929 os.chmod(dst, m)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
930
22640
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
931 file_util.copy_file = copyfileandsetmode
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
932 try:
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
933 install_lib.run(self)
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
934 finally:
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
935 file_util.copy_file = realcopyfile
e88a634e0195 setup: set mode 644 or 755 on installed files
Kyle Lippincott <spectral@google.com>
parents: 22575
diff changeset
936
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
937
49066
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
938 class hginstallcompletion(Command):
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
939 description = 'Install shell completion'
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
940
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
941 def initialize_options(self):
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
942 self.install_dir = None
49103
b6f535f3beda setup: fix incomplete implementation of Command
Rapha?l Gom?s <rgomes@octobus.net>
parents: 49066
diff changeset
943 self.outputs = []
49066
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
944
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
945 def finalize_options(self):
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
946 self.set_undefined_options(
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
947 'install_data', ('install_dir', 'install_dir')
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
948 )
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
949
49103
b6f535f3beda setup: fix incomplete implementation of Command
Rapha?l Gom?s <rgomes@octobus.net>
parents: 49066
diff changeset
950 def get_outputs(self):
b6f535f3beda setup: fix incomplete implementation of Command
Rapha?l Gom?s <rgomes@octobus.net>
parents: 49066
diff changeset
951 return self.outputs
b6f535f3beda setup: fix incomplete implementation of Command
Rapha?l Gom?s <rgomes@octobus.net>
parents: 49066
diff changeset
952
49066
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
953 def run(self):
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
954 for src, dir_path, dest in (
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
955 (
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
956 'bash_completion',
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
957 ('share', 'bash-completion', 'completions'),
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
958 'hg',
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
959 ),
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
960 ('zsh_completion', ('share', 'zsh', 'site-functions'), '_hg'),
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
961 ):
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
962 dir = os.path.join(self.install_dir, *dir_path)
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
963 self.mkpath(dir)
49103
b6f535f3beda setup: fix incomplete implementation of Command
Rapha?l Gom?s <rgomes@octobus.net>
parents: 49066
diff changeset
964
b6f535f3beda setup: fix incomplete implementation of Command
Rapha?l Gom?s <rgomes@octobus.net>
parents: 49066
diff changeset
965 dest = os.path.join(dir, dest)
b6f535f3beda setup: fix incomplete implementation of Command
Rapha?l Gom?s <rgomes@octobus.net>
parents: 49066
diff changeset
966 self.outputs.append(dest)
b6f535f3beda setup: fix incomplete implementation of Command
Rapha?l Gom?s <rgomes@octobus.net>
parents: 49066
diff changeset
967 self.copy_file(os.path.join('contrib', src), dest)
49066
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
968
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
969
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
970 cmdclass = {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
971 'build': hgbuild,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
972 'build_doc': hgbuilddoc,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
973 'build_mo': hgbuildmo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
974 'build_ext': hgbuildext,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
975 'build_py': hgbuildpy,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
976 'build_scripts': hgbuildscripts,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
977 'build_hgextindex': buildhgextindex,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
978 'install': hginstall,
49066
8d7eaff92f9c completion: install completers to conventional locations
Matthew Martin <phy1729@gmail.com>
parents: 49037
diff changeset
979 'install_completion': hginstallcompletion,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
980 'install_lib': hginstalllib,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
981 'build_hgexe': buildhgexe,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
982 }
3238
3dba9ec89164 Applied coding style to setup.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2402
diff changeset
983
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
984 packages = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
985 'mercurial',
50995
727428c7e1fc commands: add admin namespace
Franck Bret <franck.bret@octobus.net>
parents: 50953
diff changeset
986 'mercurial.admin',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
987 'mercurial.cext',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
988 'mercurial.cffi',
52360
f2fc0a91faca commands: create a "mercurial.cmd_impls" module to host graft
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52358
diff changeset
989 'mercurial.cmd_impls',
52447
0a81f3ef054c config: move `rcutil` module under a new `mercurial.configuration` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
990 'mercurial.configuration',
51938
f0e07efc199f rev-branch-cache: move the code in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51887
diff changeset
991 'mercurial.branching',
44028
44b03c0313aa setup: include `defaultrc` in the package list
Matt Harbison <matt_harbison@yahoo.com>
parents: 43812
diff changeset
992 'mercurial.defaultrc',
47674
ff97e793ed36 dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents: 47007
diff changeset
993 'mercurial.dirstateutils',
43676
2e017696181f help: create packages for the help text
Matt Harbison <matt_harbison@yahoo.com>
parents: 43349
diff changeset
994 'mercurial.helptext',
2e017696181f help: create packages for the help text
Matt Harbison <matt_harbison@yahoo.com>
parents: 43349
diff changeset
995 'mercurial.helptext.internals',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
996 'mercurial.hgweb',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
997 'mercurial.interfaces',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
998 'mercurial.pure',
50460
f0d2b18f0274 stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents: 50442
diff changeset
999 'mercurial.stabletailgraph',
45325
41ff8a463e10 packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents: 45294
diff changeset
1000 'mercurial.templates',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1001 'mercurial.thirdparty',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1002 'mercurial.thirdparty.attr',
50800
2c34c9b61a4f thirdparty: vendor tomli
Rapha?l Gom?s <rgomes@octobus.net>
parents: 50730
diff changeset
1003 'mercurial.thirdparty.tomli',
46050
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45957
diff changeset
1004 'mercurial.upgrade_utils',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1005 'mercurial.utils',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1006 'mercurial.revlogutils',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1007 'mercurial.testing',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1008 'hgext',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1009 'hgext.convert',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1010 'hgext.fsmonitor',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1011 'hgext.fastannotate',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1012 'hgext.fsmonitor.pywatchman',
44489
ad718271a9eb git: skeleton of a new extension to _directly_ operate on git repos
Augie Fackler <augie@google.com>
parents: 44484
diff changeset
1013 'hgext.git',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1014 'hgext.highlight',
44440
4cabeea6d214 hgext: start building a library for simple hooks
Joerg Sonnenberger <joerg@bec.de>
parents: 44348
diff changeset
1015 'hgext.hooklib',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1016 'hgext.largefiles',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1017 'hgext.lfs',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1018 'hgext.narrow',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1019 'hgext.remotefilelog',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1020 'hgext.zeroconf',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1021 'hgext3rd',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1022 'hgdemandimport',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1023 ]
45325
41ff8a463e10 packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents: 45294
diff changeset
1024
41ff8a463e10 packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents: 45294
diff changeset
1025 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: 45294
diff changeset
1026 if name != '__pycache__' and os.path.isdir(
41ff8a463e10 packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents: 45294
diff changeset
1027 os.path.join('mercurial', 'templates', name)
41ff8a463e10 packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents: 45294
diff changeset
1028 ):
41ff8a463e10 packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents: 45294
diff changeset
1029 packages.append('mercurial.templates.%s' % name)
41ff8a463e10 packaging: mark mercurial.templates and subdirs as packages
Martin von Zweigbergk <martinvonz@google.com>
parents: 45294
diff changeset
1030
42054
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1031 if 'HG_PY2EXE_EXTRA_INSTALL_PACKAGES' in os.environ:
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1032 # py2exe can't cope with namespace packages very well, so we have to
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1033 # install any hgext3rd.* extensions that we want in the final py2exe
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1034 # image here. This is gross, but you gotta do what you gotta do.
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1035 packages.extend(os.environ['HG_PY2EXE_EXTRA_INSTALL_PACKAGES'].split(' '))
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 41959
diff changeset
1036
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1037 common_depends = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1038 'mercurial/bitmanipulation.h',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1039 'mercurial/compat.h',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1040 'mercurial/cext/util.h',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1041 ]
32251
c48583859e04 policy: add "cext" package which will host CPython extension modules
Yuya Nishihara <yuya@tcha.org>
parents: 32178
diff changeset
1042 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
1043
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1044 common_cflags = []
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1045
44610
960770add699 setup: relax -Werror for declaration-after-statement on Python 3.9
Augie Fackler <augie@google.com>
parents: 44596
diff changeset
1046 # 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: 44596
diff changeset
1047 # 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: 44596
diff changeset
1048 if os.name != 'nt' and sys.version_info[1] < 9:
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1049 common_cflags = ['-Werror=declaration-after-statement']
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1050
30418
ce9a3033c118 setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents: 30356
diff changeset
1051 osutil_cflags = []
25073
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1052 osutil_ldflags = []
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1053
31567
312e62640798 setup: detect statfs
Jun Wu <quark@fb.com>
parents: 31566
diff changeset
1054 # platform specific macros
31627
2243ba216f66 statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents: 31601
diff changeset
1055 for plat, func in [('bsd', 'setproctitle')]:
31567
312e62640798 setup: detect statfs
Jun Wu <quark@fb.com>
parents: 31566
diff changeset
1056 if re.search(plat, sys.platform) and hasfunction(new_compiler(), func):
30418
ce9a3033c118 setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents: 30356
diff changeset
1057 osutil_cflags.append('-DHAVE_%s' % func.upper())
ce9a3033c118 setup: test setproctitle before building osutil
Jun Wu <quark@fb.com>
parents: 30356
diff changeset
1058
31601
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1059 for plat, macro, code in [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1060 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1061 'bsd|darwin',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1062 'BSD_STATFS',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1063 '''
31601
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1064 #include <sys/param.h>
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1065 #include <sys/mount.h>
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1066 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
1067 ''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1068 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1069 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1070 'linux',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1071 'LINUX_STATFS',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1072 '''
31627
2243ba216f66 statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents: 31601
diff changeset
1073 #include <linux/magic.h>
2243ba216f66 statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents: 31601
diff changeset
1074 #include <sys/vfs.h>
2243ba216f66 statfs: change Linux feature detection
Jun Wu <quark@fb.com>
parents: 31601
diff changeset
1075 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
1076 ''',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1077 ),
31601
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1078 ]:
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1079 if re.search(plat, sys.platform) and cancompile(new_compiler(), code):
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1080 osutil_cflags.append('-DHAVE_%s' % macro)
ab51a2b18f87 setup: use a more strict way to test BSD or OSX's statfs
Jun Wu <quark@fb.com>
parents: 31568
diff changeset
1081
25073
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1082 if sys.platform == 'darwin':
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1083 osutil_ldflags += ['-framework', 'ApplicationServices']
c1a9e31bec0f setup: move osutil_ldflags logic to before extmodules definition
Adrian Buehlmann <adrian@cadifra.com>
parents: 25072
diff changeset
1084
44220
539490756a72 setup: link osutil.so to libsocket on Solaris/illumos (issue6299)
Alexander Pyhalov <apyhalov@gmail.com>
parents: 44214
diff changeset
1085 if sys.platform == 'sunos5':
539490756a72 setup: link osutil.so to libsocket on Solaris/illumos (issue6299)
Alexander Pyhalov <apyhalov@gmail.com>
parents: 44214
diff changeset
1086 osutil_ldflags += ['-lsocket']
539490756a72 setup: link osutil.so to libsocket on Solaris/illumos (issue6299)
Alexander Pyhalov <apyhalov@gmail.com>
parents: 44214
diff changeset
1087
36704
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1088 xdiff_srcs = [
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1089 'mercurial/thirdparty/xdiff/xdiffi.c',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1090 'mercurial/thirdparty/xdiff/xprepare.c',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1091 'mercurial/thirdparty/xdiff/xutils.c',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1092 ]
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1093
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1094 xdiff_headers = [
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1095 'mercurial/thirdparty/xdiff/xdiff.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1096 'mercurial/thirdparty/xdiff/xdiffi.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1097 'mercurial/thirdparty/xdiff/xinclude.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1098 'mercurial/thirdparty/xdiff/xmacros.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1099 'mercurial/thirdparty/xdiff/xprepare.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1100 'mercurial/thirdparty/xdiff/xtypes.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1101 'mercurial/thirdparty/xdiff/xutils.h',
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1102 ]
430fdb717549 bdiff: add a xdiffblocks method
Jun Wu <quark@fb.com>
parents: 36636
diff changeset
1103
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1104
40979
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1105 class RustCompilationError(CCompilerError):
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1106 """Exception class for Rust compilation errors."""
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1107
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1108
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1109 class RustExtension(Extension):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1110 """Base classes for concrete Rust Extension classes."""
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1111
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1112 rusttargetdir = os.path.join('rust', 'target', 'release')
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1113
48194
01c3dd208c75 rust: Make the hg-cpython crate default to Python 3
Simon Sapin <simon.sapin@octobus.net>
parents: 48192
diff changeset
1114 def __init__(self, mpath, sources, rustlibname, subcrate, **kw):
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1115 Extension.__init__(self, mpath, sources, **kw)
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1116 srcdir = self.rustsrcdir = os.path.join('rust', subcrate)
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1117
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1118 # adding Rust source and control files to depends so that the extension
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1119 # gets rebuilt if they've changed
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1120 self.depends.append(os.path.join(srcdir, 'Cargo.toml'))
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1121 cargo_lock = os.path.join(srcdir, 'Cargo.lock')
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1122 if os.path.exists(cargo_lock):
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1123 self.depends.append(cargo_lock)
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1124 for dirpath, subdir, fnames in os.walk(os.path.join(srcdir, 'src')):
52893
6ce3fc909a68 setup: don't add Rust build artifacts to dependencies
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52706
diff changeset
1125 if dirpath == os.path.join(srcdir, "target"):
6ce3fc909a68 setup: don't add Rust build artifacts to dependencies
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52706
diff changeset
1126 # Skip this large artifacts free
6ce3fc909a68 setup: don't add Rust build artifacts to dependencies
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52706
diff changeset
1127 continue
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1128 self.depends.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1129 os.path.join(dirpath, fname)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1130 for fname in fnames
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1131 if os.path.splitext(fname)[1] == '.rs'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1132 )
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1133
42473
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1134 @staticmethod
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1135 def rustdylibsuffix():
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1136 """Return the suffix for shared libraries produced by rustc.
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1137
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1138 See also: https://doc.rust-lang.org/reference/linkage.html
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1139 """
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1140 if sys.platform == 'darwin':
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1141 return '.dylib'
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1142 elif os.name == 'nt':
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1143 return '.dll'
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1144 else:
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1145 return '.so'
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1146
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1147 def rustbuild(self):
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1148 env = os.environ.copy()
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1149 if 'HGTEST_RESTOREENV' in env:
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1150 # Mercurial tests change HOME to a temporary directory,
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1151 # but, if installed with rustup, the Rust toolchain needs
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1152 # HOME to be correct (otherwise the 'no default toolchain'
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1153 # error message is issued and the build fails).
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1154 # This happens currently with test-hghave.t, which does
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1155 # invoke this build.
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1156
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1157 # Unix only fix (os.path.expanduser not really reliable if
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1158 # HOME is shadowed like this)
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1159 import pwd
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1160
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1161 env['HOME'] = pwd.getpwuid(os.getuid()).pw_dir
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1162
52212
124c944b71b2 setup: make sure Rust build its extension for the right python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52206
diff changeset
1163 # Wildy shooting in the dark to make sure rust-cpython use the right
124c944b71b2 setup: make sure Rust build its extension for the right python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52206
diff changeset
1164 # python
124c944b71b2 setup: make sure Rust build its extension for the right python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52206
diff changeset
1165 if not sys.executable:
124c944b71b2 setup: make sure Rust build its extension for the right python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52206
diff changeset
1166 msg = "Cannot determine which Python to compile Rust for"
124c944b71b2 setup: make sure Rust build its extension for the right python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52206
diff changeset
1167 raise RustCompilationError(msg)
124c944b71b2 setup: make sure Rust build its extension for the right python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52206
diff changeset
1168 env['PYTHON_SYS_EXECUTABLE'] = sys.executable
124c944b71b2 setup: make sure Rust build its extension for the right python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52206
diff changeset
1169 env['PYTHONEXECUTABLE'] = sys.executable
124c944b71b2 setup: make sure Rust build its extension for the right python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52206
diff changeset
1170 env['PYTHON'] = sys.executable
52915
53ae4495e5f0 setup: set PYO3_PYTHON to ensure PyO3 uses the right Python
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 52894
diff changeset
1171 env['PYO3_PYTHON'] = sys.executable
52212
124c944b71b2 setup: make sure Rust build its extension for the right python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52206
diff changeset
1172
44905
47787a48f469 setup: stop asking cargo to spam
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 44737
diff changeset
1173 cargocmd = ['cargo', 'rustc', '--release']
44348
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44302
diff changeset
1174
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44302
diff changeset
1175 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: 44302
diff changeset
1176 if rust_features:
48933
649ff7f86f96 rust: enable Python 3 support unconditionally
Simon Sapin <simon.sapin@octobus.net>
parents: 48929
diff changeset
1177 cargocmd.extend(('--features', rust_features))
44348
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44302
diff changeset
1178
42475
85041e2b69c7 rust: switched to 'cargo rustc' in setup.py
Georges Racinet <georges.racinet@octobus.net>
parents: 42474
diff changeset
1179 cargocmd.append('--')
42474
8ee0fdf3b087 rust-cpython: fix build for MacOSX
Georges Racinet <georges.racinet@octobus.net>
parents: 42473
diff changeset
1180 if sys.platform == 'darwin':
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1181 cargocmd.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1182 ("-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup")
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1183 )
40979
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1184 try:
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1185 subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir)
49318
050dc8730858 py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents: 49128
diff changeset
1186 except FileNotFoundError:
050dc8730858 py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents: 49128
diff changeset
1187 raise RustCompilationError("Cargo not found")
050dc8730858 py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents: 49128
diff changeset
1188 except PermissionError:
050dc8730858 py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents: 49128
diff changeset
1189 raise RustCompilationError(
050dc8730858 py3: catch specific OSError subclasses instead of checking errno
Manuel Jacob <me@manueljacob.de>
parents: 49128
diff changeset
1190 "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: 49128
diff changeset
1191 )
40979
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1192 except subprocess.CalledProcessError:
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1193 raise RustCompilationError(
1eaf62a67c1a rust: better treatment of cargo/rustc errors
Georges Racinet <gracinet@anybox.fr>
parents: 40877
diff changeset
1194 "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
1195 "command: %r, environment: %r"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1196 % (self.rustsrcdir, cargocmd, env)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1197 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1198
40273
3b275f549777 rust: exposing in parsers module
Georges Racinet <gracinet@anybox.fr>
parents: 40122
diff changeset
1199
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1200 class RustStandaloneExtension(RustExtension):
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1201 def __init__(self, pydottedname, rustcrate, dylibname, **kw):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1202 RustExtension.__init__(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1203 self, pydottedname, [], dylibname, rustcrate, **kw
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1204 )
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1205 self.dylibname = dylibname
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1206
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1207 def build(self, target_dir):
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1208 self.rustbuild()
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1209 target = [target_dir]
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1210 target.extend(self.name.split('.'))
42473
f4a65077e949 rust-cpython: management of shared libray suffix
Georges Racinet <georges.racinet@octobus.net>
parents: 42469
diff changeset
1211 target[-1] += DYLIB_SUFFIX
50019
ff4df0954742 setup: Ensure target directory exists with building rust extension
C?dric Krier <ced@b2ck.com>
parents: 49958
diff changeset
1212 target = os.path.join(*target)
ff4df0954742 setup: Ensure target directory exists with building rust extension
C?dric Krier <ced@b2ck.com>
parents: 49958
diff changeset
1213 os.makedirs(os.path.dirname(target), exist_ok=True)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1214 shutil.copy2(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1215 os.path.join(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1216 self.rusttargetdir, self.dylibname + self.rustdylibsuffix()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1217 ),
50019
ff4df0954742 setup: Ensure target directory exists with building rust extension
C?dric Krier <ced@b2ck.com>
parents: 49958
diff changeset
1218 target,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1219 )
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1220
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1221
10000
16f49d671c7f setup: cleanup coding style
Martin Geisler <mg@lazybytes.net>
parents: 9999
diff changeset
1222 extmodules = [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1223 Extension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1224 'mercurial.cext.base85',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1225 ['mercurial/cext/base85.c'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1226 include_dirs=common_include_dirs,
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1227 extra_compile_args=common_cflags,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1228 depends=common_depends,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1229 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1230 Extension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1231 'mercurial.cext.bdiff',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1232 ['mercurial/bdiff.c', 'mercurial/cext/bdiff.c'] + xdiff_srcs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1233 include_dirs=common_include_dirs,
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1234 extra_compile_args=common_cflags,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1235 depends=common_depends + ['mercurial/bdiff.h'] + xdiff_headers,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1236 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1237 Extension(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1238 'mercurial.cext.mpatch',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1239 ['mercurial/mpatch.c', 'mercurial/cext/mpatch.c'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1240 include_dirs=common_include_dirs,
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1241 extra_compile_args=common_cflags,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1242 depends=common_depends,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1243 ),
44484
79ac59d3f73d setup-rust: remove the legacy 'direct-ffi' variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44470
diff changeset
1244 Extension(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1245 'mercurial.cext.parsers',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1246 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1247 'mercurial/cext/charencode.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1248 'mercurial/cext/dirs.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1249 'mercurial/cext/manifest.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1250 'mercurial/cext/parsers.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1251 'mercurial/cext/pathencode.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1252 'mercurial/cext/revlog.c',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1253 ],
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1254 include_dirs=common_include_dirs,
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1255 extra_compile_args=common_cflags,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1256 depends=common_depends
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1257 + [
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1258 'mercurial/cext/charencode.h',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1259 'mercurial/cext/revlog.h',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1260 ],
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1261 ),
37182
922b3fae9c7d setup: register zope.interface packages and compile C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37133
diff changeset
1262 Extension(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1263 'mercurial.cext.osutil',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1264 ['mercurial/cext/osutil.c'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1265 include_dirs=common_include_dirs,
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1266 extra_compile_args=common_cflags + osutil_cflags,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1267 extra_link_args=osutil_ldflags,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1268 depends=common_depends,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1269 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1270 Extension(
44058
bde1cd4c99d9 sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents: 44028
diff changeset
1271 'mercurial.thirdparty.sha1dc',
bde1cd4c99d9 sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents: 44028
diff changeset
1272 [
bde1cd4c99d9 sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents: 44028
diff changeset
1273 'mercurial/thirdparty/sha1dc/cext.c',
bde1cd4c99d9 sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents: 44028
diff changeset
1274 'mercurial/thirdparty/sha1dc/lib/sha1.c',
bde1cd4c99d9 sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents: 44028
diff changeset
1275 'mercurial/thirdparty/sha1dc/lib/ubc_check.c',
bde1cd4c99d9 sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents: 44028
diff changeset
1276 ],
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1277 extra_compile_args=common_cflags,
44058
bde1cd4c99d9 sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents: 44028
diff changeset
1278 ),
bde1cd4c99d9 sha1dc: initial implementation of Python extension
Augie Fackler <augie@google.com>
parents: 44028
diff changeset
1279 Extension(
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1280 'hgext.fsmonitor.pywatchman.bser',
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1281 ['hgext/fsmonitor/pywatchman/bser.c'],
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1282 extra_compile_args=common_cflags,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1283 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1284 ]
5396
5105b119edd2 Add osutil module, containing a listdir function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 5197
diff changeset
1285
52687
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1286 if os.name != 'nt':
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1287 extmodules += [
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1288 RustStandaloneExtension(
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1289 'mercurial.rustext',
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1290 'hg-cpython',
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1291 'librusthg',
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1292 ),
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1293 RustStandaloneExtension(
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1294 'mercurial.pyo3_rustext',
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1295 'hg-pyo3',
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1296 'librusthgpyo3',
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1297 ),
e5aadff6cb7d setup: skip building rust extensions on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 52686
diff changeset
1298 ]
40980
462a26756f70 rust-cpython: build via HGWITHRUSTEXT=cpython
Georges Racinet <gracinet@anybox.fr>
parents: 40979
diff changeset
1299
30445
788ea4ac4388 setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30418
diff changeset
1300 sys.path.insert(0, 'contrib/python-zstandard')
788ea4ac4388 setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30418
diff changeset
1301 import setup_zstd
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1302
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1303 zstd = setup_zstd.get_c_extension(
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1304 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
1305 )
44596
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1306 zstd.extra_compile_args += common_cflags
2a98b0cd4995 setup: build C extensions with -Werror=declaration-after-statement
Matt Harbison <matt_harbison@yahoo.com>
parents: 44499
diff changeset
1307 extmodules.append(zstd)
30445
788ea4ac4388 setup: compile zstd C extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30418
diff changeset
1308
23677
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1309 try:
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1310 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
1311
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1312 # the -mno-cygwin option has been deprecated for years
33663
7686cbb0ba41 setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents: 33600
diff changeset
1313 mingw32compilerclass = cygwinccompiler.Mingw32CCompiler
17121
d13f47c800fd setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents: 17061
diff changeset
1314
23677
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1315 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
1316 def __init__(self, *args, **kwargs):
33663
7686cbb0ba41 setup: fix installing in a mingw environment
Mike Hommey <mh@glandium.org>
parents: 33600
diff changeset
1317 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
1318 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
1319 try:
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1320 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
1321 except ValueError:
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1322 pass
17121
d13f47c800fd setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents: 17061
diff changeset
1323
23677
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1324 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
1325 except ImportError:
6bc1702e7333 setup: don't fail when Python doesn't have the cygwinccompiler package
Ludovic Chabant <ludovic@chabant.com>
parents: 23647
diff changeset
1326 # 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
1327 # 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
1328 # DiskStation boxes
49037
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48941
diff changeset
1329 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
1330 pass
17121
d13f47c800fd setup: disable -mno-cygwin if building under mingw32
Bryan O'Sullivan <bryano@fb.com>
parents: 17061
diff changeset
1331
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1332
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1333 packagedata = {
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1334 'mercurial': [
50801
c51b178b0b7e configitems: declare items in a TOML file
Rapha?l Gom?s <rgomes@octobus.net>
parents: 50800
diff changeset
1335 'configitems.toml',
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1336 'locale/*/LC_MESSAGES/hg.mo',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1337 'dummycert.pem',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1338 ],
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1339 'mercurial.defaultrc': [
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1340 '*.rc',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1341 ],
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1342 'mercurial.helptext': [
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1343 '*.txt',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1344 ],
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1345 'mercurial.helptext.internals': [
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1346 '*.txt',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45954
diff changeset
1347 ],
49771
54421ef8a423 setup: include vendored 3rd party type stubs
Matt Harbison <matt_harbison@yahoo.com>
parents: 49441
diff changeset
1348 'mercurial.thirdparty.attr': [
54421ef8a423 setup: include vendored 3rd party type stubs
Matt Harbison <matt_harbison@yahoo.com>
parents: 49441
diff changeset
1349 '*.pyi',
54421ef8a423 setup: include vendored 3rd party type stubs
Matt Harbison <matt_harbison@yahoo.com>
parents: 49441
diff changeset
1350 'py.typed',
54421ef8a423 setup: include vendored 3rd party type stubs
Matt Harbison <matt_harbison@yahoo.com>
parents: 49441
diff changeset
1351 ],
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1352 }
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1353
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1354
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1355 def ordinarypath(p):
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1356 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
1357
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1358
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
1359 for root in ('templates',):
9999
f91e5630ce7e setup: install translation files as package data
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 9998
diff changeset
1360 for curdir, dirs, files in os.walk(os.path.join('mercurial', root)):
45326
e2320bb7a99f packaging: include templates with their package as key in package_data
Martin von Zweigbergk <martinvonz@google.com>
parents: 45325
diff changeset
1361 packagename = curdir.replace(os.sep, '.')
e2320bb7a99f packaging: include templates with their package as key in package_data
Martin von Zweigbergk <martinvonz@google.com>
parents: 45325
diff changeset
1362 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
1363
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1364 extra = {}
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1365
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1366 py2exepackages = [
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1367 'hgdemandimport',
41923
5d9fdc9b0178 setup: include hgext3rd package in py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41922
diff changeset
1368 'hgext3rd',
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1369 'hgext',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1370 'email',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1371 # implicitly imported per module policy
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1372 # (cffi wouldn't be used as a frozen exe)
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1373 'mercurial.cext',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1374 #'mercurial.cffi',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1375 'mercurial.pure',
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1376 ]
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1377
46350
d6cfe45afb18 packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents: 46315
diff changeset
1378 py2exe_includes = []
d6cfe45afb18 packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents: 46315
diff changeset
1379
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1380 py2exeexcludes = []
41959
e5ac701e5b7c setup: exclude crypt32.dll in py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41958
diff changeset
1381 py2exedllexcludes = ['crypt32.dll']
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1382
10400
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1383 if py2exeloaded:
fb203201ce30 setup.py: fixing version info for Windows hg.exe (py2exe)
Adrian Buehlmann <adrian@cadifra.com>
parents: 10282
diff changeset
1384 extra['console'] = [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1385 {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1386 'script': 'hg',
52257
6ca5cf290ebe copyright: update to 2025
Matt Harbison <matt_harbison@yahoo.com>
parents: 52213
diff changeset
1387 'copyright': 'Copyright (C) 2005-2025 Olivia Mackall and others',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1388 'product_version': version,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1389 }
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1390 ]
41922
ac32e04e887f setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41921
diff changeset
1391 # Sub command of 'build' because 'py2exe' does not handle sub_commands.
ac32e04e887f setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41921
diff changeset
1392 # Need to override hgbuild because it has a private copy of
ac32e04e887f setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41921
diff changeset
1393 # build.sub_commands.
ac32e04e887f setup: properly install build_hgextindex for py2exe builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41921
diff changeset
1394 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
1395 # 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
1396 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
1397
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1398 # We allow some configuration to be supplemented via environment
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1399 # variables. This is better than setup.cfg files because it allows
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1400 # supplementing configs instead of replacing them.
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1401 extrapackages = os.environ.get('HG_PY2EXE_EXTRA_PACKAGES')
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1402 if extrapackages:
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1403 py2exepackages.extend(extrapackages.split(' '))
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1404
46350
d6cfe45afb18 packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents: 46315
diff changeset
1405 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
1406 if extra_includes:
d6cfe45afb18 packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents: 46315
diff changeset
1407 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
1408
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1409 excludes = os.environ.get('HG_PY2EXE_EXTRA_EXCLUDES')
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1410 if excludes:
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1411 py2exeexcludes.extend(excludes.split(' '))
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1412
41921
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1413 dllexcludes = os.environ.get('HG_PY2EXE_EXTRA_DLL_EXCLUDES')
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1414 if dllexcludes:
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41859
diff changeset
1415 py2exedllexcludes.extend(dllexcludes.split(' '))
41856
ed35057421ae setup: include additional packages in py2exe distribution
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41855
diff changeset
1416
45132
9d532329ee97 extensions: make `hg help extensions` list disabled extensions with PyOxidizer
Martin von Zweigbergk <martinvonz@google.com>
parents: 44952
diff changeset
1417 if os.environ.get('PYOXIDIZER'):
9d532329ee97 extensions: make `hg help extensions` list disabled extensions with PyOxidizer
Martin von Zweigbergk <martinvonz@google.com>
parents: 44952
diff changeset
1418 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: 44952
diff changeset
1419
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1420 setup(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1421 long_description=(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1422 'Mercurial is a distributed SCM tool written in Python.'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1423 ' 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
1424 ' fast, reliable distributed revision control, such as '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1425 'Mozilla.'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1426 ),
52011
d07034819565 install: add long_description_content_type
paugier <pierre.augier@univ-grenoble-alpes.fr>
parents: 51938
diff changeset
1427 long_description_content_type='text/x-rst',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1428 scripts=scripts,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1429 packages=packages,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1430 ext_modules=extmodules,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1431 package_data=packagedata,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1432 cmdclass=cmdclass,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1433 distclass=hgdist,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1434 options={
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1435 'py2exe': {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1436 'bundle_files': 3,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1437 'dll_excludes': py2exedllexcludes,
46350
d6cfe45afb18 packaging: allow specifying modules to include with py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents: 46315
diff changeset
1438 'includes': py2exe_includes,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1439 'excludes': py2exeexcludes,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1440 'packages': py2exepackages,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1441 },
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1442 'bdist_mpkg': {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1443 'zipdist': False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1444 'license': 'COPYING',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1445 'readme': 'contrib/packaging/macosx/Readme.html',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1446 'welcome': 'contrib/packaging/macosx/Welcome.html',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1447 },
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1448 },
51191
3c5b66d03c37 setup: make debug simpler by adding a `__repr__` to `hgcommand`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50995
diff changeset
1449 **extra,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43044
diff changeset
1450 )