You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to convert a python script that depends on weasyprint into an exe file using pyinstaller.
The good news is that pyinstaller is able to create a folder called "weasyprint" containing the necessary dependencies such as the css files in weasyprint/css and files in weasyprint/tests/resources.
However, the code in html.py assumes that these file dependencies are in the same directory as the exe files.
Around line 36
This may not be suitable if someone uses the pyinstaller to create a standalone exe file instead.
I suggest the following modification based on how pyinstaller works.
ifhasattr(sys, "frozen"):
# MEIPASS explanation:# https://pythonhosted.org/PyInstaller/#run-time-operationroot=getattr(sys, '_MEIPASS', None) #To handle standalone exe case ifnotroot:
root=os.path.dirname(sys.executable) #To handle exe with file dependencies in the same directoryroot=os.path.join(root,'weasyprint')
else:
root=os.path.dirname(__file__)
HTML5_UA_STYLESHEET=CSS(filename=os.path.join(root, 'css', 'html5_ua.css'))
HTML5_PH_STYLESHEET=CSS(filename=os.path.join(root, 'css', 'html5_ph.css'))
Hope this helps.
PS:
Please note that weasyprint also depends on the file dependencies from the pyphen package as well.
For this package, pyinstaller will not create a folder called "pyphen" by default.
To do so, please write in the *.spec file
@JauntyJJS Sorry for commenting on an old issue, but are you able to share any details about using PyInstaller with WeasyPrint? Like a blog or a gist? It seems like it would be super valuable info to share, especially if you did it on Windows! :)
Hi,
I tried to convert a python script that depends on weasyprint into an exe file using pyinstaller.
The good news is that pyinstaller is able to create a folder called "weasyprint" containing the necessary dependencies such as the css files in weasyprint/css and files in weasyprint/tests/resources.
However, the code in html.py assumes that these file dependencies are in the same directory as the exe files.
Around line 36
This may not be suitable if someone uses the pyinstaller to create a standalone exe file instead.
I suggest the following modification based on how pyinstaller works.
Hope this helps.
PS:
Please note that weasyprint also depends on the file dependencies from the pyphen package as well.
For this package, pyinstaller will not create a folder called "pyphen" by default.
To do so, please write in the *.spec file
and put the variable pyphen_dictionary into
The text was updated successfully, but these errors were encountered: