Skip to content

Commit

Permalink
Update Windows-packaging scripts
Browse files Browse the repository at this point in the history
Part of #23
  • Loading branch information
otsaloma committed Jul 8, 2016
1 parent 02ba65b commit ff7ce84
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,3 +11,4 @@ data/patterns/*.hearing-impaired
data/patterns/*.line-break
dist
locale
winsetup.log
7 changes: 7 additions & 0 deletions manifests/clean.manifest
@@ -1,7 +1,13 @@
__pycache__
*/__pycache__
*/*/__pycache__
*/*/*/__pycache__
*/*/*/*/__pycache__
.cache
*/.cache
*/*/.cache
*/*/*/.cache
*/*/*/*/.cache
build
data/extensions/*/*.extension
data/gaupol.appdata.xml
Expand All @@ -14,3 +20,4 @@ dist
locale
po/*~
MANIFEST
winsetup.log
11 changes: 11 additions & 0 deletions setup.py
Expand Up @@ -40,6 +40,8 @@
import re
import shutil

freezing = "GAUPOL_FREEZING" in os.environ

clean = distutils.command.clean.clean
distribution = distutils.dist.Distribution
install = distutils.command.install.install
Expand Down Expand Up @@ -78,6 +80,12 @@ def get_gaupol_version():

def run_or_exit(cmd):
"""Run command in shell and raise SystemExit if it fails."""
if freezing and cmd.startswith("intltool-merge"):
# intltool-merge is not available on Windows.
ifile, ofile = re.split(" +", cmd)[-2:]
text = open(ifile, "r", encoding="utf_8").read()
return open(ofile, "w", encoding="utf_8").write(
re.sub("^_", "", text, flags=re.MULTILINE))
if os.system(cmd) != 0:
log.error("command {} failed".format(repr(cmd)))
raise SystemExit(1)
Expand Down Expand Up @@ -114,6 +122,8 @@ class Distribution(distribution):

def __init__(self, attrs=None):
"""Initialize a :class:`Distribution` instance."""
if freezing:
self.executables = []
self.mandir = "share/man"
self.with_aeidon = True
self.with_gaupol = True
Expand Down Expand Up @@ -276,6 +286,7 @@ def run(self):
"""Install data files after translating them."""
if self.distribution.with_aeidon:
for po_file in glob.glob("po/*.po"):
if freezing: continue
self.data_files.append(self.__get_mo_file(po_file))
for pattern_file in glob.glob("data/patterns/*.in"):
self.data_files.append(self.__get_pattern_file(pattern_file))
Expand Down
30 changes: 30 additions & 0 deletions win32/RELEASING.md
@@ -0,0 +1,30 @@
Releasing a New Windows Installer
=================================

* Install the latest 32-bit Python 3.4.x
* Install dependencies with PIP

```
cd C:\Python34\Scripts
pip3 install chardet
pip3 install cx_Freeze
pip3 install pyenchant
pip3 install pypiwin32
```

* Install PyGObject all-in-one for Windows (pygi-aio)
- GTK+, GtkSpell 3, iso-codes and GIR
* Install Inno Setup
* Test, build, test build

```
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
C:\Python34\python.exe bin\gaupol
win32\build.bat
win32\test-build.bat
# If needed, enable a console window to see output:
# winsetup.py: s/base="Win32GUI"/base=None/
```

* Update version numbers in `win32/gaupol.iss` and compile with Inno Setup
* Install Gaupol and check that it works
9 changes: 9 additions & 0 deletions win32/build.bat
@@ -0,0 +1,9 @@
:: -*- coding: us-ascii-unix -*-
cd "%~dp0\.."
set GAUPOL_FREEZING=1
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Python34
python setup.py clean
python setup.py install_data -d build\usr
python winsetup.py build > winsetup.log
del /s /q build\exe.win32-3.4\share\gir-1.0 > NUL
del /s /q build\exe.win32-3.4\share\locale > NUL
24 changes: 24 additions & 0 deletions win32/gaupol.iss
@@ -0,0 +1,24 @@
; -*- conf -*-

[Setup]
AllowNoIcons=yes
AppName=Gaupol
AppPublisher=Osmo Salomaa
AppPublisherURL=http://otsaloma.io/gaupol/
AppVerName=Gaupol 0.90.20160708
Compression=lzma
DefaultDirName={pf}\Gaupol
DefaultGroupName=Gaupol
OutputBaseFilename=gaupol-0.90.20160708-win32
OutputDir=".."
SolidCompression=yes

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "..\build\exe.win32-3.4\*"; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs

[Icons]
Name: "{commonprograms}\Gaupol"; Filename: "{app}\gaupol.exe"
Name: "{commondesktop}\Gaupol"; Filename: "{app}\gaupol.exe"; Tasks: desktopicon
4 changes: 4 additions & 0 deletions win32/test-build.bat
@@ -0,0 +1,4 @@
:: -*- coding: us-ascii-unix -*-
cd "%~dp0\.."
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
build\exe.win32-3.4\gaupol.exe
46 changes: 46 additions & 0 deletions winsetup.py
@@ -0,0 +1,46 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""cx_Freeze installation routines built on top of normal setup.py."""

import glob
import os
import site

os.environ["GAUPOL_FREEZING"] = "1"
from setup import *
import cx_Freeze

includes = ["aeidon", "cairo", "gaupol", "gi"]
include_files = [(os.path.join("build", "usr", "share"), "share")]
site_path = site.getsitepackages()[1]

gnome_path = os.path.join(site_path, "gnome")
for dll in glob.glob("{}\\*.dll".format(gnome_path)):
include_files.append((dll, os.path.basename(dll)))
include_files.append((os.path.join(gnome_path, "etc"), "etc"))
include_files.append((os.path.join(gnome_path, "lib"), "lib"))
include_files.append((os.path.join(gnome_path, "share"), "share"))

# PyEnchant ships with DLLs provided by pygi-aio as well.
# Keep the pygio-aio DLLs, but add PyEnchant data files.
enchant_path = os.path.join(site_path, "enchant")
include_files.append((os.path.join(enchant_path, "lib"), "lib"))
include_files.append((os.path.join(enchant_path, "share"), "share"))

setup_kwargs.update(dict(
options=dict(build_exe=dict(
compressed=False,
includes=includes,
packages=includes,
include_files=include_files,
)),
executables=[cx_Freeze.Executable(
script="bin/gaupol",
base="WIN32GUI",
icon="data/icons/gaupol.ico",
)],
))

if __name__ == "__main__":
cx_Freeze.setup(**setup_kwargs)

0 comments on commit ff7ce84

Please sign in to comment.