forked from IronLanguages/ironpython3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_compiled.py
More file actions
29 lines (24 loc) · 1015 Bytes
/
run_compiled.py
File metadata and controls
29 lines (24 loc) · 1015 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
27
28
29
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the Apache 2.0 License.
# See the LICENSE file in the project root for more information.
import sys
import clr
from System.IO import File, Path
def main():
if len(sys.argv) != 2:
print "Usage: ipy run_compiled.py <testfile.py>"
sys.exit(-1)
testName = sys.argv[1]
print "Compiling ", testName ,"..."
clr.CompileModules("compiledTest.dll", testName)
File.Move(testName, testName+".bak")
try:
print "Running test from compiled binary..."
clr.AddReference("compiledTest")
__import__(Path.GetFileNameWithoutExtension(testName))
finally:
File.Move(testName+".bak" , testName)
#--------------------------------------------------------------------------------------
if __name__ == "__main__":
main()
#--------------------------------------------------------------------------------------