6Triple-use minimum working example for PyXMake. This script can be
7executed in three different ways in varying levels of accessibility
9@note: Compile Fortran source for PYTHON remotely
10 on the institute cluster. Uses main function.
13----------------------------------------------------------------------------------------------
21@author: garb_ma [DLR-FA,STM Braunschweig]
22----------------------------------------------------------------------------------------------
32 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
36 from PyXMake
import VTL
39__user = os.getenv(
"username",
"")
40__mcd_cluster_dev = posixpath.join(Utility.AsDrive(
"home",posixpath.sep),__user,
"mcodac")
41__mcd_cluster_stable = posixpath.join(Utility.AsDrive(
"cluster",posixpath.sep),
"software",
"mcodac",
"stable")
42__mcd_cluster_incpath = posixpath.join(__mcd_cluster_stable,
"include")
46 from PyCODAC.Tools.Utility
import GetPyCODACPath
48 __mcd_core_path = os.path.join(GetPyCODACPath(),
"Core")
61 files=VTL.GetSourceCode(0),
62 command=VTL.GetBuildCommand(4),
63 lib=VTL.GetLinkDependency(0, 4,
"x64"),
65 source=os.path.join(__mcd_core_path,
"src"),
66 include=[posixpath.join(__mcd_cluster_incpath, x)
for x
in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4,
"x64")],
67 dependency=posixpath.join(__mcd_cluster_stable,
"lib"),
68 output=posixpath.join(__mcd_cluster_dev,
"bin"),
70 environment = VTL.GetEnvironment(2),
72 architecture=
"x64", scratch=VTL.Scratch, verbosity=2,
76 host=
"129.247.54.37", port=22, **kwargs):
78 Main function to execute the script.
80 envlist = list([]); envlist.append(environment); envlist = list(Utility.ArbitraryFlattening(envlist))
82 SSHBuild = pyx.SSH(BuildID, files, msvsc=
'vs2015', scratch=scratch, arch=architecture,
83 verbose=verbosity, incremental=incremental)
84 SSHBuild.SourcePath(source)
85 SSHBuild.AddIncludePath(include)
86 SSHBuild.AddDependencyPath(dependency)
89 SSHBuild.Environment(bash=x)
93 SSHBuild.Preprocessing(
'fpp -P -e -DPYD', inend=
'.for', outend=
'.f90')
95 SSHBuild.Preprocessing(copyfiles=files)
97 SSHBuild.OutputPath(libpath=output)
98 SSHBuild.Build(command, run=
"f2py", lib=lib)
99 SSHBuild.Settings(user, key, host, port, **kwargs)
102if __name__ ==
"__main__":
106 parser = argparse.ArgumentParser(description=
"Build shared Fortran libraries for Python remotely on the institute cluster.")
107 parser.add_argument(
"user", metavar=
"user", nargs=1, help=
"Current user for SSH connection")
108 parser.add_argument(
"key", metavar=
"key", nargs=1, help=
"Path to private SSH key")
112 args, _ = parser.parse_known_args()
122 key = os.path.join(Utility.AsDrive(
"C"),
"Users",user,
"Keys",
"Putty",
"id_rsa")
127 BuildID =
"beos"; env = VTL.GetEnvironment(i)
128 files=VTL.GetSourceCode(2); command=VTL.GetBuildCommand(4,
"free")
129 lib = []; include = []; dependency = []
131 source=os.path.join(__mcd_core_path,
"external",
"beos")
133 main(BuildID, user, key, files, command, lib, source, include, dependency, environment=env, verbosity=0, incremental=
True)
138 BuildID =
"bbeam"; env = VTL.GetEnvironment(i)
139 files=VTL.GetSourceCode(1); command=VTL.GetBuildCommand(4)
140 lib = []; include = []; dependency = []
142 source=os.path.join(__mcd_core_path,
"external",
"boxbeam")
144 main(BuildID, user, key, files, command, lib, source, include, dependency, environment=env, verbosity=0)
149 BuildID =
"mcd_core"; env = VTL.GetEnvironment(i)
151 main(BuildID, user, key, environment=env)
155 raise NotImplementedError
158 print(
"==================================")
159 print(
"Finished build for Python")
160 print(
"==================================")
Module containing all relevant modules and scripts associated with the building process.
main(BuildID, user, key, files=VTL.GetSourceCode(0), command=VTL.GetBuildCommand(4), lib=VTL.GetLinkDependency(0, 4,"x64"), source=os.path.join(__mcd_core_path,"src"), include=[posixpath.join(__mcd_cluster_incpath, x) for x in VTL.GetIncludeDirectory(__mcd_core_path, 0, 4, "x64")], dependency=posixpath.join(__mcd_cluster_stable,"lib"), output=posixpath.join(__mcd_cluster_dev,"bin"), environment=VTL.GetEnvironment(2), architecture="x64", scratch=VTL.Scratch, verbosity=2, incremental=False, host="129.247.54.37", port=22, **kwargs)