Commits

Georg Brandl  committed 84aee27

Closes #796: use package_dir everywhere instead of __file__.

  • Participants
  • Parent commits df1afa5
  • Branches stable

Comments (0)

Files changed (3)

File sphinx/ext/autosummary/generate.py

 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()

File sphinx/pycode/__init__.py

 
 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)
 

File sphinx/websupport/__init__.py

 
     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)