Skip to content

Commit

Permalink
hooks: add hook for lightning
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rokm committed Dec 23, 2023
1 parent 2afbbcf commit 3c364fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions news/676.new.7.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add hook for ``lightning`` (PyTorch Lightning) to ensure that its
``version.info`` data file is collected.
21 changes: 21 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-lightning.py
Original file line number Diff line number Diff line change
@@ -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'],
)

0 comments on commit 3c364fd

Please sign in to comment.