Fix importing black when building exe with pyinstaller

This commit is contained in:
Ircama 2024-09-20 09:34:42 +02:00
parent 69a6e9bf06
commit 350ca81474
2 changed files with 18 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import argparse
import os import os
import os.path import os.path
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from PyInstaller.utils.hooks import collect_submodules, collect_data_files
def create_image(png_file, text): def create_image(png_file, text):
@ -76,12 +77,25 @@ app.mainloop()
with open(PROGRAM[0], 'w') as file: with open(PROGRAM[0], 'w') as file:
file.write(gui_wrapper) file.write(gui_wrapper)
# black submodules: https://github.com/pyinstaller/pyinstaller/issues/8270
black_submodules = collect_submodules('black')
blib2to3_submodules = collect_submodules('blib2to3')
# "black" data files: https://github.com/pyinstaller/pyinstaller/issues/8270
blib2to3_data = collect_data_files('blib2to3')
a = Analysis( a = Analysis(
PROGRAM, PROGRAM,
pathex=[], pathex=[],
binaries=[], binaries=[],
datas=DATAS, datas=DATAS + blib2to3_data, # the latter required by black
hiddenimports=['babel.numbers'], hiddenimports=[
'babel.numbers',
# The following modules are needed by "black": https://github.com/pyinstaller/pyinstaller/issues/8270
'30fcd23745efe32ce681__mypyc',
'6b397dd64e00b5aff23d__mypyc', 'click', 'json', 'platform',
'mypy_extensions', 'pathspec', '_black_version', 'platformdirs'
] + black_submodules + blib2to3_submodules, # the last two required by black
hookspath=[], hookspath=[],
hooksconfig={}, hooksconfig={},
runtime_hooks=[], runtime_hooks=[],

View file

@ -1,4 +1,5 @@
PyYAML pyyaml
pyasn1==0.4.8
git+https://github.com/etingof/pysnmp.git@master#egg=pysnmp git+https://github.com/etingof/pysnmp.git@master#egg=pysnmp
pyasyncore;python_version>="3.12" pyasyncore;python_version>="3.12"
tkcalendar tkcalendar