From 60972f5524b22e8a9758b764c3a512e7dc7b7291 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Mon, 5 Mar 2018 14:06:58 -0800 Subject: [PATCH 1/2] Fixed dynamic import mechanics of make.py --- doc/make.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/make.py b/doc/make.py index 53635498f2adb..ea3bf0e45dae4 100755 --- a/doc/make.py +++ b/doc/make.py @@ -11,6 +11,7 @@ $ python make.py html $ python make.py latex """ +import importlib import sys import os import shutil @@ -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') @@ -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), help='path') argparser.add_argument('-v', action='count', dest='verbosity', default=0, help=('increase verbosity (can be repeated), ' @@ -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) From 84b8bcb0f2bc3e0154caca11ff401206481e5043 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Mon, 5 Mar 2018 15:24:32 -0800 Subject: [PATCH 2/2] Added noqa directive to avoid LINT issue --- doc/make.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/make.py b/doc/make.py index ea3bf0e45dae4..4967f30453fd1 100755 --- a/doc/make.py +++ b/doc/make.py @@ -133,7 +133,7 @@ def _process_single_doc(self, single_doc): self.single_doc = single_doc elif single_doc is not None: try: - obj = pandas + obj = pandas # noqa: F821 for name in single_doc.split('.'): obj = getattr(obj, name) except AttributeError: