[PATCH 1 of 2] packaging: bundle windows-curses in the py3 installer (fixes #5780)

6 views
Skip to first unread message

Matt Harbison

unread,
May 13, 2022, 5:34:06 PM5/13/22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1652473690 14400
# Fri May 13 16:28:10 2022 -0400
# Node ID a276ddcdde1aba7a162e0b40bcc3ad92f1ef53c6
# Parent 1cfb87f6e536d6207f18f5173a4c0cb253d45577
# EXP-Topic windows-py3-packaging
packaging: bundle windows-curses in the py3 installer (fixes #5780)

It's a trivial workaround for the upstream issue, and I don't feel like waiting
for it to be fixed and released.

diff --git a/contrib/packaging/thgpackaging/py2exe.py b/contrib/packaging/thgpackaging/py2exe.py
--- a/contrib/packaging/thgpackaging/py2exe.py
+++ b/contrib/packaging/thgpackaging/py2exe.py
@@ -305,7 +305,7 @@
fp.write('''
[py2exe]
includes = PyQt5.sip, PyQt5.QtPrintSupport, PyQt5.QtSvg, PyQt5.QtXml,
- mercurial_keyring, pygit2
+ mercurial_keyring, pygit2, _curses, _curses_panel

packages = ctypes, curses, dulwich, email, encodings, iniparse, json, keyring,
keyring.backends, nntplib, pygments, sspi, sqlite3, six,
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -523,6 +523,15 @@
try:
import py2exe

+ if sys.version_info.major >= 3:
+ # The py3 version of py2exe hardcodes _curses in the exclusion list,
+ # assuming it is a non-Windows module. But that prevents
+ # windows-curses from being bundled.
+ #
+ # See https://github.com/py2exe/py2exe/issues/132
+ from py2exe import hooks
+ hooks.windows_excludes.remove('_curses')
+
# Help py2exe to find win32com.shell
try:
import modulefinder
diff --git a/win32/wix/dist-py3.wxs b/win32/wix/dist-py3.wxs
--- a/win32/wix/dist-py3.wxs
+++ b/win32/wix/dist-py3.wxs
@@ -85,8 +85,7 @@
<File Name="_bz2.pyd" />
<File Name="_cffi_backend.pyd" />
<File Name="_ctypes.pyd" />
- <!-- TODO: enable this when py2exe recognizes the curses module -->
- <!-- <File Name="_curses.pyd" -->
+ <File Name="_curses.pyd" />
<File Name="_curses_panel.pyd" />
<File Name="_decimal.pyd" />
<File Name="_elementtree.pyd" />
diff --git a/win32/wix/guids.wxi b/win32/wix/guids.wxi
--- a/win32/wix/guids.wxi
+++ b/win32/wix/guids.wxi
@@ -32,7 +32,7 @@
<?define templates.static.guid = {2c807a50-27ce-46c4-b8e6-1cb0be1e7105} ?>

<!-- dist.wxs -->
- <?define dist.guid = {98b18124-41af-449c-9396-202a3e0c0c41} ?>
+ <?define dist.guid = {148657a8-7dbd-438b-820a-7c7d80138e41} ?>
<?define lib.guid = {7b261357-2643-401d-90c9-b31270242927} ?>
<?define imageformats.guid = {12885995-61ed-468f-a964-3654d091138e} ?>
<?define platforms.guid = {4b2c42d4-fbb3-4449-b1df-31bf789e009e} ?>

Matt Harbison

unread,
May 13, 2022, 5:34:07 PM5/13/22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1652477503 14400
# Fri May 13 17:31:43 2022 -0400
# Node ID 24819b8590cc3f48600b2b5a7da4ad3f2def8e52
# Parent a276ddcdde1aba7a162e0b40bcc3ad92f1ef53c6
# EXP-Topic windows-py3-packaging
packaging: add instructions for building the py3 Windows installer

This was mostly copied from the same file in the Mercurial repository.

diff --git a/contrib/packaging/wix/readme.rst b/contrib/packaging/wix/readme.rst
new file mode 100644
--- /dev/null
+++ b/contrib/packaging/wix/readme.rst
@@ -0,0 +1,58 @@
+WiX Installer
+=============
+
+The files in this directory are used to produce an MSI installer using
+the WiX Toolset (http://wixtoolset.org/).
+
+Requirements
+============
+
+Building the WiX installer requires a Windows machine.
+
+The following system dependencies must be installed:
+
+* Python 3.7+ (to run the ``packaging.py`` script)
+* Visual Studio 2017 or later Build Tools
+* HTML Help Workshop 1.3 or later
+* Mercurial on ``%PATH%``
+
+The simplest way to install the requirements is to run the
+``contrib/install-windows-dependencies.ps1`` [1]_ script in the Mercurial
+repository from an elevated PowerShell. This will also allow Mercurial
+itself to be built from the Mercurial repository. The HTML Help Workshop [2]_
+package needs to be installed separately.
+
+Building
+========
+
+The ``packaging.py`` script automates the process of producing an MSI
+installer. It manages fetching and configuring non-system dependencies
+(such as gettext, and various Python packages). It can be run from a
+basic cmd.exe Window (i.e. activating the MSBuildTools environment is
+not required).
+
+From the prompt, change to the TortoiseHg source directory. e.g.
+``cd c:\src\thg``.
+
+Next, invoke ``packaging.py`` to stage Mercurial and other dependencies. The
+version of Mercurial and the Evolve extension can be changed with this command.
+The version of TortoiseHg built is whatever is currently checked out, including
+uncommitted changes::
+
+ $ py -3 contrib\packaging\packaging.py \
+ stage --hg-version 6.1.2 --evolve-version 10.5.1
+
+Finally, invoke ``packaging.py`` to produce an MSI installer.::
+
+ $ py -3 contrib\packaging\packaging.py wix
+
+If everything runs as intended, dependencies will be fetched and
+configured into the ``build`` sub-directory, TortoiseHg will be built,
+and an installer placed in the ``dist`` sub-directory. The final line
+of output should print the name of the generated installer.
+
+Additional options may be configured. Run ``packaging.py wix --help``
+to see a list of program flags.
+
+.. [1] https://www.mercurial-scm.org/repo/hg/raw-file/6.1.2/contrib/install-windows-dependencies.ps1
+.. [2] https://download.microsoft.com/download/OfficeXPProf/Install/4.71.1015.0/W98NT42KMe/EN-US/HTMLHELP.EXE

Yuya Nishihara

unread,
May 13, 2022, 9:06:56 PM5/13/22
to Matt Harbison, thg...@googlegroups.com
On Fri, 13 May 2022 17:34:02 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1652473690 14400
> # Fri May 13 16:28:10 2022 -0400
> # Node ID a276ddcdde1aba7a162e0b40bcc3ad92f1ef53c6
> # Parent 1cfb87f6e536d6207f18f5173a4c0cb253d45577
> # EXP-Topic windows-py3-packaging
> packaging: bundle windows-curses in the py3 installer (fixes #5780)

Queued for stable, thanks.
Reply all
Reply to author
Forward
0 new messages