-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·26 lines (20 loc) · 769 Bytes
/
Copy pathrun.py
File metadata and controls
executable file
·26 lines (20 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
# Copyright (C) 2010 Tobi Vollebregt
def main():
# Modify path so that development copy is picked up first, if available.
import imp, os, sys
sys.path = [os.path.normpath(os.path.dirname(os.path.realpath(__file__)))] + sys.path
if len(sys.argv) < 2:
print """Usage: %s foo.py [arguments...]'
Runs foo.py as if it was run directly, except that sys.path is modified so that
development copies of modules (relative to this script) are picked up first.""" % sys.argv[0]
sys.exit(1)
# Cloak =)
# (i.e. remove the `main' function from the global scope)
global main
del main
# Load module by filename after first correcting sys.argv
sys.argv = sys.argv[1:]
imp.load_source('__main__', sys.argv[0])
if __name__ == '__main__':
main()