From f0a228516f6394695e16dfd0742a6107616433ce Mon Sep 17 00:00:00 2001 From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Thu, 29 Jul 2010 12:11:26 +0000 Subject: [PATCH] deploy.py --bundle creates an installer-free application bundle git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2608 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- deployment/macos/bundle.py | 36 +++++++++++++++++++++----------- deployment/macos/deploy.py | 22 ++++++++++++++++--- deployment/macos/deps.py | 2 +- modules/gui/pymod/dng/termuse.py | 3 ++- 4 files changed, 46 insertions(+), 17 deletions(-) diff --git a/deployment/macos/bundle.py b/deployment/macos/bundle.py index 5b7e4c113..01d25441b 100644 --- a/deployment/macos/bundle.py +++ b/deployment/macos/bundle.py @@ -43,31 +43,43 @@ def _WriteInfoPList(bundle): info_plist.write(INFO_PLIST) info_plist.close() -def _WriteScript(bundle): - script="""#!/bin/sh - if [ -e $HOME/Library/OpenStructure/bin/dng ]; then - $HOME/Library/OpenStructure/bin/dng - else - /Library/OpenStructure/bin/dng - fi - """ +def _WriteScript(bundle, standalone): + if standalone: + script="""#!/bin/sh +if [ -h "$0" ] ; then + SCRIPT_NAME=`readlink "$0"` +else + SCRIPT_NAME="$0" +fi +`dirname "$SCRIPT_NAME"`/../bin/dng + """ + else: + script="""#!/bin/sh +if [ -e $HOME/Library/OpenStructure/bin/dng ]; then + $HOME/Library/OpenStructure/bin/dng +else + /Library/OpenStructure/bin/dng +fi + """ bin_path=os.path.join('%s.app' % bundle, 'Contents/MacOS/dng') bin=open(bin_path, 'w+') bin.write(script) bin.close() os.system('chmod a+x %s' % bin_path) -def _CreateBundleSkeleton(bundle): +def _CreateBundleSkeleton(bundle, standalone): bin_path=os.path.join('%s.app' % bundle, 'Contents/MacOS') if not os.path.exists(bin_path): os.makedirs(bin_path) _WritePkgInfo(bundle) _WriteInfoPList(bundle) - _WriteScript(bundle) + _WriteScript(bundle, standalone) res_dir='%s.app/Contents/Resources' % bundle if not os.path.exists(res_dir): os.makedirs(res_dir) copy('../../graphics/icon.icns', res_dir) -def create_bundle(bundle_name): - _CreateBundleSkeleton(bundle_name) \ No newline at end of file +def create_bundle(bundle_name, standalone=False): + _CreateBundleSkeleton(bundle_name, standalone) + if standalone: + os.system('mv standalone/* DNG.app/Contents/') \ No newline at end of file diff --git a/deployment/macos/deploy.py b/deployment/macos/deploy.py index d87a6a06b..60d45e647 100644 --- a/deployment/macos/deploy.py +++ b/deployment/macos/deploy.py @@ -1,7 +1,23 @@ import bundle import deps import sys -bundle.create_bundle('DNG') +from optparse import OptionParser +import shutil +import os +p=OptionParser() +p.add_option('--bundle', action='store_true', default=False) +p.add_option('--no_rpath', action='store_true', + default=False) +p.add_option('--macports_workaround', action='store_true', default=False) +opts, args=p.parse_args() deps.make_standalone('../../stage', 'standalone', True, - '--no-rpath' in sys.argv, - macports_workaround='--macports-workaround' in sys.argv) + opts.no_rpath, + macports_workaround=opts.macports_workaround) +if os.path.exists('DNG.app'): + shutil.rmtree('DNG.app') +bundle.create_bundle('DNG', opts.bundle) +if opts.bundle: + shutil.copytree('../../examples', 'DNG.app/Contents/examples') + os.system('rm `find DNG.app/Contents/examples/ -name "*.pyc"`') + os.system('rm -rf DNG.app/Contents/examples/harmony') + os.system('rm -rf DNG.app/Contents/examples/dokk') \ No newline at end of file diff --git a/deployment/macos/deps.py b/deployment/macos/deps.py index b7c10b676..f335dcfa4 100644 --- a/deployment/macos/deps.py +++ b/deployment/macos/deps.py @@ -252,7 +252,7 @@ def make_standalone(stage_dir, outdir, no_includes, force_no_rpath=False, framework_path=os.path.join(outdir, 'lib/Python.framework') nonstd_python=True copied_py_framework=True - if glob.glob(os.path.join(outdir, 'lib', 'libpython*'))>0: + if len(glob.glob(os.path.join(outdir, 'lib', 'libpython*')))>0: non_std_python=True if non_std_python: print 'looks like we are using a non-standard python.' diff --git a/modules/gui/pymod/dng/termuse.py b/modules/gui/pymod/dng/termuse.py index 13341a0ca..8f90c4c47 100644 --- a/modules/gui/pymod/dng/termuse.py +++ b/modules/gui/pymod/dng/termuse.py @@ -25,7 +25,8 @@ class TerminalUsageDialog(QDialog): self.path_combo=QComboBox() self.path_combo.setFixedWidth(150) for path in os.getenv('PATH').split(':'): - if os.path.exists(os.path.expanduser(path)): + exp_path=os.path.expanduser(path) + if os.path.exists(exp_path) and exp_path.find('DNG.app')==-1: self.path_combo.addItem(path) l2.addWidget(self.path_combo) l.addLayout(l2) -- GitLab