From f07349398acb4399b25a2be01c8900c9dc273e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Tue, 2 Apr 2013 11:11:06 +0200 Subject: [PATCH] preperation for spliting into multiple files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- dependency-test.sh | 1 + setup.py | 45 ++++++++++++++++++-------- ponysay-tool.py => src/ponysay-tool.py | 0 ponysay.py => src/ponysay.py | 0 4 files changed, 33 insertions(+), 13 deletions(-) rename ponysay-tool.py => src/ponysay-tool.py (100%) rename ponysay.py => src/ponysay.py (100%) diff --git a/dependency-test.sh b/dependency-test.sh index a74463ca..05f3020d 100755 --- a/dependency-test.sh +++ b/dependency-test.sh @@ -14,6 +14,7 @@ pv=0 # python version (hash chmod 2>/dev/null) || (br=1 ; ro=1 ; echo 'Missing chmod, install coreutils [build+runtime required]') +(hash zip 2>/dev/null) || (br=1 ; echo 'Missing zip, install zip [build required]') (hash gzip 2>/dev/null) || (bo=1 ; echo 'Missing gzip, install gzip [build optional]') (hash makeinfo 2>/dev/null) || (bo=1 ; echo 'Missing makeinfo, install texinfo [build optional]') diff --git a/setup.py b/setup.py index f77866c1..2ce69d86 100755 --- a/setup.py +++ b/setup.py @@ -37,6 +37,10 @@ mansections = [('ponysay', '6'), miscfiles = [('COPYING', '/usr/share/licenses/ponysay/COPYING'), ('CREDITS', '/usr/share/licenses/ponysay/CREDITS')] +ponysaysrc = [src + '.py' for src in + ('__main__', 'common', 'ponysay', 'argparser', 'balloon', + 'backend', 'colourstack', 'ucs', 'spellocorrecter')] + @@ -404,20 +408,34 @@ class Setup(): mane = True break if mane: + for src in ponysaysrc: + try: + fileout = open('src/%s.install' % src, 'wb+') + filein = open('src/%s' % src, 'rb') + data = filein.read().decode('utf-8', 'replace') + + if '#!/usr/bin/env python3' in data: + data = data.replace('#!/usr/bin/env python3', '#!/usr/bin/env ' + env) + else: + data = data.replace('#!/usr/bin/env python', '#!/usr/bin/env ' + env) + data = data.replace('/usr/share/', conf['share-dir'] if conf['share-dir'].endswith('/') else (conf['share-dir'] + '/')) + data = data.replace('/etc/', conf['sysconf-dir'] + ('' if conf['sysconf-dir'].endswith('/') else '/')) + data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION)) + + fileout.write(data.encode('utf-8')) + finally: + if fileout is not None: fileout.close() + if filein is not None: filein .close() + try: + os.chdir('src') + os.system('zip ../ponysay.zip ' + ' '.join(ponysaysrc)) + finally: + os.chdir('..') try: fileout = open('ponysay.install', 'wb+') - filein = open('ponysay.py', 'rb') - data = filein.read().decode('utf-8', 'replace') - - if '#!/usr/bin/env python3' in data: - data = data.replace('#!/usr/bin/env python3', '#!/usr/bin/env ' + env) - else: - data = data.replace('#!/usr/bin/env python', '#!/usr/bin/env ' + env) - data = data.replace('/usr/share/', conf['share-dir'] if conf['share-dir'].endswith('/') else (conf['share-dir'] + '/')) - data = data.replace('/etc/', conf['sysconf-dir'] + ('' if conf['sysconf-dir'].endswith('/') else '/')) - data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION)) - - fileout.write(data.encode('utf-8')) + filein = open('src/%s' % src, 'rb') + fileout.write(('#!/usr/bin/env %s\n' % env).encode('utf-8')) + fileout.write(filein.read()) finally: if fileout is not None: fileout.close() if filein is not None: filein .close() @@ -721,7 +739,8 @@ class Setup(): def clean(self): print('\033[1;34m::\033[39mCleaning...\033[21m') - files = ['ponysay.info', 'ponysay.info.gz', 'ponysay.info.xz', 'ponysay.pdf.gz', 'ponysay.pdf.xz', 'ponysay.install'] + files = ['ponysay.info', 'ponysay.info.gz', 'ponysay.info.xz', 'ponysay.pdf.gz', 'ponysay.pdf.xz', 'ponysay.install', 'ponysay.zip'] + files += ['src/%s.install' % file for file in ponysaysrc] dirs = ['quotes'] for comp in ['install', 'gz', 'xz']: for man in manpages: diff --git a/ponysay-tool.py b/src/ponysay-tool.py similarity index 100% rename from ponysay-tool.py rename to src/ponysay-tool.py diff --git a/ponysay.py b/src/ponysay.py similarity index 100% rename from ponysay.py rename to src/ponysay.py