Skip to content

DOC: fixed dynamic import mechanics of make.py #20005

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

Merged
merged 2 commits into from
Mar 6, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
$ python make.py html
$ python make.py latex
"""
import importlib
import sys
import os
import shutil
Expand All @@ -20,8 +21,6 @@
import webbrowser
import jinja2

import pandas


DOC_PATH = os.path.dirname(os.path.abspath(__file__))
SOURCE_PATH = os.path.join(DOC_PATH, 'source')
Expand Down Expand Up @@ -332,7 +331,7 @@ def main():
'compile, e.g. "indexing", "DataFrame.join"'))
argparser.add_argument('--python-path',
type=str,
default=os.path.join(DOC_PATH, '..'),
default=os.path.dirname(DOC_PATH),
Copy link
Member Author

Choose a reason for hiding this comment

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

This is purely stylistic

help='path')
argparser.add_argument('-v', action='count', dest='verbosity', default=0,
help=('increase verbosity (can be repeated), '
Expand All @@ -343,7 +342,13 @@ def main():
raise ValueError('Unknown command {}. Available options: {}'.format(
args.command, ', '.join(cmds)))

# Below we update both os.environ and sys.path. The former is used by
# external libraries (namely Sphinx) to compile this module and resolve
# the import of `python_path` correctly. The latter is used to resolve
# the import within the module, injecting it into the global namespace
os.environ['PYTHONPATH'] = args.python_path
sys.path.append(args.python_path)
globals()['pandas'] = importlib.import_module('pandas')

builder = DocBuilder(args.num_jobs, not args.no_api, args.single,
args.verbosity)
Expand Down