3 """Symlinks, or on Windows copies, an existing file to a second location.
5 Overwrites the target location if it exists.
6 Updates the mtime on a stamp file when done."""
15 parser
= argparse
.ArgumentParser(
17 formatter_class
=argparse
.RawDescriptionHelpFormatter
)
19 "--stamp", required
=True, help="name of a file whose mtime is updated on run"
21 parser
.add_argument("source")
22 parser
.add_argument("output")
23 args
= parser
.parse_args()
25 # FIXME: This should not check the host platform but the target platform
26 # (which needs to be passed in as an arg), for cross builds.
27 if sys
.platform
!= "win32":
29 os
.makedirs(os
.path
.dirname(args
.output
))
31 if e
.errno
!= errno
.EEXIST
:
34 os
.symlink(args
.source
, args
.output
)
36 if e
.errno
== errno
.EEXIST
:
37 os
.remove(args
.output
)
38 os
.symlink(args
.source
, args
.output
)
44 output
= args
.output
+ ".exe"
45 source
= args
.source
+ ".exe"
46 shutil
.copyfile(os
.path
.join(os
.path
.dirname(output
), source
), output
)
48 open(args
.stamp
, "w") # Update mtime on stamp file.
51 if __name__
== "__main__":