diff options
author | lloyd <[email protected]> | 2015-01-06 00:18:03 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-01-06 00:18:03 +0000 |
commit | 6198946dbb5a864ab0aa9ce8d27c920423634827 (patch) | |
tree | da3da2f34b696994dfb786b2b1bc01628613ea70 /src/scripts | |
parent | 21e038b98b9d0ddc26bff65b078a7d5adee440ef (diff) |
Fix install script under Python3
Diffstat (limited to 'src/scripts')
-rwxr-xr-x | src/scripts/combine_relnotes.py | 19 | ||||
-rwxr-xr-x | src/scripts/install.py | 22 |
2 files changed, 29 insertions, 12 deletions
diff --git a/src/scripts/combine_relnotes.py b/src/scripts/combine_relnotes.py index c843bf347..9b6c4f304 100755 --- a/src/scripts/combine_relnotes.py +++ b/src/scripts/combine_relnotes.py @@ -9,6 +9,13 @@ Distributed under the terms of the Botan license import re import sys import os +import sys + +def open_for_utf8(fsname, mode): + if sys.version_info[0] == 3: + return open(fsname, mode, encoding='utf-8') + else: + return open(fsname, mode) def combine_relnotes(relnote_dir, with_rst_labels): @@ -23,7 +30,7 @@ def combine_relnotes(relnote_dir, with_rst_labels): versions_nyr = [] for f in relnotes: - contents = open(os.path.join(relnote_dir, f)).readlines() + contents = open_for_utf8(os.path.join(relnote_dir, f), 'r').readlines() match = re_version.match(contents[0]) @@ -33,13 +40,13 @@ def combine_relnotes(relnote_dir, with_rst_labels): versions.append(version) version_date[version] = date else: - match = re_nyr.match(contents[0]) - version = match.group(1) - - versions_nyr.append(version) + match = re_nyr.match(str(contents[0])) if not match: raise Exception('No version match for %s' % (f)) + version = match.group(1) + versions_nyr.append(version) + version_contents[version] = (''.join(contents)).strip() def make_label(v): @@ -76,7 +83,7 @@ def main(args = None): if args is None: args = sys.argv - print combine_relnotes(args[1], True) + print(combine_relnotes(args[1], True)) if __name__ == '__main__': sys.exit(main()) diff --git a/src/scripts/install.py b/src/scripts/install.py index 82b1155b7..daa4a928e 100755 --- a/src/scripts/install.py +++ b/src/scripts/install.py @@ -1,4 +1,11 @@ -#!/usr/bin/env python2 +#!/usr/bin/python + +""" +Botan install script +(C) 2014,2015 Jack Lloyd + +Distributed under the terms of the Botan license +""" import errno import logging @@ -8,6 +15,9 @@ import shutil import string import sys +if 'dont_write_bytecode' in sys.__dict__: + sys.dont_write_bytecode = True + from botan_version import release_major, release_minor import combine_relnotes @@ -26,7 +36,7 @@ def parse_command_line(args): parser.add_option_group(build_group) install_group = optparse.OptionGroup(parser, 'Installation options') - install_group.add_option('--destdir', default='/tmp/local', + install_group.add_option('--destdir', default='/usr/local', help='Set output directory (default %default)') install_group.add_option('--bindir', default='bin', metavar='DIR', help='Set binary subdir (default %default)') @@ -94,13 +104,13 @@ def main(args = None): (options, args) = parse_command_line(args) - exe_mode = 0777 + exe_mode = 0o777 if 'umask' in os.__dict__: umask = int(options.umask, 8) logging.debug('Setting umask to %s' % oct(umask)) os.umask(int(options.umask, 8)) - exe_mode &= (umask ^ 0777) + exe_mode &= (umask ^ 0o777) def copy_executable(src, dest): shutil.copyfile(src, dest) @@ -195,7 +205,7 @@ def main(args = None): with open(os.path.join(botan_doc_dir, 'license.txt'), 'w+') as lic: lic.write(license_text('doc/license.rst')) - with open(os.path.join(botan_doc_dir, 'news.txt'), 'w+') as news: + with combine_relnotes.open_for_utf8(os.path.join(botan_doc_dir, 'news.txt'), 'w+') as news: news.write(combine_relnotes.combine_relnotes('doc/relnotes', False)) logging.info('Botan %s installation complete', build_vars['version']) @@ -206,5 +216,5 @@ if __name__ == '__main__': except Exception as e: logging.error('Failure: %s' % (e)) import traceback - logging.debug(traceback.format_exc()) + logging.info(traceback.format_exc()) sys.exit(1) |