##// END OF EJS Templates
setup: build extensions in parallel by default...
setup: build extensions in parallel by default The build_ext distutils command in Python 3.5+ has a "parallel" option that controls whether to build extensions in parallel. It is disabled by default (None) and can be set to an integer value for number of cores or True to indicate use all available CPU cores. This commit changes our build_ext command override to set "parallel" to True unless a value has been provided by the caller. On my machine, this makes `python setup.py build_ext` 1-4s faster. It is worth noting that at this time, each individual source file constituting the extension is still built serially. For Mercurial, this means that we can't build faster than the slowest-to-build extension, which is the zstd extension by a long shot. This means that setup.py is still not very efficient at utilizing multiple cores. But we're better than before. Differential Revision: https://phab.mercurial-scm.org/D6923 # no-check-commit because of foo_bar naming

File last commit:

r42260:57645939 default
r43314:f9d35f01 default
Show More
build.py
84 lines | 3.0 KiB | text/x-python | PythonLexer
#!/usr/bin/env python3
# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
# no-check-code because Python 3 native.
"""Code to build Mercurial WiX installer."""
import argparse
import os
import pathlib
import sys
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--name',
help='Application name',
default='Mercurial')
parser.add_argument('--python',
help='Path to Python executable to use',
required=True)
parser.add_argument('--sign-sn',
help='Subject name (or fragment thereof) of certificate '
'to use for signing')
parser.add_argument('--sign-cert',
help='Path to certificate to use for signing')
parser.add_argument('--sign-password',
help='Password for signing certificate')
parser.add_argument('--sign-timestamp-url',
help='URL of timestamp server to use for signing')
parser.add_argument('--version',
help='Version string to use')
parser.add_argument('--extra-packages-script',
help=('Script to execute to include extra packages in '
'py2exe binary.'))
parser.add_argument('--extra-wxs',
help='CSV of path_to_wxs_file=working_dir_for_wxs_file')
parser.add_argument('--extra-features',
help=('CSV of extra feature names to include '
'in the installer from the extra wxs files'))
args = parser.parse_args()
here = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
source_dir = here.parent.parent.parent
sys.path.insert(0, str(source_dir / 'contrib' / 'packaging'))
from hgpackaging.wix import (
build_installer,
build_signed_installer,
)
fn = build_installer
kwargs = {
'source_dir': source_dir,
'python_exe': pathlib.Path(args.python),
'version': args.version,
}
if not os.path.isabs(args.python):
raise Exception('--python arg must be an absolute path')
if args.extra_packages_script:
kwargs['extra_packages_script'] = args.extra_packages_script
if args.extra_wxs:
kwargs['extra_wxs'] = dict(
thing.split("=") for thing in args.extra_wxs.split(','))
if args.extra_features:
kwargs['extra_features'] = args.extra_features.split(',')
if args.sign_sn or args.sign_cert:
fn = build_signed_installer
kwargs['name'] = args.name
kwargs['subject_name'] = args.sign_sn
kwargs['cert_path'] = args.sign_cert
kwargs['cert_password'] = args.sign_password
kwargs['timestamp_url'] = args.sign_timestamp_url
fn(**kwargs)