Last active
January 8, 2022 17:26
-
-
Save flozz/3c09efaee7d7d01b746a68f7d85dcc7b to your computer and use it in GitHub Desktop.
Builds a frozen version of WeasyPrint that includes all required dependencies and libraries.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Builds a frozen version of WeasyPrint (https://github.com/kozea/weasyprint) | |
# that includes all required dependencies and libraries. | |
# | |
# Dependencies: | |
# | |
# * GNU make (build-essential package on Debian) | |
# * Python headers (python3-dev package on Dabian) | |
# * virtualenv | |
# | |
# Usage: | |
# | |
# * Clone the WeasyPrint repository, | |
# * Put this Makefile at the root of the repository, | |
# * Run the "make" command, | |
# * The result will be generated in dist/weasy/, the executable is | |
# named "weasy". | |
# | |
# Trouble Shooting: | |
# | |
# P: Unable to find "[...]/__env__/lib/python3.6/site-packages/pyphen/dictionaries" | |
# when adding binary and data files | |
# | |
# S: change the PYTHON_VERSION in the Makefile accordingly to your installed | |
# Python version. | |
# | |
# Note: | |
# | |
# This should work fine on Linux and other Unix systems. This will need | |
# some changes to work on Windows™. | |
NAME=weasy | |
PYTHON_VERSION=3.6 | |
all: build/$(NAME) | |
build/$(NAME): __env__ | |
mv weasyprint.py $(NAME).py | |
. __env__/bin/activate \ | |
&& pyinstaller \ | |
--noconfirm \ | |
--name $(NAME) \ | |
--add-data __env__/lib/python$(PYTHON_VERSION)/site-packages/pyphen/dictionaries:pyphen/dictionaries \ | |
--add-data weasyprint/css:css \ | |
--hidden-import encodings \ | |
$(NAME).py | |
mv $(NAME).py weasyprint.py | |
__env__: | |
virtualenv --python=python3 __env__ | |
. __env__/bin/activate \ | |
&& pip install -e . \ | |
&& pip install pyinstaller | |
clean: | |
rm -f $(NAME).spec | |
rm -rf build/$(NAME)/ | |
rm -rf dist/$(NAME)/ | |
test -f $(NAME).py && mv $(NAME).py weasyprint.py || echo -n "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment