From b2cc17d5e7895d14337d81a189519e806cd4d40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 28 Jun 2018 02:01:56 +0200 Subject: [PATCH] Update setup freeze to Python3 - Use python3 shebang - Open gir with utf-8 encoding - Replace user module by executing ~/.pythonrc.py issue7488 --- make-darwin-installer.sh | 6 +++--- make-win32-installer.sh | 6 +++--- setup-freeze.py | 21 +++++++++++++++++---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/make-darwin-installer.sh b/make-darwin-installer.sh index 46d7653917..ccc17d3686 100644 --- a/make-darwin-installer.sh +++ b/make-darwin-installer.sh @@ -1,8 +1,8 @@ #!/bin/sh set -e -version=`python setup.py --version` -python setup.py compile_catalog -python setup-freeze.py bdist_mac +version=`./setup.py --version` +./setup.py compile_catalog +./setup-freeze.py bdist_mac rm -rf dist mkdir dist mv build/Tryton.app dist/ diff --git a/make-win32-installer.sh b/make-win32-installer.sh index 1aa22c8126..c07da1f546 100644 --- a/make-win32-installer.sh +++ b/make-win32-installer.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -version=`python setup.py --version` +version=`./setup.py --version` series=${version%.*} -python setup.py compile_catalog -python setup-freeze.py install_exe -d dist +./setup.py compile_catalog +./setup-freeze.py install_exe -d dist makensis -DVERSION=${version} -DSERIES=${series} setup.nsi diff --git a/setup-freeze.py b/setup-freeze.py index 0147056bfa..1bfb94c3b8 100644 --- a/setup-freeze.py +++ b/setup-freeze.py @@ -1,12 +1,24 @@ +#!/usr/bin/env python3 +# This file is part of Tryton. The COPYRIGHT file at the top level of +# this repository contains the full copyright notices and license terms. + import os import re import sys import tempfile -import user from subprocess import Popen, PIPE, check_call from cx_Freeze import setup, Executable +home = os.path.expanduser('~/') +pythonrc = os.path.join(home, '.pythonrc.py') +try: + with open(pythonrc) as fp: + exec(fp.read()) +except IOError: + pass + + include_files = [ (os.path.join('tryton', 'data'), 'data'), (os.path.join('tryton', 'plugins'), 'plugins'), @@ -60,9 +72,10 @@ for ns in required_gi_namespaces: gir_name = '%s.gir' % ns gir_file = os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name) gir_tmp = os.path.join(temp, gir_name) - with open(gir_file, 'r') as src, open(gir_tmp, 'w') as dst: - for line in src: - dst.write(lib_re.sub(replace_path, line)) + with open(gir_file, 'r', encoding='utf-8') as src: + with open(gir_tmp, 'w', encoding='utf-8') as dst: + for line in src: + dst.write(lib_re.sub(replace_path, line)) typefile_name = '%s.typelib' % ns typefile_file = os.path.join('lib', 'girepository-1.0', typefile_name) typefile_tmp = os.path.join(temp, typefile_name)