forked from numpy/numpy-refactor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iron_install.py
executable file
·91 lines (76 loc) · 2.86 KB
/
iron_install.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# This file performs the installation step once the build is complete.
# Installation primarily involves copying the build results to the
# IronPython site-packages directory.
import os
import sys
import shutil
import tempfile
from os.path import dirname, isdir, isfile, join
src_dir = join(os.getcwd(), "numpy")
def install():
print "INSTALLING ..."
sp_dir = join(sys.prefix, r'Lib\site-packages')
numpy_dir = src_dir
dll_dir = join(sys.prefix, 'DLLs')
if not isdir(dll_dir):
os.mkdir(dll_dir)
ignore_pys = ["setup.py", "iron_install.py"]
ignore_libs = ["Microsoft.Scripting.dll",
"Microsoft.Scripting.Metadata.dll",
"Microsoft.Dynamic.dll",
"IronPython.dll",
"IronPython.Modules.dll"]
# Recursively walk the directory tree and copy all .py files into the
# site-packages directory and all .dll files into DLLs.
for root, dirs, files in os.walk("."):
for fn in files:
rel_path = join(root, fn)
#rel_path = abs_path[len(numpy_dir) + 1:]
if fn.endswith('.py') and fn not in ignore_pys:
#print "abs_path = %s, relpath = %s" % ("", rel_path)
dst_dir = dirname(join(sp_dir, rel_path))
if not isdir(dst_dir):
os.makedirs(dst_dir)
# Rename the _clr.py files to remove the _clr suffix.
# Only used for IronPython.
if fn.endswith('_clr.py'):
dst_file = join(dst_dir, fn[:-7] + ".py")
else:
dst_file = join(dst_dir, fn)
#print "Copy %s to %s" % (rel_path, dst_file)
shutil.copy(rel_path, dst_file)
elif fn.endswith('.dll') and fn not in ignore_libs:
dst_file = join(dll_dir, fn)
print rel_path
if isfile(dst_file):
# Rename existing file because it is probably in use
# by the ipy command.
tmp_dir = tempfile.mkdtemp()
os.rename(dst_file, join(tmp_dir, fn))
#print "Copy %s to %s" % (rel_path, dst_file)
shutil.copy(rel_path, dst_file)
write_config(join(sp_dir, r'numpy\__config__.py'))
write_version(join(sp_dir, r'numpy\version.py'))
def write_config(path):
fo = open(path, 'w')
fo.write("""# this file is generated by ironsetup.py
__all__ = ["show"]
_config = {}
def show():
print 'Numpy for IronPython'
""")
fo.close()
def write_version(path):
fo = open(path, 'w')
fo.write("""# this file is generated by ironsetup.py
short_version = '2.0.0'
version = '2.0.0'
full_version= '2.0.0.dev-unknown'
git_revision = 'unknown'
release = False
if not release:
version = full_version
""")
fo.close()
if __name__ == '__main__':
install()