@@ -657,14 +657,22 @@ 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 this if you use cbook.mkdirs
663
+ # also need it to compare source and dest paths at end
664
+ build_dir = os .path .normpath (build_dir )
665
+
660
666
if not os .path .exists (build_dir ):
661
- cbook .mkdirs (build_dir )
667
+ # cbook.mkdirs(build_dir)
668
+ os .makedirs (build_dir )
662
669
663
670
# output_dir: final location in the builder's directory
664
671
dest_dir = os .path .abspath (os .path .join (setup .app .builder .outdir ,
665
672
source_rel_dir ))
666
673
if not os .path .exists (dest_dir ):
667
- cbook .mkdirs (dest_dir )
674
+ # cbook.mkdirs(dest_dir)
675
+ os .makedirs (dest_dir ) # no problem here for me, but just use built-ins
668
676
669
677
# how to link to files from the RST file
670
678
dest_dir_link = os .path .join (relpath (setup .confdir , rst_dir ),
@@ -738,15 +746,16 @@ def run(arguments, content, options, state_machine, state, lineno):
738
746
if total_lines :
739
747
state_machine .insert_input (total_lines , source = source_file_name )
740
748
741
- # copy image files to builder's output directory
749
+ # copy image files to builder's output directory, if necessary
742
750
if not os .path .exists (dest_dir ):
743
751
cbook .mkdirs (dest_dir )
744
-
752
+
745
753
for code_piece , images in results :
746
754
for img in images :
747
755
for fn in img .filenames ():
748
- shutil .copyfile (fn , os .path .join (dest_dir ,
749
- os .path .basename (fn )))
756
+ destimg = os .path .join (dest_dir , os .path .basename (fn ))
757
+ if fn != destimg :
758
+ shutil .copyfile (fn , destimg )
750
759
751
760
# copy script (if necessary)
752
761
if source_file_name == rst_file :
0 commit comments