Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay import of Sphinx #248

Merged
merged 3 commits into from
Dec 4, 2019
Merged

Delay import of Sphinx #248

merged 3 commits into from
Dec 4, 2019

Conversation

cgohlke
Copy link
Contributor

@cgohlke cgohlke commented Dec 3, 2019

from numpydoc.docscrape import FunctionDoc takes ~3.5 s on my Windows workstation because importing Sphinx triggers the use of pkg_resources, which is excruciatingly slow if many Python packages are installed.

AFAICT, FunctionDoc does not require Sphinx.

pypa/setuptools#510

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible for config.members to be ALL unless sphinx has already been imported, so we can also protect here with

if 'sphinx' in sys.modules:
    from sphinx.ext.autodoc import ALL
else:
    ALL = object()  # or something else that will never match

@cgohlke cgohlke mentioned this pull request Dec 4, 2019
numpydoc/docscrape.py Outdated Show resolved Hide resolved
@larsoner larsoner merged commit 4978673 into numpy:master Dec 4, 2019
@larsoner
Copy link
Collaborator

larsoner commented Dec 4, 2019

Thanks @cgohlke

@rgommers rgommers added this to the 1.0.0 milestone Dec 17, 2019
rgommers pushed a commit that referenced this pull request Dec 24, 2019
* Delay import of Sphinx

* ENH: do not import Sphinx unless it has already been imported

* Delay import of Sphinx

(cherry picked from commit 4978673)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants