[hdf-compass] 110/295: Updates to the PyInstaller mechanism (3.0 features)

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun May 8 10:35:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository hdf-compass.

commit da5f6f49b6e8b86c5bd95f741116fb4e748b6f81
Author: giumas <giumas at yahoo.it>
Date:   Tue Oct 6 09:49:17 2015 -0400

    Updates to the PyInstaller mechanism (3.0 features)
---
 HDFCompass.1file.spec           |  85 +++++++++++++++++++++++++++++++++++++++
 HDFCompass.1folder.spec         |  86 ++++++++++++++++++++++++++++++++++++++++
 compass.icns => HDFCompass.icns | Bin
 compass.ico => HDFCompass.ico   | Bin
 HDFCompass.spec                 |  46 ---------------------
 README.md                       |  18 ++++++---
 6 files changed, 183 insertions(+), 52 deletions(-)

diff --git a/HDFCompass.1file.spec b/HDFCompass.1file.spec
new file mode 100644
index 0000000..f9215bb
--- /dev/null
+++ b/HDFCompass.1file.spec
@@ -0,0 +1,85 @@
+##############################################################################
+# Copyright by The HDF Group.                                                #
+# All rights reserved.                                                       #
+#                                                                            #
+# This file is part of the HDF Compass Viewer. The full HDF Compass          #
+# copyright notice, including terms governing use, modification, and         #
+# terms governing use, modification, and redistribution, is contained in     #
+# the file COPYING, which can be found at the root of the source code        #
+# distribution tree.  If you do not have access to this file, you may        #
+# request a copy from help at hdfgroup.org.                                     #
+##############################################################################
+
+# Builds a single-file EXE for distribution.
+# Note that an "unbundled" distribution launches much more quickly, but
+# requires an installer program to distribute.
+#
+# To compile, execute the following within the source directory:
+#
+# pyinstaller --clean -y HDFCompass.1file.spec
+#
+# The resulting .exe file is placed in the dist/ folder.
+
+from PyInstaller.building.build_main import Analysis, PYZ, EXE, COLLECT, BUNDLE, TOC
+from PyInstaller import is_darwin
+import os
+
+
+def collect_pkg_data(package, include_py_files=False, subdir=None):
+    """ helper function to collect data based on the passed package """
+    from PyInstaller.utils.hooks import get_package_paths, remove_prefix, PY_IGNORE_EXTENSIONS
+
+    # Accept only strings as packages.
+    if type(package) is not str:
+        raise ValueError
+
+    pkg_base, pkg_dir = get_package_paths(package)
+    if subdir:
+        pkg_dir = os.path.join(pkg_dir, subdir)
+    # Walk through all file in the given package, looking for data files.
+    data_toc = TOC()
+    for dir_path, dir_names, files in os.walk(pkg_dir):
+        for f in files:
+            extension = os.path.splitext(f)[1]
+            if include_py_files or (extension not in PY_IGNORE_EXTENSIONS):
+                source_file = os.path.join(dir_path, f)
+                dest_folder = remove_prefix(dir_path, os.path.dirname(pkg_base) + os.sep)
+                dest_file = os.path.join(dest_folder, f)
+                data_toc.append((dest_file, source_file, 'DATA'))
+
+    return data_toc
+
+pkg_data_hdf_compass = collect_pkg_data('hdf_compass')
+
+if is_darwin:
+    icon_file = os.path.abspath('HDFCompass.icns')
+else:
+    icon_file = os.path.abspath('HDFCompass.ico')
+if not os.path.exists(icon_file):
+    raise RuntimeError("invalid path to icon: %s" % icon_file)
+
+a = Analysis(['HDFCompass.py'],
+             pathex=[],
+             hiddenimports=[],
+             excludes=["PySide"],  # exclude libraries from being bundled (in case that are installed)
+             hookspath=None,
+             runtime_hooks=None)
+
+pyz = PYZ(a.pure)
+exe = EXE(pyz,
+          a.scripts,
+          a.binaries,
+          a.zipfiles,
+          a.datas,
+          pkg_data_hdf_compass,
+          name='HDFCompass',
+          debug=False,
+          strip=None,
+          upx=False,
+          console=True,
+          icon=icon_file)
+if is_darwin:
+    app = BUNDLE(exe,
+                 name='HDFCompass',
+                 icon=icon_file,
+                 bundle_identifier=None)
diff --git a/HDFCompass.1folder.spec b/HDFCompass.1folder.spec
new file mode 100644
index 0000000..f1ba5f3
--- /dev/null
+++ b/HDFCompass.1folder.spec
@@ -0,0 +1,86 @@
+##############################################################################
+# Copyright by The HDF Group.                                                #
+# All rights reserved.                                                       #
+#                                                                            #
+# This file is part of the HDF Compass Viewer. The full HDF Compass          #
+# copyright notice, including terms governing use, modification, and         #
+# terms governing use, modification, and redistribution, is contained in     #
+# the file COPYING, which can be found at the root of the source code        #
+# distribution tree.  If you do not have access to this file, you may        #
+# request a copy from help at hdfgroup.org.                                     #
+##############################################################################
+
+# Builds a single-file EXE for distribution.
+# Note that an "unbundled" distribution launches much more quickly, but
+# requires an installer program to distribute.
+#
+# To compile, execute the following within the source directory:
+#
+# pyinstaller --clean -y HDFCompass.1folder.spec
+#
+# The resulting .exe file is placed in the dist/HDFCompass folder.
+
+from PyInstaller.building.build_main import Analysis, PYZ, EXE, COLLECT, BUNDLE, TOC
+from PyInstaller import is_darwin
+import os
+
+
+def collect_pkg_data(package, include_py_files=False, subdir=None):
+    """ helper function to collect data based on the passed package """
+    from PyInstaller.utils.hooks import get_package_paths, remove_prefix, PY_IGNORE_EXTENSIONS
+
+    # Accept only strings as packages.
+    if type(package) is not str:
+        raise ValueError
+
+    pkg_base, pkg_dir = get_package_paths(package)
+    if subdir:
+        pkg_dir = os.path.join(pkg_dir, subdir)
+    # Walk through all file in the given package, looking for data files.
+    data_toc = TOC()
+    for dir_path, dir_names, files in os.walk(pkg_dir):
+        for f in files:
+            extension = os.path.splitext(f)[1]
+            if include_py_files or (extension not in PY_IGNORE_EXTENSIONS):
+                source_file = os.path.join(dir_path, f)
+                dest_folder = remove_prefix(dir_path, os.path.dirname(pkg_base) + os.sep)
+                dest_file = os.path.join(dest_folder, f)
+                data_toc.append((dest_file, source_file, 'DATA'))
+
+    return data_toc
+
+pkg_data_hdf_compass = collect_pkg_data('hdf_compass')
+
+if is_darwin:
+    icon_file = os.path.abspath('HDFCompass.icns')
+else:
+    icon_file = os.path.abspath('HDFCompass.ico')
+if not os.path.exists(icon_file):
+    raise RuntimeError("invalid path to icon: %s" % icon_file)
+
+a = Analysis(['HDFCompass.py'],
+             pathex=[],
+             hiddenimports=[],
+             excludes=["PySide"],  # exclude libraries from being bundled (in case that are installed)
+             hookspath=None,
+             runtime_hooks=None)
+
+pyz = PYZ(a.pure)
+exe = EXE(pyz,
+          a.scripts,
+          exclude_binaries=True,
+          name='HDFCompass',
+          debug=False,
+          strip=None,
+          upx=True,
+          console=True,
+          icon=icon_file)
+coll = COLLECT(exe,
+               a.binaries,
+               a.zipfiles,
+               a.datas,
+               pkg_data_hdf_compass,
+               strip=None,
+               upx=True,
+               name='HDFCompass')
+
diff --git a/compass.icns b/HDFCompass.icns
similarity index 100%
rename from compass.icns
rename to HDFCompass.icns
diff --git a/compass.ico b/HDFCompass.ico
similarity index 100%
rename from compass.ico
rename to HDFCompass.ico
diff --git a/HDFCompass.spec b/HDFCompass.spec
deleted file mode 100644
index 40824b0..0000000
--- a/HDFCompass.spec
+++ /dev/null
@@ -1,46 +0,0 @@
-##############################################################################
-# Copyright by The HDF Group.                                                #
-# All rights reserved.                                                       #
-#                                                                            #
-# This file is part of the HDF Compass Viewer. The full HDF Compass          #
-# copyright notice, including terms governing use, modification, and         #
-# terms governing use, modification, and redistribution, is contained in     #
-# the file COPYING, which can be found at the root of the source code        #
-# distribution tree.  If you do not have access to this file, you may        #
-# request a copy from help at hdfgroup.org.                                     #
-##############################################################################
-
-# Builds a single-file EXE for distribution.
-# Note that an "unbundled" distribution launches much more quickly, but
-# requires an installer program to distribute.
-#
-# To compile, execute the following within the source directory:
-#
-# python /path/to/pyinstaller.py HDFCompass.spec
-#
-# The resulting .exe file is placed in the dist/ folder.
-
-a = Analysis(['HDFCompass.py'],
-             pathex=[],
-             hiddenimports=[],
-             hookspath=None,
-             runtime_hooks=None)
-             
-# The following block is necessary to prevent a hard crash when launching
-# the resulting .exe file
-for d in a.datas:
-    if 'pyconfig' in d[0]: 
-        a.datas.remove(d)
-        break
-        
-pyz = PYZ(a.pure)
-exe = EXE(pyz,
-          a.scripts,
-          a.binaries,
-          a.zipfiles,
-          a.datas,
-          name='HDFCompass.exe',
-          debug=False,
-          strip=None,
-          upx=False,
-          console=False, icon='compass.ico')
diff --git a/README.md b/README.md
index 5d7d0af..f036288 100644
--- a/README.md
+++ b/README.md
@@ -25,13 +25,13 @@ You will need:
 * Python 2.7
 * NumPy
 * Matplotlib
-* wxPython Phoenix (2.9.5.0 or later)
+* wxPython Phoenix *(2.9.5.0 or later)*
 * h5py
 
 For packaging the app:
 
+* PyInstaller (Linux & Windows, experimental for OS X) *(>= 3.0)*
 * Py2App (OS X)
-* PyInstaller (Linux & Windows)
 
 Running the Program  
 --------------------
@@ -56,11 +56,17 @@ Packaging on OS X
 Packaging on Windows
 --------------------
 
-    $ pyinstaller HDFCompass.spec
+Single-file:
+
+    $ pyinstaller --clean -y HDFCompass.1file.spec
+
+Single-folder (useful for debugging the `pyinstaller` settings):
+
+    $ pyinstaller --clean -y HDFCompass.1folder.spec
     
 Other info
 ----------
 
-* Github: http://github.com/HDFGroup/hdf-compass
-* Project page: https://www.hdfgroup.org/projects/compass/
-* License: BSD-like HDF Group license (See COPYING)
+* Github: [http://github.com/HDFGroup/hdf-compass](http://github.com/HDFGroup/hdf-compass)
+* Project page: [https://www.hdfgroup.org/projects/compass/](https://www.hdfgroup.org/projects/compass/)
+* License: BSD-like HDF Group license (See [COPYING](https://raw.githubusercontent.com/HDFGroup/hdf-compass/master/COPYING))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/hdf-compass.git



More information about the debian-science-commits mailing list