6 Triple-use minimum working example for PyXMake. This script can be 7 executed in three different ways in varying levels of accessibility 9 @note: Compile Fortran source as a shared library for Python 10 using f2py (Py2X in the future). 14 ---------------------------------------------------------------------------------------------- 21 @author: garb_ma [DLR-FA,STM Braunschweig] 22 ---------------------------------------------------------------------------------------------- 31 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
35 from PyXMake
import VTL
38 __arch = Utility.GetArchitecture()
42 from PyCODAC.Tools.Utility
import GetPyCODACPath
44 __mcd_core_path = os.path.join(GetPyCODACPath(),
"Core")
51 ErrorHandling.InputError(20)
56 files=VTL.GetSourceCode(0),
57 command = VTL.GetBuildCommand(0),
58 libs = VTL.GetLinkDependency(0, 0, __arch),
60 source=os.path.join(__mcd_core_path,
"src"),
61 include=[os.path.join(__mcd_core_path,
"include",Utility.GetPlatform(),__arch, x)
62 for x
in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4, __arch)],
63 dependency=os.path.join(__mcd_core_path,
"lib",Utility.GetPlatform(),__arch),
64 output=os.path.join(__mcd_core_path,
"bin",Utility.GetPlatform(),__arch),
66 architecture=__arch,scratch=VTL.Scratch, verbosity=0,
68 incremental =
False, **kwargs):
70 Main function to execute the script. 73 P2XBuild = pyx.Py2X(BuildID, files, scratch=scratch, msvsc=kwargs.get(
"msvsc",
"vs2015"), verbose=verbosity, incremental=incremental)
74 P2XBuild.AddIncludePath(include)
75 P2XBuild.SourcePath(source)
79 P2XBuild.Preprocessing(
'fpp -P -e -DPYD', inend=
'.for', outend=
'.fpp')
81 P2XBuild.Preprocessing(copyfiles=files)
83 P2XBuild.OutputPath(output)
84 P2XBuild.Build(command)
85 P2XBuild.AddDependencyPath(dependency)
86 P2XBuild.UseLibraries(libs)
89 if __name__ ==
"__main__":
93 parser = argparse.ArgumentParser(description=
"Build a shared Fortran library for current Python executable")
94 parser.add_argument(
"make", metavar=
"make", nargs=1, help=
"Integer value selecting a predefined make operation")
98 args, _ = parser.parse_known_args()
100 make_opt = args.make[0]
110 files=VTL.GetSourceCode(2),
111 command=VTL.GetBuildCommand(0, _format=
"free"),
112 source=os.path.join(__mcd_core_path,
"external",
"beos"),
113 libs=[],include=[],dependency=[],
115 output=os.path.join(os.path.join(__mcd_core_path,
"bin",Utility.GetPlatform(),__arch)), incremental=
True)
120 files=VTL.GetSourceCode(1),
121 source=os.path.join(__mcd_core_path,
"external",
"boxbeam"),
122 libs=[],include=[],dependency=[],
124 output=os.path.join(os.path.join(__mcd_core_path,
"bin",Utility.GetPlatform(),__arch)))
127 BuildID =
"mcd_core";
main(BuildID)
130 raise NotImplementedError
133 print(
"==================================")
134 print(
"Finished build for Python")
135 print(
"==================================")
def main(BuildID, files=VTL.GetSourceCode(0), command=VTL.GetBuildCommand(0), libs=VTL.GetLinkDependency(0, 0, __arch), source=os.path.join(__mcd_core_path,"src"), include=[os.path.join(__mcd_core_path,"include", Utility.GetPlatform(), __arch, x) for x in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4, __arch)], dependency=os.path.join(__mcd_core_path,"lib", Utility.GetPlatform(), __arch), output=os.path.join(__mcd_core_path,"bin", Utility.GetPlatform(), __arch), architecture=__arch, scratch=VTL.Scratch, verbosity=0, incremental=False, kwargs)
Module containing all relevant modules and scripts associated with the building process.