This is a hacky little repo used to build Windows binaries for ebookmaker using pyinstaller.
These instructions use bash-isms and thus assume you are running the following commands in a git bash shell on Windows (presumably after having installed Git for Windows).
-
Clone this repository
-
Install the ebookmaker build dependencies
- Install Python 3.10 from python.org.
- Install Microsoft Visual Studio Build Tools.
- Go to Microsoft Visual Studio Downloads.
- Scroll down and expand Visual Studio under All Downloads.
- Download Build Tools for Visual Studio 2022. This will download and start the Visual Studio Installer.
- In the installer, select the Desktop Development with C++ workload. You really will need all of the things this wants to install by default. All 6GB of it.
- Start the install.
-
If not present already, you may need to add the following to your PATH to pick up python, pip, and pipenv:
%USERPROFILE%\AppData\Local\Programs\Python\Python310
%USERPROFILE%\AppData\Local\Programs\Python\Python310\Scripts
%USERPROFILE%\AppData\Roaming\Python\Python310\Scripts
-
Install
pipenv
pip install --user pipenv
-
Within the repository clone, install the pipenv virtual environment
pipenv install
ebookmaker dynamically loads the set of available parsers, packagers,
and writers from the filesystem using pkg_resources
. Unfortunately
this does not work with pyinstaller so we need to adjust the installed
ebookmaker code to provide it with an explicit list using the
ebookmaker-pyinstaller.patch
file.
# Start a pipenv shell
pipenv shell
# Apply the patch
./apply_patch.sh
Create the ebookmaker binary with pyinstaller:
# Start a pipenv shell if you are not already
pipenv shell
# Run the installer
pyinstaller -F \
--hidden-import ebookmaker.parsers.AuxParser \
--hidden-import ebookmaker.parsers.CSSParser \
--hidden-import ebookmaker.parsers.GutenbergTextParser \
--hidden-import ebookmaker.parsers.HTMLParser \
--hidden-import ebookmaker.parsers.ImageParser \
--hidden-import ebookmaker.parsers.RSTParser \
--hidden-import ebookmaker.parsers.WrapperParser \
--hidden-import ebookmaker.writers.EpubWriter \
--hidden-import ebookmaker.writers.Epub3Writer \
--hidden-import ebookmaker.writers.HTMLWriter \
--hidden-import ebookmaker.writers.KindleWriter \
--hidden-import ebookmaker.writers.PDFWriter \
--hidden-import ebookmaker.writers.PicsDirWriter \
--hidden-import ebookmaker.writers.RSTWriter \
--hidden-import ebookmaker.writers.TxtWriter \
--hidden-import ebookmaker.packagers.GzipPackager \
--hidden-import ebookmaker.packagers.HTMLPackager \
--hidden-import ebookmaker.packagers.PDFPackager \
--hidden-import ebookmaker.packagers.PushPackager \
--hidden-import ebookmaker.packagers.RSTPackager \
--hidden-import ebookmaker.packagers.TxtPackager \
"$(which ebookmaker)"
This will create the Windows binary dist/ebookmaker.exe
.
To validate the ebookmaker.exe
binary is working correctly, you must
build an epub, not just ebookmaker.exe --version
:
./dist/ebookmaker.exe \
--verbose \
--make=epub.images \
--output-dir build \
--config-dir dist \
--title sample_ebook \
sample_ebook/ebmtest.htm
This should create build/sample_ebook-images-epub.epub
.
To release a new binary:
- Ensure you are working with a fresh checkout of the
master
branch. - Tag the repo with the same version of EBookMaker installed in the
Pipfile
:git tag v0.9.1 master
- Push the tag to the upstream repo:
git push --tags upstream
- Create the
ebookmaker.exe
file in the dist folder. - Create a zip named with the version of EBookMaker that it was built from.
For example:
ebookmaker-0.9.1.zip
. It should contain theebookmaker.exe
file. - Create an ebm_builder release
with the tag using the following template:
- Release title:
- Description: updated with the appropriate versions
This is a Windows binary of the <tagname> [ebookmaker](https://github.com/gutenbergtools/ebookmaker) tool built on Windows 10 with pyinstaller and Python 3.8.
- Attach the zip file
To update the version of ebookmaker this tool builds, install a new
version of the ebookmaker package with pipenv install
:
pipenv install "ebookmaker==0.9.2"
Then re-apply the patch to enable building with pyinstaller and build the new binary as instructed above. Depending on the changes within ebookmaker this may require updating the patch and/or the list of hidden imports passed into pyinstaller.
Be sure and check in the updated Pipfile
and Pipfile.lock
along with
any other changes before tagging and releasing a new binary.
If ebookmaker crashes and the traceback refers to imported packages, it may be that one of the packages has been updated, requiring an updated version of pyinstaller. Try upgrading to the latest version of PyInstaller by finding the latest released version and upgrading to it with:
pipenv install "pyinstaller==$LATEST_RELEASE"
An error such as local variable 'xxxx' referenced before assignment
may
indicate that a fix is needed in ebookmaker itself. Contact the ebookmaker
maintainers with details.