import sys import glob import os from PyInstaller import log as logging from PyInstaller.utils.hooks import ( django_find_root_dir, django_dottedstring_imports, collect_all, collect_submodules, collect_data_files, get_module_file_attribute, get_module_attribute) logger = logging.getLogger(__name__) datas, binaries, hiddenimports = collect_all('django') root_dir = django_find_root_dir() if root_dir: logger.info('Django root directory %s', root_dir) # Include imports from the mysite.settings.py module. settings_py_imports = django_dottedstring_imports(root_dir) # Include all submodules of all imports detected in mysite.settings.py. for submod in settings_py_imports: hiddenimports.append(submod) hiddenimports += collect_submodules(submod) # Include main django modules - settings.py, urls.py, wsgi.py. # Without them the django server won't run. package_name = os.path.basename(root_dir) hiddenimports += [ # TODO Consider including 'mysite.settings.py' in source code as a data files. # Since users might need to edit this file. package_name + '.settings',