[sagenb] 99/179: Workaround for Sphinx appending to sys.path

felix salfelder felix-guest at moszumanska.debian.org
Tue May 6 12:05:14 UTC 2014


This is an automated email from the git hooks/post-receive script.

felix-guest pushed a commit to branch master
in repository sagenb.

commit 50d3063e49bb30ab383e80d9ab92f89a4bf36d24
Author: Volker Braun <vbraun.name at gmail.com>
Date:   Tue Apr 23 20:41:45 2013 +0100

    Workaround for Sphinx appending to sys.path
---
 sagenb/misc/sphinxify.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sagenb/misc/sphinxify.py b/sagenb/misc/sphinxify.py
index 20ff352..2777f02 100644
--- a/sagenb/misc/sphinxify.py
+++ b/sagenb/misc/sphinxify.py
@@ -76,6 +76,12 @@ def sphinxify(docstring, format='html'):
         'x=y\n'
         sage: sphinxify(':math:`x=y`', format='text')
         'x=y\n'
+
+    TESTS::
+
+        sage: n = len(sys.path)
+        sage: _ = sphinxify('A test')
+        sage: assert n == len(sys.path)
     """
     global Sphinx
     if not Sphinx:
@@ -109,9 +115,12 @@ def sphinxify(docstring, format='html'):
     doctreedir = os.path.join(srcdir, 'doctrees')
     confoverrides = {'html_context': {}, 'master_doc': 'docstring'}
 
+    import sys
+    old_sys_path = list(sys.path)  # Sphinx modifies sys.path
     sphinx_app = Sphinx(srcdir, confdir, srcdir, doctreedir, format,
                         confoverrides, None, None, True)
     sphinx_app.build(None, [rst_name])
+    sys.path = old_sys_path
 
     #We need to remove "_" from __builtin__ that the gettext module installs
     import __builtin__

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sagenb.git



More information about the debian-science-commits mailing list