Skip to content

Commit

Permalink
hooks: exclude docutils from distutils.command.check
Browse files Browse the repository at this point in the history
Add hooks for `distutils.command.check` from stdlib and
`setuptools` (`setuptools._distutils.command.check`) that
exclude conditionally-imported `docutils`.

The latter is quite heavy-weight, as it triggers collection of
various modules from `pygments` and `PIL`; so try avoiding its
collection if not necessary.

See:

https://github.com/python/cpython/blob/v3.8.0/Lib/distutils/command/check.py#L8-L34

https://github.com/pypa/setuptools/blob/v68.2.2/setuptools/_distutils/command/check.py#L10-L36
  • Loading branch information
rokm committed Nov 1, 2023
1 parent 28dba7f commit 0e3e828
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions PyInstaller/hooks/hook-distutils.command.check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#-----------------------------------------------------------------------------
# Copyright (c) 2023, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License (version 2
# or later) with exception for distributing the bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
#-----------------------------------------------------------------------------

# Conditionally imported in this module; should not trigger collection.
excludedimports = ['docutils']
13 changes: 13 additions & 0 deletions PyInstaller/hooks/hook-setuptools._distutils.command.check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#-----------------------------------------------------------------------------
# Copyright (c) 2023, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License (version 2
# or later) with exception for distributing the bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
#-----------------------------------------------------------------------------

# Conditionally imported in this module; should not trigger collection.
excludedimports = ['docutils']
4 changes: 4 additions & 0 deletions news/8053.hooks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add hooks for ``distutils.command.check`` and
``setuptools._distutils.command.check`` that prevent unnecessary
collection of ``docutils`` (which in turn triggers collection of
``pygments``, ``PIL``, etc.).

0 comments on commit 0e3e828

Please sign in to comment.