From 3c364fdaa2044f9c0c37e96dff73d142914ce18e Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Sat, 16 Dec 2023 16:46:46 +0100 Subject: [PATCH] hooks: add hook for lightning Add hook for (PyTorch) `lightning`. Currently, the main functionality is to ensure that the `version.info` file from the package is collected. We do not collect source .py files, as it seems that even if `lightning.LightningModule.to_torchscript()` is used, it requires the source where the model inheriting from `lightning.LightningModule` is defined, rather than `lightning`'s own sources. We can always add source .py files collection later, if it proves to be necessary. --- news/676.new.7.rst | 2 ++ .../hooks/stdhooks/hook-lightning.py | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 news/676.new.7.rst create mode 100644 src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-lightning.py diff --git a/news/676.new.7.rst b/news/676.new.7.rst new file mode 100644 index 00000000..a2259737 --- /dev/null +++ b/news/676.new.7.rst @@ -0,0 +1,2 @@ +Add hook for ``lightning`` (PyTorch Lightning) to ensure that its +``version.info`` data file is collected. diff --git a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-lightning.py b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-lightning.py new file mode 100644 index 00000000..40833f60 --- /dev/null +++ b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-lightning.py @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------ +# Copyright (c) 2023 PyInstaller Development Team. +# +# This file is distributed under the terms of the GNU General Public +# License (version 2.0 or later). +# +# The full license is available in LICENSE.GPL.txt, distributed with +# this software. +# +# SPDX-License-Identifier: GPL-2.0-or-later +# ------------------------------------------------------------------ + +from PyInstaller.utils.hooks import collect_data_files + +# Collect version.info (which is read during package import at run-time). Avoid collecting data from `lightning.app`, +# which likely does not work with PyInstaller without additional tricks (if we need to collect that data, it should +# be done in separate `lightning.app` hook). +datas = collect_data_files( + 'lightning', + includes=['version.info'], +)