Skip to content

Commit 4dc7caa

Browse files
committed
Create savefig_dir in Sphinx IPython directive
Closes ipythongh-8733 (hopefully)
1 parent 636e0af commit 4dc7caa

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎IPython/sphinxext/ipython_directive.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126

127127
# Stdlib
128128
import atexit
129+
import errno
129130
import os
130131
import re
131132
import sys
@@ -892,6 +893,13 @@ def setup(self):
892893
self.shell.IP.execution_count = 1
893894
self.seen_docs.add(self.state.document.current_source)
894895

896+
# Ensure that the directory for saving figures exists
897+
try:
898+
os.makedirs(os.path.abspath(savefig_dir))
899+
except OSError as e:
900+
if e.errno != errno.EEXIST:
901+
raise
902+
895903
# and attach to shell so we don't have to pass them around
896904
self.shell.rgxin = rgxin
897905
self.shell.rgxout = rgxout

0 commit comments

Comments
 (0)