36def run(output=os.getcwd(),verbose=2):
38 Main function to execute the script.
41 __arch = Utility.GetArchitecture()
45 from PyCODAC.Tools.Utility
import GetPyCODACPath
47 __mcd_core_path = os.path.join(GetPyCODACPath(),
"Core")
54 ErrorHandling.InputError(20)
57 with Utility.TemporaryDirectory(VTL.Scratch):
60 __temp_path = os.path.join(os.getcwd(),Utility.GetTemporaryFileName(extension=
""))
61 if not os.path.exists(__temp_path): shutil.copytree(__mcd_core_path, __temp_path, ignore=shutil.ignore_patterns(
'*.svn',
'.git'))
64 __mcd_core_path = __temp_path; __mcd_out_path = os.getcwd()
68 py2x(BuildID, files=VTL.GetSourceCode(1), source=os.path.join(__mcd_core_path,
"external",
"boxbeam"), libs=[],include=[],dependency=[], scratch = os.getcwd(),
69 verbosity=verbose, output=__mcd_out_path, bash=
True)
73 py2x(BuildID, files=VTL.GetSourceCode(2), command=VTL.GetBuildCommand(0, _format=
"free"), source=os.path.join(__mcd_core_path,
"external",
"beos"),
74 libs=[],include=[],dependency=[], scratch = os.getcwd(), output=__mcd_out_path, incremental=
True, verbosity=verbose, bash=
True)
80 cmake(BuildID, source=os.path.join(__mcd_core_path,
"config"), scratch=os.getcwd(), bash=
True)
82 py2x(BuildID, source=os.path.join(__mcd_core_path,
"src"),
83 include=[os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch, x)
for x
in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4, __arch)],
84 dependency=os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch), scratch = os.getcwd(),
85 output=__mcd_out_path, verbosity=verbose, bash=
True)
88 for x
in os.listdir(os.getcwd()):
89 if x.endswith((
".pyd")): shutil.move(x,os.path.join(output,x))
92 print(
'==================================')
94 print(
'==================================')
98def main(python=sys.executable, **kwargs):
100 Build for a given python executable
102 from PyCODAC
import PyCODACPath
as __pyc_src_path
105 output_path = os.path.normpath(kwargs.get(
"output",os.getcwd())).replace(os.sep,os.sep*2)
106 module_file = __file__.split(os.sep)[-1].split(
".")[0]
107 file_dir = os.path.dirname(os.path.abspath(__file__)).replace(os.sep,os.sep*2)
110 with tempfile.NamedTemporaryFile(mode=
"w+", suffix=
".py", delete=
False)
as tmp:
111 tmp.writelines(
"import os; import sys; sys.path.insert(0, os.path.normpath('"+file_dir+
"')); import %s; %s.run(output='%s')" % (module_file, module_file, output_path))
114 command =
" ".join([python,os.path.join(__pyc_src_path,
"__setenv__.py"),tmp.name])
117 p = Utility.Popen(command, verbosity=2, collect=
False, shell=
True)
123 return getattr(p,
"returncode",p)