[meld: 1/3] prepare for ci mingw building:



commit 15b8ff319440dc4a574c203361a280420fc8548e
Author: Vasily Galkin <galkin-vv ya ru>
Date:   Fri Jul 6 23:53:51 2018 +0300

    prepare for ci mingw building:
    
    -moved copying of huge data (adwaita icons) to install_data stage
    instead of build_exe stage to minimize copyings count.
    -pygobject-win32 support dropped
    -worked around autoinclusion of gdiplus
    -disable bytecompilation of files included in
    lib\python3.6\site-packages\meld\
    since they can be used only by humans reading source,
    not by freezed executable
    -simplify zip building by providing empty install prefix by default
    
    -appveyour build broken by now, but appveyour.yml has a new cmdline
    for fast building zip and msi from single folder,
    which eliminates one more copying of icons.

 appveyor.yml   |  3 +--
 setup_win32.py | 81 +++++++++++++++++++++++++++++++++-------------------------
 2 files changed, 47 insertions(+), 37 deletions(-)
---
diff --git a/appveyor.yml b/appveyor.yml
index 002f1ea4..92b9bf42 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -45,8 +45,7 @@ install:
 build_script:
   - cmd: |
       %PYTHON_PREFIX%\Lib\site-packages\gnome\glib-compile-schemas data
-      %PYTHON_PREFIX%\python setup_win32.py bdist_msi
-      %PYTHON_PREFIX%\python setup_win32.py install --root build/install_root --prefix . bdist_dumb
+      %PYTHON_PREFIX%\python setup_win32.py bdist_dumb --bdist-dir build\bdist.mingw\msi --keep-temp 
bdist_msi --keep-temp
 
 artifacts:
   - path: dist/*.msi
diff --git a/setup_win32.py b/setup_win32.py
index 9289b945..90cd9f3e 100755
--- a/setup_win32.py
+++ b/setup_win32.py
@@ -12,33 +12,21 @@ import meld.build_helpers
 import meld.conf
 
 
-def get_non_python_dependencies():
+def get_non_python_libs():
     """Returns list of tuples containing extra dependencies required to run
     meld on current platform.
-    Every pair corresponds to a single required file/folder.
+    Every pair corresponds to a single library file.
     First tuple item correspond to path expected in meld installation
     relative to meld prefix.
     Second tuple item is path in local filesystem during build.
-    Note that for returned dynamic libraries their dependencies
+    Note that for returned dynamic libraries and executables dependencies
     are expected to be resolved by caller, for example by cx_freeze.
     """
-    gtk_prefix = sys.prefix
-    gtk_exec_prefix = sys.prefix
-    sysconfig_platform = sysconfig.get_platform()
-
-    gtk_data = [
-        'etc/fonts',
-        'etc/gtk-3.0/settings.ini',
-        'lib/gdk-pixbuf-2.0',
-        'lib/girepository-1.0',
-        'share/fontconfig',
-        'share/glib-2.0',
-        'share/gtksourceview-3.0',
-        'share/icons',
-    ]
+    gtk_exec_prefix = os.path.join(sys.prefix, "bin")
+
     gtk_exec = []
 
-    if 'mingw' in sysconfig_platform:
+    if 'mingw' in sysconfig.get_platform():
         # dll imported by dll dependencies expected to be auto-resolved later
         gtk_exec = [
             'libgtksourceview-3.0-1.dll',
@@ -49,29 +37,48 @@ def get_non_python_dependencies():
             gtk_exec.append('gspawn-win32-helper.exe')
         else:
             gtk_exec.append('gspawn-win64-helper.exe')
-        gtk_exec_prefix = os.path.join(gtk_exec_prefix, "bin")
-    elif 'win32' in sysconfig_platform or 'win-amd64' in sysconfig_platform:
-        # Official python on windows (non-mingw)
-        # The required gtk version isn't available,
-        # so kept mostly for temporarily keep appveyour build green.
-        gtk_exec = [
-            'libgtk-3-0.dll',
-        ]
-        gtk_prefix = os.path.join(gtk_prefix, "Lib", "site-packages", "gnome")
-        gtk_exec_prefix = gtk_prefix
 
-    path_list = [(os.path.join(gtk_prefix, path), path) for path in gtk_data]
-    path_list += [
-        (os.path.join(gtk_exec_prefix, path), path) for path in gtk_exec
-    ]
-    return path_list
+    return [(os.path.join(gtk_exec_prefix, path), path) for path in gtk_exec]
+
+
+gtk_data_dirs = [
+    'etc/fonts',
+    'etc/gtk-3.0',
+    'lib/gdk-pixbuf-2.0',
+    'lib/girepository-1.0',
+    'share/fontconfig',
+    'share/glib-2.0',
+    'share/gtksourceview-3.0',
+    'share/icons',
+]
 
+gtk_data_files = []
+for data_dir in gtk_data_dirs:
+    local_data_dir = os.path.join(sys.prefix, data_dir)
+
+    for local_data_subdir, dirs, files in os.walk(local_data_dir):
+        data_subdir = os.path.relpath(local_data_subdir, local_data_dir)
+        gtk_data_files.append((
+            os.path.join(data_dir, data_subdir),
+            [os.path.join(local_data_subdir, file) for file in files]
+        ))
+
+# add libgdk_pixbuf-2.0-0.dll manually to forbid auto-pulling of gdiplus.dll
+manually_added_libs = {
+    "libgdk_pixbuf-2.0-0.dll": os.path.join(sys.prefix, 'bin'),
+    }
+
+for lib, possible_path in manually_added_libs.items():
+    local_lib = os.path.join(possible_path, lib)
+    if os.path.isfile(local_lib):
+        gtk_data_files.append((os.path.dirname(lib), [local_lib]))
 
 build_exe_options = {
     "includes": ["gi"],
     "excludes": ["tkinter"],
     "packages": ["gi", "weakref"],
-    "include_files": get_non_python_dependencies(),
+    "include_files": get_non_python_libs(),
+    "bin_excludes": list(manually_added_libs.keys()),
     "zip_exclude_packages": [],
     "zip_include_packages": ["*"],
 }
@@ -137,6 +144,10 @@ setup(
     options={
         "build_exe": build_exe_options,
         "bdist_msi": bdist_msi_options,
+        #  cx_freeze + bdist_dumb fails on non-empty prefix
+        "install": {"prefix": "."},
+        #  freezed binary doesn't use source files, they are only for humans
+        "install_lib": {"compile": False},
     },
     executables=[
         Executable(**executable_options),
@@ -171,7 +182,7 @@ setup(
         ('share/meld/ui',
          glob.glob("data/ui/*.ui") + glob.glob("data/ui/*.xml")
          ),
-    ],
+    ] + gtk_data_files,
     cmdclass={
         "build_i18n": meld.build_helpers.build_i18n,
         "build_help": meld.build_helpers.build_help,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]