Georg Brandl committed 84aee27

Closes #796: use package_dir everywhere instead of __file__.

Comments (0)

Files changed (3)


 from jinja2 import FileSystemLoader, TemplateNotFound
 from jinja2.sandbox import SandboxedEnvironment
+from sphinx import package_dir
 from sphinx.ext.autosummary import import_by_name, get_documenter
 from sphinx.jinja2glue import BuiltinTemplateLoader
 from sphinx.util.osutil import ensuredir
         sources = [os.path.join(base_path, filename) for filename in sources]
     # create our own templating environment
-    template_dirs = [os.path.join(os.path.dirname(__file__), 'templates')]
+    template_dirs = [os.path.join(package_dir, 'ext', 'autosummary', 'templates')]
     if builder is not None:
         # allow the user to override the templates
         template_loader = BuiltinTemplateLoader()


 from os import path
+from sphinx import package_dir
 from sphinx.errors import PycodeError
 from sphinx.pycode import nodes
 from sphinx.pycode.pgen2 import driver, token, tokenize, parse, literals
 # load the Python grammar
-_grammarfile = path.join(path.dirname(__file__), 'Grammar.txt')
+_grammarfile = path.join(package_dir, 'pycode', 'Grammar.txt')
 pygrammar = driver.load_grammar(_grammarfile)
 pydriver = driver.Driver(pygrammar, convert=nodes.convert)


     def _init_templating(self):
         import sphinx
-        template_path = path.join(path.dirname(sphinx.__file__),
+        template_path = path.join(sphinx.package_dir,
                                   'themes', 'basic')
         loader = FileSystemLoader(template_path)
         self.template_env = Environment(loader=loader)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.