##// END OF EJS Templates
py3: avoid iterating over a literal bytes in highlight...
py3: avoid iterating over a literal bytes in highlight In Python 3, iterating over a bytes literal yields integers. Since we use the value in `text.replace()`, this fails on Python 3 with the following trackback: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/mercurial/hgweb/hgwebdir_mod.py", line 378, in run_wsgi for r in self._runwsgi(req, res): File "/usr/lib/python3/dist-packages/mercurial/hgweb/hgweb_mod.py", line 326, in run_wsgi for r in self._runwsgi(req, res, repo): File "/usr/lib/python3/dist-packages/mercurial/hgweb/hgweb_mod.py", line 449, in _runwsgi return getattr(webcommands, cmd)(rctx) File "/usr/lib/python3/dist-packages/mercurial/hgweb/webcommands.py", line 211, in file return _filerevision(web, webutil.filectx(web.repo, web.req)) File "/usr/lib/python3/dist-packages/hgext/highlight/__init__.py", line 72, in filerevision_highlight pygmentize(web, b'fileline', fctx, web.tmpl) File "/usr/lib/python3/dist-packages/hgext/highlight/__init__.py", line 58, in pygmentize field, fctx, style, tmpl, guessfilenameonly=filenameonly File "/usr/lib/python3/dist-packages/hgext/highlight/highlight.py", line 62, in pygmentize text = text.replace(c, b'') TypeError: a bytes-like object is required, not 'int'

File last commit:

r43346:2372284d default
r44014:856cce0c stable
Show More
build.py
96 lines | 2.9 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)