@@ -657,14 +657,19 @@ def run(arguments, content, options, state_machine, state, lineno):
657
657
build_dir = os .path .join (os .path .dirname (setup .app .doctreedir ),
658
658
'plot_directive' ,
659
659
source_rel_dir )
660
+ # get rid of .. in paths, also changes pathsep
661
+ # see note in Python docs for warning about symbolic links on Windows.
662
+ # need to compare source and dest paths at end
663
+ build_dir = os .path .normpath (build_dir )
664
+
660
665
if not os .path .exists (build_dir ):
661
- cbook . mkdirs (build_dir )
666
+ os . makedirs (build_dir )
662
667
663
668
# output_dir: final location in the builder's directory
664
669
dest_dir = os .path .abspath (os .path .join (setup .app .builder .outdir ,
665
670
source_rel_dir ))
666
671
if not os .path .exists (dest_dir ):
667
- cbook . mkdirs (dest_dir )
672
+ os . makedirs (dest_dir ) # no problem here for me, but just use built-ins
668
673
669
674
# how to link to files from the RST file
670
675
dest_dir_link = os .path .join (relpath (setup .confdir , rst_dir ),
@@ -738,15 +743,16 @@ def run(arguments, content, options, state_machine, state, lineno):
738
743
if total_lines :
739
744
state_machine .insert_input (total_lines , source = source_file_name )
740
745
741
- # copy image files to builder's output directory
746
+ # copy image files to builder's output directory, if necessary
742
747
if not os .path .exists (dest_dir ):
743
748
cbook .mkdirs (dest_dir )
744
-
749
+
745
750
for code_piece , images in results :
746
751
for img in images :
747
752
for fn in img .filenames ():
748
- shutil .copyfile (fn , os .path .join (dest_dir ,
749
- os .path .basename (fn )))
753
+ destimg = os .path .join (dest_dir , os .path .basename (fn ))
754
+ if fn != destimg :
755
+ shutil .copyfile (fn , destimg )
750
756
751
757
# copy script (if necessary)
752
758
if source_file_name == rst_file :
0 commit comments