Skip to content
Permalink
Browse files

Revert to GTK 3.18 stack on Windows (#432)

  • Loading branch information...
jendrikseipp committed Mar 26, 2019
1 parent 3dab8f6 commit 591d24c3cd4f6aff2671d3bdd6b4b5e62b93daaf
Showing with 57 additions and 34 deletions.
  1. +1 −0 TODO
  2. +13 −27 appveyor.yml
  3. +2 −1 rednotebook/gui/browser_cef.py
  4. +1 −2 rednotebook/gui/main_window.py
  5. +39 −3 win/rednotebook.spec
  6. +1 −1 win/requirements.txt
1 TODO
@@ -7,6 +7,7 @@ please check back with me briefly about its status.

=== Roadmap ===

X Revert to GTK 3.18 stack on Windows (fixes #429 and #430).
O Remove imports.py.
O Update Github README file.
O Check for latest version during startup by default.
@@ -22,38 +22,24 @@ build_script:
- set VERSION
- cd win

# Install GTK stack.
- curl -Lo gtk.tar.gz https://www.dropbox.com/s/1as726i4rb2zmlg/gvsbuild-vs14-x86.tar.gz?dl=1
- tar -xzf gtk.tar.gz
- move release C:\gtk
- set PATH=%PATH%;C:\gtk\bin
# Install Python 3.4.4 and GTK 3.18 stack.
- curl -Lo python34.tar.gz https://www.dropbox.com/s/3wu38oluushvqan/python34.tar.gz?dl=1
- tar -xzf python34.tar.gz
# C:\Python34 already contains a Python installation.
- move Python34 C:\Python344
- set PATH=%PATH%;C:\Python344\Lib\site-packages\gnome
- set PYTHON=C:\Python344\python.exe
- "%PYTHON% --version"

# Install other dependencies.
- "%PYTHON% -m pip install -U pip wheel"
# Update some of the dependencies in the tarball.
# PyInstaller 3.3.1 and 3.4 both produce executables flagged by Windows.
# pip 19.1 will be the last pip version supporting Python 3.4.
- "%PYTHON% -m pip install -U pip==19.0.3 wheel==0.33.1"
- "%PYTHON% -m pip install -r requirements.txt"
- "%PYTHON% -m pip install C:/gtk/python/pycairo-1.17.1-cp36-cp36m-win32.whl C:/gtk/python/PyGObject-3.28.3-cp36-cp36m-win32.whl"

# Pyenchant wheels bundle DLLs. The bundled DLLs are incompatible to the
# DLLs we use and lead to the error "ImportError: DLL load failed: The
# specified procedure could not be found." when calling "import gi".
# Therefore, we remove the bundled DLLs and put our own DLLs in the
# places where pyenchant and PyInstaller expect them.
- rm C:/Python36/Lib/site-packages/enchant/*.dll
- rm C:/Python36/Lib/site-packages/enchant/lib/enchant/*.dll
- cp C:/gtk/bin/libenchant.dll C:/Python36/Lib/site-packages/enchant
- cp C:/gtk/lib/enchant/libenchant_*.dll C:/Python36/Lib/site-packages/enchant/lib/enchant/

# Remove bundled dictionaries and install custom ones.
- rm -r C:/Python36/Lib/site-packages/enchant/share/enchant
- curl -Lo dicts.tar.gz https://www.dropbox.com/s/f12k20aur6znpmo/myspell-dicts.tar.gz?dl=1
- tar -xzf dicts.tar.gz
- move enchant C:\Python36\Lib\site-packages\enchant\share

# Sanity check with dummy app.
- "%PYTHON% sampleapp.py"
- "%PYTHON% -m PyInstaller --debug=all --additional-hooks-dir=. sampleapp.py"
# Use clean PATH to check that everything has been copied correctly.
- cmd /C "set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem && dist\sampleapp\sampleapp.exe"
- "%PYTHON% -m PyInstaller --debug --additional-hooks-dir=. sampleapp.py"

# Create executable.
- "%PYTHON% -m PyInstaller --workpath=C:/build --distpath=C:/ rednotebook.spec"
@@ -86,7 +86,8 @@ def get_handle(self):
ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object]
gpointer = ctypes.pythonapi.PyCapsule_GetPointer(
self.get_property("window").__gpointer__, None)
libgdk = ctypes.CDLL("gdk-3-3.0.dll")
# The GTK 3.22 stack needs "gdk-3-3.0.dll".
libgdk = ctypes.CDLL("libgdk-3-0.dll")
handle = libgdk.gdk_win32_window_get_handle(gpointer)
Gdk.threads_leave()
return handle
@@ -133,8 +133,7 @@ def __init__(self, journal):
self.edit_pane = self.builder.get_object('edit_pane')
self.text_vbox = self.builder.get_object('text_vbox')

# Disable CEF preview until fixed.
use_cef = False
use_cef = True
if browser.WebKit2:
class Preview(browser.HtmlView):
def __init__(self, journal):
@@ -1,6 +1,8 @@
# -*- mode: python -*-

import os
import os.path
import site

block_cipher = None

@@ -10,24 +12,42 @@ options = [] # [('v', None, 'OPTION'), ('u', None, 'OPTION')]
drive_c = DISTPATH
basedir = os.path.join(drive_c, 'repo')
srcdir = os.path.join(basedir, 'rednotebook')
bindir = os.path.join(site.getsitepackages()[1], 'gnome')
enchantdir = os.path.join(site.getsitepackages()[1], 'enchant')
icon = os.path.join(basedir, 'win', 'rednotebook.ico')

# See also https://github.com/pyinstaller/pyinstaller/issues/1966
typelibdir = os.path.join(bindir, 'lib', 'girepository-1.0')

MISSED_BINARIES = [
os.path.join(drive_c, path) for path in [
'gtk/bin/gspawn-win32-helper.exe',
'windows/syswow64/python34.dll',
'Python344/DLLs/_ctypes.pyd',
'Python344/DLLs/_socket.pyd',
'Python344/DLLs/pyexpat.pyd',
'Python344/Lib/site-packages/gnome/gspawn-win32-helper.exe',
]
]

for path in [drive_c, basedir, srcdir, icon] + MISSED_BINARIES:
for path in [drive_c, basedir, srcdir, bindir, icon] + MISSED_BINARIES:
assert os.path.exists(path), "{} does not exist".format(path)

os.environ['PATH'] += os.pathsep + bindir
print('PATH:', os.environ['PATH'])


def Dir(path, excludes=None):
assert os.path.isdir(path), path
return Tree(path, prefix=os.path.basename(path), excludes=excludes or [])

def include_dll(name):
# Exclude some unused large dlls to save space.
return name.endswith('.dll') and name not in set([
'libwebkit2gtk-3.0-25.dll', 'libavcodec-57.dll',
'libjavascriptcoregtk-3.0-0.dll', 'libavformat-57.dll',
'libgstreamer-1.0-0.dll'])


a = Analysis([os.path.join(srcdir, 'journal.py')],
pathex=[basedir],
binaries=[],
@@ -40,7 +60,19 @@ a = Analysis([os.path.join(srcdir, 'journal.py')],
win_private_assemblies=False,
cipher=block_cipher)
# Adding these files in the ctor mangles up the paths.
a.binaries += [(os.path.basename(path), path, 'BINARY') for path in MISSED_BINARIES]
a.binaries += ([
(os.path.join('gi_typelibs', tl), os.path.join(typelibdir, tl), 'BINARY') for tl in os.listdir(typelibdir)] + [
(name, os.path.join(bindir, name), 'BINARY') for name in os.listdir(bindir) if include_dll(name)] + [
(os.path.basename(path), path, 'BINARY') for path in MISSED_BINARIES] + [
('gi._gi.pyd', os.path.join(drive_c, 'Python344/Lib/site-packages/gi/_gi.pyd'), 'BINARY'),
('gi._gi_cairo.pyd', os.path.join(drive_c, 'Python344/Lib/site-packages/gi/_gi_cairo.pyd'), 'BINARY'),
])

# We need to manually copy the enchant directory, because we want to omit
# the DLLs and include the Python files. Keeping the DLLs leads to errors,
# because then there are multiple versions of the same DLL.
a.binaries = [(dest, source, _) for (dest, source, _) in a.binaries if not dest.startswith('enchant')]
a.datas = [(dest, source, _) for (dest, source, _) in a.datas if not dest.startswith('enchant')]

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(pyz,
@@ -60,6 +92,10 @@ coll = COLLECT(exe,
a.datas,
Dir(os.path.join(srcdir, 'files')),
Dir(os.path.join(srcdir, 'images')),
Dir(os.path.join(bindir, 'etc')),
Dir(os.path.join(bindir, 'lib'), excludes=['girepository-1.0', 'gstreamer-1.0']),
Dir(os.path.join(bindir, 'share'), excludes=['gir-1.0', 'gstreamer-1.0', 'webkitgtk-3.0']),
Dir(enchantdir, excludes=['*.dll']),
strip=False,
upx=True,
name='dist')
@@ -2,7 +2,7 @@ cefpython3==66.0
pyenchant==2.0.0
pefile==2018.8.8
pyinstaller==3.4
pypiwin32==223
pypiwin32==219
PyYAML==3.13
setuptools==40.6.2
six==1.11.0

0 comments on commit 591d24c

Please sign in to comment.
You can’t perform that action at this time.