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(description
=__doc__
)
17 "--stamp", required
=True, help="name of a file whose mtime is updated on run"
19 parser
.add_argument("source")
20 parser
.add_argument("output")
21 args
= parser
.parse_args()
23 # FIXME: This should not check the host platform but the target platform
24 # (which needs to be passed in as an arg), for cross builds.
25 if sys
.platform
!= "win32":
27 os
.makedirs(os
.path
.dirname(args
.output
))
29 if e
.errno
!= errno
.EEXIST
:
32 os
.symlink(args
.source
, args
.output
)
34 if e
.errno
== errno
.EEXIST
:
35 os
.remove(args
.output
)
36 os
.symlink(args
.source
, args
.output
)
42 output
= args
.output
+ ".exe"
43 source
= args
.source
+ ".exe"
44 shutil
.copyfile(os
.path
.join(os
.path
.dirname(output
), source
), output
)
46 open(args
.stamp
, "w") # Update mtime on stamp file.
49 if __name__
== "__main__":