PyXMake Developer Guide  1.0
PyXMake
D:/03_Workspaces/01_Eclipse/pyx_core/PyXMake/VTL/stm_make.py
1 # -*- coding: utf-8 -*-
2 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 # % PyXMake - Build environment for PyXMake %
4 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 """
6 Jenkins Test Server script.
7 
8 @note: Start build jobs on the Jenkins Test Server using PyXMake.
9 
10 @version: 1.0
11 ----------------------------------------------------------------------------------------------
12 @requires:
13  - PyXMake, PyCODAC
14 
15 @change:
16  -
17 
18 @author:
19  - hein_fa [DLR-FA,STM Braunschweig]
20  - garb_ma [DLR-FA,STM Braunschweig]
21 ----------------------------------------------------------------------------------------------
22 """
23 # See the file "LICENSE.txt" for the full license governing this code.
24 
25 ## @package PyXMake.VTL.stm_make
26 # Start build jobs on the Jenkins Test Server using PyXMake.
27 ## @author
28 # Falk Heinecke, Marc Garbade
29 ## @date
30 # 20.03.2018
31 ## @par Notes/Changes
32 # - Added documentation // mg 28.06.2018
33 
34 """
35 Setup script.
36 from main import releasecreator_Abhi
37 """
38 import shutil
39 from distutils.command import clean as _clean
40 from distutils import core
41 import os
42 import subprocess
43 import sys
44 import setuptools
45 
46 
47 class Clean(_clean.clean):
48  """
49  Little clean extension: Cleans up a non-empty build directory.
50  """
51  def run(self):
52  for path in ["build", "dist", ".coverage"]:
53  if os.path.isdir(path):
54  shutil.rmtree(path)
55  elif os.path.isfile(path):
56  os.remove(path)
57 
58 
59 class _BaseCommandRunner(core.Command):
60  """
61  Base class for encapsulating command line commands.
62  """
63  def run(self):
64  self._create_build_dir()
65  command = self._create_command()
66  self._run_command(command)
68 
69  @staticmethod
70  def _create_build_dir():
71  if not os.path.exists("build"):
72  os.mkdir("build")
73 
74  def _create_command(self):
75  pass
76 
77  def _run_command(self, command):
78  if self.verbose:
79  print(command)
80  subprocess.call(command, shell=True)
81 
82  def _perform_post_actions(self):
83  pass
84 
85 
86 class pyx_app(_BaseCommandRunner):
87  """
88  Base class for encapsulating command line arguments and build process.
89  """
90  _APP_NAME = ''
91  _INPUT_SCRIPT = ""
92 
93  description = "Compile a stand-alone application using PyInstaller."
94  user_options = [
95  # The format is (long option, short option, description).
96  ('source-path=', None, 'path to the folder holding source files'),
97  ('verbose=', None, 'controls the logging level (0 - Nothing, 2- Everything) Default: 0 - Nothing'),
98  ('mode=', None, 'define application build mode (one directory or one file mode)'),
99  ('scratch-path=', None, 'path to scratch folder where all temporary data is located during the build event'),
100  ('output-file-path=', None, 'path to the output directory'),
101  ]
102 
104  """
105  Set default values for options.
106  """
107  # Each user option must be listed here with their default value.
108  self.verbose = 0
109  self.source_path = ''
110  self.output_file_path = ''
111  self.mode = "onedir"
112  self.scratch_path = os.getcwd()
113  self.include = None
114  self.dependency = None
115 
116  def finalize_options(self):
117  """
118  Post-process options.
119  """
120  if self.source_path:
121  assert os.path.exists(self.source_path), (
122  'Source path'+self.source_path+' does not exist.')
123 
124  def _run_command(self, command):
125  """
126  Execute build command
127  """
128  from PyXMake.VTL import app # @UnresolvedImport
129 
130  # Are additional dependencies given? Defaults to empty lists
131  include = []; dependency = []
132  if self.include:
133  include = self.include
134  if self.dependency:
135  dependency = self.dependency
136 
137  # Compile stand-alone python application
138  app(self._APP_NAME,
139  script=self._INPUT_SCRIPT,
140  scratch=self.scratch_path,
141  source=self.source_path,
142  mode=self.mode,
143  output=self.output_file_path,
144  verbosity=self.verbose,
145  encryption=True,
146  include=include, dependency=dependency,
147  preprocessing=command)
148 
150  """
151  Runs the application build process using PyCODAC to create runtime for STMLab.
152  """
153  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
154 
155  # Set class defining attributes.
156  _KEY_OPT = 8
157  _APP_NAME = 'STMLab'
158  _INPUT_SCRIPT = GetSourceCode(_KEY_OPT)
159 
160  def _create_command(self):
161  from PyXMake import VTL
162  import PyCODAC #@UnresolvedImport
163 
164  # Add pre-assembled dependencies from VTL
165  self.include=VTL.GetIncludeDirectory(PyCODAC.PyCODACPath, self._KEY_OPT),
166  self.dependency=VTL.GetLinkDependency(self._KEY_OPT),
167 
168  # Assemble pre-processing command to include Smetana & DEliS
169  delimn = " "; continuation = "&&"
170  command = delimn.join([
171  sys.executable,os.path.join(PyCODAC.PyCODACPath,"Plugin","DELiS","__install__.py"),continuation,
172  sys.executable,os.path.join(PyCODAC.PyCODACPath,"Plugin","DELiS","__update__.py"),continuation,
173  sys.executable,os.path.join(PyCODAC.PyCODACPath,"Plugin","Smetana","__install__.py"),continuation,
174  sys.executable,os.path.join(PyCODAC.PyCODACPath,"Plugin","Smetana","__update__.py")
175  ])
176 
177  return command
178 
179 
181  """
182  Base class for encapsulating command line arguments and build process.
183  """
184  _BUNDLE_NAME = ''
185  _INPUT_FILES = ""
186 
187  description = "Compile a stand-alone installer using NSIS."
188  user_options = [
189  # The format is (long option, short option, description).
190  ('source-path=', None, 'path to the folder holding source files'),
191  ('verbose=', None, 'controls the logging level (0 - Nothing, 2- Everything) Default: 0 - Nothing'),
192  ('scratch-path=', None, 'path to scratch folder where all temporary data is located during the build event'),
193  ('output-file-path=', None, 'path to the output directory'),
194  ('install-path=', None, 'path to the default installation directory'),
195  ]
196 
198  """
199  Set default values for options.
200  """
201  # Each user option must be listed here with their default value.
202  self.verbose = 0
203  self.source_path = ''
204  self.output_file_path = ''
205  self.scratch_path = os.getcwd()
206  self.install_path = "$Desktop"
207 
208  def finalize_options(self):
209  """
210  Post-process options.
211  """
212  if self.source_path:
213  assert os.path.exists(self.source_path), (
214  'Source path'+self.source_path+' does not exist.')
215 
216  def _run_command(self, command):
217  """
218  Execute build command
219  """
220  from PyXMake.VTL import bundle # @UnresolvedImport
221 
222  # Compile stand-alone python application
223  bundle(self._BUNDLE_NAME,
224  files=self._INPUT_FILES,
225  scratch=self.scratch_path,
226  source=self.source_path,
227  output=self.output_file_path,
228  verbosity=self.verbose,
229  install_path=self.install_path,
230  assembly_path=os.path.dirname(self.source_path),
231  # Upload installer to FTP server.
232  user='ASRI_adm', key='lm9ITHUR', upload =True)
233 
235  """
236  Create an installer for STMLab using PyCODAC.
237  """
238  # Set class defining attributes.
239  _BUNDLE_NAME = 'STMLab'
240  _INPUT_FILES = "*.*"
241 
242  def _create_command(self):
243  # Import package
244  import svn.remote
245  from PyXMake.Tools import Utility
246  # Overwrite default installation directory
247  self.install_path = os.getenv("plugin_central_dir",os.path.join(Utility.AsDrive("c"),"simulia","cae","plugins","2019"))
248  # Define local output directories
249  __url_delimn = "/"
250  __pyc_plugin = os.path.join(self.source_path,"PyCODAC")
251  __smet_plugin = os.path.join(self.source_path,"Smetana")
252  # Set URLs to repositories
253  __pyc_plugin_repo = __url_delimn.join(["https:","","svn.dlr.de","STM-Routines","Analysis_Tools","MCODAC","trunk","src","mcd_pycodac","PyCODAC","Plugin","JupyterLab","src"])
254  __smet_plugin_repo = __url_delimn.join(["https:","","svn.dlr.de","STM-Routines","Analysis_Tools","MCODAC","trunk","src","mcd_pycodac","PyCODAC","Plugin","Smetana","src"])
255  # Export content of repositories into the current source folder to create a bundle
256  svn.remote.RemoteClient(__pyc_plugin_repo).export(__pyc_plugin, force=True)
257  svn.remote.RemoteClient(__smet_plugin_repo).export(__smet_plugin, force=True)
258  # Delete unwanted files and folders
259  shutil.rmtree(os.path.join(__pyc_plugin,".config"), ignore_errors=True)
260  os.remove(os.path.join(__pyc_plugin,"user","Paths.log"))
261  # Return dummy command
262  command = " "
263  # Return
264  return command
265 
266 
268  """
269  Base class for encapsulating command line arguments and build process.
270  """
271  _BUILD_NAME = ''
272  _INPUT_FILE = ""
273 
274  description = "Runs the html documentation build process of source code using Sphinx."
275  user_options = [
276  # The format is (long option, short option, description).
277  ('source-path=', None, 'path to the folder holding source files'),
278  ('verbose=', None, 'controls the logging level (0 - Nothing, 2- Everything) Default: 0 - Nothing'),
279  ('include-path=', None, 'path to additional files required for processing.'),
280  ('scratch-path=', None, 'path to scratch folder where all temporary data is located during the build event'),
281  ('output-file-path=', None, 'path to the output directory'),
282  ('logo=', None, 'Custom logo for the upper left corner. Defaults to None, leaving the space empty'),
283  ]
284 
286  """
287  Set default values for options.
288  """
289  # Each user option must be listed here with their default value.
290  self.verbose = 0
291  self.include_path = ""
292  self.source_path = ''
293  self.output_file_path = ''
294  self.scratch_path = os.getcwd()
295  self.logo = None
296 
297  def finalize_options(self):
298  """
299  Post-process options.
300  """
301  if self.source_path:
302  assert os.path.exists(self.source_path), (
303  'Source path'+self.source_path+' does not exist.')
304 
305  def _run_command(self, command):
306  """
307  Execute build command
308  """
309  from PyXMake.VTL import sphinx # @UnresolvedImport
310 
311  # Build documentation
312  sphinx(self._BUILD_NAME,
313  self._INPUT_FILE,
314  scratch=self.scratch_path,
315  source=self.source_path,
316  include=self.include_path,
317  output=self.output_file_path,
318  verbosity=self.verbose,
319  logo=self.logo)
320 
322  """
323  Runs the html documentation build process for Structural Mechanics Lab using a scheme from ReadtheDocs.
324  """
325  # Set class defining attributes
326  _BUILD_NAME = 'Structural Mechanics Lab'
327  _INPUT_FILE = "stm_lab"
328 
329  def _create_command(self):
330  from PyXMake.Tools import Utility # @UnresolvedImport
331  # Predefined script local variables
332  __arch = Utility.GetArchitecture()
333  __platform = Utility.GetPlatform()
334 
335  from PyCODAC.Tools.Utility import GetPyCODACPath #@UnresolvedImport
336  # Import and set local path to PyCODAC
337  __pyc_core_path = GetPyCODACPath()
338 
339  self.include_path=[os.path.join(__pyc_core_path,"Plugin","Smetana"),
340  os.path.join(__pyc_core_path,"Plugin","Smetana","src","Smetana"),
341  os.path.join(__pyc_core_path,"Core","bin",__platform,__arch)]
342  self.logo = os.path.join(__pyc_core_path,"VTL","doc","mcd_stmlab","pics","stm_lab_logo_bubbles.png")
343 
344  command = ' '
345  return command
346 
347 
349  """
350  Base class for encapsulating command line arguments and build process.
351  """
352  _BUILD_NAME = ''
353  _INPUT_FILES = []
354 
355  description = "Runs the html documentation build process of source code using Doxygen."
356  user_options = [
357  # The format is (long option, short option, description).
358  ('source-path=', None, 'path to the folder holding source files'),
359  ('verbose=', None, 'controls the logging level (0 - Nothing, 2- Everything) Default: 0 - Nothing'),
360  ('stype=', None, 'define type of source files (Java, Python or left blank) Defaults to: Fortran'),
361  ('scratch-path=', None, 'path to scratch folder where all temporary data is located during the build event'),
362  ('output-file-path=', None, 'path to the output directory'),
363  ]
364 
366  """
367  Set default values for options.
368  """
369  # Each user option must be listed here with their default value.
370  self.verbose = 0
371  self.source_path = ''
372  self.output_file_path = ''
373  self.stype = "Fortran"
374  self.scratch_path = os.getcwd()
375 
376  def finalize_options(self):
377  """
378  Post-process options.
379  """
380  if self.source_path:
381  assert os.path.exists(self.source_path), (
382  'Source path'+self.source_path+' does not exist.')
383 
384  def _run_command(self, command):
385  """
386  Execute build command
387  """
388  from PyXMake.VTL import doxygen # @UnresolvedImport
389 
390  # Search for all source files in source folder if files have not been specified.
391  if self._INPUT_FILES == []:
392  self._INPUT_FILES = [x[0] for x in os.walk(self.source_path)]
393 
394  # Build documentation
395  doxygen(self._BUILD_NAME,
396  title=[self.brief, self.header],
397  files=self._INPUT_FILES,
398  ftype=self.stype,
399  scratch=self.scratch_path,
400  source=self.source_path,
401  output=self.output_file_path)
402 
404  """
405  Runs the html documentation build process for PyXMake.
406  """
407  # Set class defining attributes
408  _BUILD_NAME = 'pyx_core'
409 
410  def _create_command(self):
411  from PyXMake.Tools import Utility # @UnresolvedImport
412  # Files to be processed
413  self._INPUT_FILES = [x[0] for x in Utility.PathWalk(self.source_path,True, startswith=(".","__"), contains=("doc","bin"), endswith=("make","scratch"))]
414 
415  self.brief = "PyXMake"
416  self.header = "PyXMake Developer Guide"
417  command = ' '
418  return command
419 
421  """
422  Runs the html documentation build process for PyCODAC.
423  """
424  # Set class defining attributes
425  _BUILD_NAME = 'pyc_core'
426 
427  def _create_command(self):
428  from PyXMake.Tools import Utility # @UnresolvedImport
429  # Files to be processed
430  self._INPUT_FILES = [x[0] for x in Utility.PathWalk(self.source_path, True, startswith=(".","__"),
431  contains=("DELiS","Smetana","PyXMake","external","doc","cmd","solver","src","bin","config"),
432  endswith=("make"))]
433 
434  self.brief = "PyCODAC"
435  self.header = "PyCODAC Developer Guide"
436  command = ' '
437  return command
438 
440  """
441  Runs the html documentation build process for BoxBeam.
442  """
443  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
444  # Set class defining attributes
445  _KEY_OPT = 1
446  _BUILD_NAME = 'box_main'
447  # Files to be processed
448  _INPUT_FILES = GetSourceCode(_KEY_OPT)
449 
450  def _create_command(self):
451  self.brief = "BoxBeam"
452  self.header = "BoxBeam Developer Guide"
453  command = ' '
454  return command
455 
457  """
458  Runs the html documentation build process for MCODAC.
459  """
460  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
461  # Set class defining attributes
462  _KEY_OPT = 0
463  _BUILD_NAME = 'mcd_core'
464  # Files to be processed
465  _INPUT_FILES = GetSourceCode(_KEY_OPT)
466 
467  def _create_command(self):
468  self.brief = "MCODAC"
469  self.header = "MCODAC Developer Guide"
470  command = ' '
471  return command
472 
474  """
475  Runs the html documentation build process for BoxBeam.
476  """
477  _BUILD_NAME = 'mcd_subbuck'
478 
479  def _create_command(self):
480  self.brief = "SubBuck"
481  self.header = "SubLaminate Buckling Developer Guide"
482  command = ' '
483  return command
484 
486  """
487  Runs the html documentation build process for BoxBeam.
488  """
489  _BUILD_NAME = 'mcd_mapper'
490 
491  def _create_command(self):
492  self.brief = "Mapper"
493  self.header = "Damage Mapping Developer Guide"
494  command = ' '
495  return command
496 
497 
499  """
500  Base class for encapsulating command line arguments and build process.
501  """
502  _PACKAGE_NAME = ''
503  _INPUT_FILES = []
504 
505  description = "Runs the build process of Fortran source code for Python using f2py."
506  user_options = [
507  # The format is (long option, short option, description).
508  ('msvsc=', None, 'identifier, which compiler version from Microsoft Visual Studio to be used'),
509  ('source-path=', None, 'path to the folder holding the fortran files'),
510  ('verbose=', None, 'controls the logging level (0 - Nothing) Default: 2 - Everything'),
511  ('scratch-path=', None, 'path to scratch folder where all temporary data is located during the build event'),
512  ('output-file-path=', None, 'path to the output directory'),
513  ('base-path=', None, 'path to base folder - optional'),
514  ]
515 
517  """
518  Set default values for options.
519  """
520  # Each user option must be listed here with their default value.
521  self._MAKE_OPT = {"Python":0, "Java":1, "Fortran":2}
522  self.verbose = 2
523  self.source_path = ''
524  self.output_file_path = ''
525  self.base_path = ''
526  self.scratch_path = os.getcwd()
527  self.libs = None
528  self.includes = None
529  self.libpaths = None
530  self.incremental = False
531 
532  # Select Visual Studio version in dependence of operating system.
533  if sys.getwindowsversion() >= (10, 0, 0):
534  # Jenkins2 // Windows 10
535  self.msvsc = "vs2015"
536  else:
537  # Jenkins // Windows 7
538  self.msvsc = "vs2010"
539 
540  def finalize_options(self):
541  """
542  Post-process options.
543  """
544  if self.source_path:
545  assert os.path.exists(self.source_path), (
546  'Source path for Fortran files '+self.source_path+' does not exist.')
547  if self.base_path:
548  assert os.path.exists(self.base_path), (
549  'Path to base folder '+self.base_path+' does not exist.')
550 
551  def _run_command(self, command):
552  """
553  Execute build command
554  """
555  # Build .pyd using f2py (for now!)
556  from PyXMake.VTL import py2x # @UnresolvedImport
557 
558  # Are additional dependencies given? Defaults to empty lists
559  includes = []; libs = []; libpaths = []
560  if self.includes:
561  includes = self.includes
562  if self.libs:
563  libs = self.libs
564  if self.libpaths:
565  libpaths = self.libpaths
566 
567  # Build Python package from Fortran source.
568  py2x(self._PACKAGE_NAME,
569  self._INPUT_FILES,
570  command=command,
571  libs=libs,include=includes,dependency=libpaths,
572  scratch=self.scratch_path, verbose=self.verbose,
573  source=self.source_path, output=self.output_file_path,
574  incremental=self.incremental,
575  msvsc=self.msvsc)
576 
578  """
579  Runs the build process for MCODAC.
580  """
581  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
582  # Set class defining attributes
583  _KEY_OPT = 0
584  _PACKAGE_NAME = 'mcd_core'
585  # Files to be processed
586  _INPUT_FILES = GetSourceCode(_KEY_OPT)
587 
588  def _create_command(self):
589  from PyXMake import VTL # @UnresolvedImport
590  from PyXMake.Tools import Utility # @UnresolvedImport
591  # Set library path
592  self.includes = [os.path.join(self.base_path,"include",Utility.GetPlatform(),Utility.GetArchitecture(), x)
593  for x in VTL.GetIncludeDirectory(self.base_path, 0, 4, Utility.GetArchitecture())],
594  self.libs = VTL.GetLinkDependency(self._KEY_OPT, self._MAKE_OPT["Python"], Utility.GetArchitecture())
595  self.libpaths = os.path.join(self.base_path,"lib",Utility.GetPlatform(), Utility.GetArchitecture())
596  # Custom compiler command for building a shared Java library.
597  return VTL.GetBuildCommand(self._MAKE_OPT["Python"])
598 
600  """
601  Runs the build process for BoxBeam.
602  """
603  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
604  # Set class defining attributes
605  _KEY_OPT = 1
606  _PACKAGE_NAME = 'bbeam'
607  # Files to be processed
608  _INPUT_FILES = GetSourceCode(_KEY_OPT)
609 
610  def _create_command(self):
611  from PyXMake.VTL import GetBuildCommand # @UnresolvedImport
612  return GetBuildCommand(self._MAKE_OPT["Python"])
613 
615  """
616  Runs the build process for Beos.
617  """
618  _PACKAGE_NAME = 'beos'
619  _KEY_OPT = 2
620  # Files to be processed
621  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
622  _INPUT_FILES = GetSourceCode(_KEY_OPT)
623 
624  def _create_command(self):
625  from PyXMake.VTL import GetBuildCommand # @UnresolvedImport
626  # Incremental compilation
627  self.incremental=True
628  return GetBuildCommand(self._MAKE_OPT["Python"], _format="free")
629 
631  """
632  Base class for encapsulating command line arguments and build process.
633  """
634  _PACKAGE_NAME = ''
635  _INPUT_FILES = []
636 
637  description = "Runs the build process of Fortran source code using the Intel Fortran Compiler through Python."
638  user_options = [
639  # The format is (long option, short option, description).
640  ('source-path=', None, 'path to the folder holding the fortran files'),
641  ('scratch-path=', None, 'path to scratch folder where all temporary data is located during the build event'),
642  ('output-file-path=', None, 'path to the output directory'),
643  ('base-path=', None, 'path to base folder - optional'),
644  ('verbose=', None, 'controls the logging level (0 - Nothing) Default: 2 - Everything'),
645  ('btype=', None, 'controls the building type. Defaults to static library. Use shared to indicate a dynamic library shall be created'),
646  ]
647 
649  """
650  Set default values for options.
651  """
652  # Each user option must be listed here with their default value.
653  self._MAKE_OPT = {"Python":0, "Java":1, "Fortran":2}
654  self.verbose = 0
655  self.source_path = ''
656  self.output_file_path = ''
657  self.base_path = ''
658  self.scratch_path = os.getcwd()
659  self.btype = 'static'
660  self.libs = None
661  self.includes = None
662  self.libpaths = None
663  self.modules = None
664 
665  def finalize_options(self):
666  """
667  Post-process options.
668  """
669  if self.source_path:
670  assert os.path.exists(self.source_path), (
671  'Source path for Fortran files '+self.source_path+' does not exist.')
672  if self.base_path:
673  assert os.path.exists(self.base_path), (
674  'Path to base folder '+self.base_path+' does not exist.')
675 
676  def _run_command(self, command):
677  """
678  Execute build command
679  """
680  from PyXMake.Tools import Utility # @UnresolvedImport
681  from PyXMake.VTL import ifort # @UnresolvedImport // Take care to set paths to PyXMake properly
682 
683  # Are additional dependencies given? Defaults to empty lists
684  includes = []; libs = []; libpaths = []
685  if self.includes:
686  includes = self.includes
687  if self.libs:
688  libs = self.libs
689  if self.libpaths:
690  libpaths = self.libpaths
691 
692  # Build Fortran library from source.
693  ifort(
694  self._PACKAGE_NAME,
695  # Build MCODAC by default
696  files=self._INPUT_FILES,
697  command = command,
698  libs = libs,
699  # Resource paths
700  source=self.source_path,
701  include=includes,
702  dependency=libpaths,
703  make=[self.modules,self.output_file_path],
704  # Architecture, verbose and scratch directory
705  architecture=Utility.GetArchitecture(), scratch=self.scratch_path, verbosity=self.verbose,
706  # Activate / deactivate incremental compilation. Does deactivate preprocessing.
707  incremental = False)
708 
710  """
711  Runs the build process for MCODAC.
712  """
713  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
714  _KEY_OPT = 0
715  _PACKAGE_NAME = 'mcd_java'
716  # Files to be processed
717  _INPUT_FILES = GetSourceCode(_KEY_OPT)
718 
719  def _create_command(self):
720  from PyXMake import VTL # @UnresolvedImport
721  from PyXMake.Tools import Utility # @UnresolvedImport
722  # Set library path
723  self.includes = [os.path.join(self.base_path,"include",Utility.GetPlatform(),Utility.GetArchitecture(), x)
724  for x in VTL.GetIncludeDirectory(self.base_path, 0, 4, Utility.GetArchitecture())],
725  self.libs = VTL.GetLinkDependency(self._KEY_OPT, self._MAKE_OPT["Java"], Utility.GetArchitecture())
726  self.libpaths = os.path.join(self.base_path,"lib",Utility.GetPlatform(), Utility.GetArchitecture())
727  # Custom compiler command for building a shared Java library.
728  return VTL.GetBuildCommand(self._MAKE_OPT["Java"])
729 
731  """
732  Runs the build process for BoxBeam.
733  """
734  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
735  # Set class defining attributes
736  _KEY_OPT = 1
737  _PACKAGE_NAME = 'bbeam_java'
738  # Files to be processed
739  _INPUT_FILES = GetSourceCode(_KEY_OPT)
740 
741  def _create_command(self):
742  from PyXMake import VTL # @UnresolvedImport
743  from PyXMake.Tools import Utility # @UnresolvedImport
744  # Set library path
745  self.includes = None
746  self.libs = VTL.GetLinkDependency(self._KEY_OPT, self._MAKE_OPT["Java"], Utility.GetArchitecture())
747  self.libpaths = os.path.join(self.base_path,"lib",Utility.GetPlatform(), Utility.GetArchitecture())
748  # Custom compiler command for building a shared Java library.
749  return VTL.GetBuildCommand(self._MAKE_OPT["Java"])
750 
752  """
753  Runs the build process for MCODAC on Windows.
754  """
755  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
756  # Set class defining attributes.
757  _KEY_OPT = 0
758  _PACKAGE_NAME = 'mcd_core'
759  # Files to be processed
760  _INPUT_FILES = GetSourceCode(_KEY_OPT)
761 
762  def _create_command(self):
763  from PyXMake import VTL # @UnresolvedImport
764  from PyXMake.Tools import Utility # @UnresolvedImport
765  # Set relative path & dependencies
766  self.includes = [os.path.join(self.base_path,"include",Utility.GetPlatform(),Utility.GetArchitecture(), x)
767  for x in VTL.GetIncludeDirectory(self.base_path, 0, 4, Utility.GetArchitecture())],
768  self.modules = os.path.join(self.base_path,"include",Utility.GetPlatform(), Utility.GetArchitecture())
769  self.libpaths = os.path.join(self.base_path,"lib",Utility.GetPlatform(), Utility.GetArchitecture())
770  self.libs = VTL.GetLinkDependency(self._KEY_OPT, self._MAKE_OPT["Fortran"], Utility.GetArchitecture())
771  # Custom compiler command for building a static Fortran library.
772  return VTL.GetBuildCommand(self._MAKE_OPT["Fortran"])
773 
775  """
776  Runs the build process for BoxBeam on Windows.
777  """
778  from PyXMake.VTL import GetSourceCode # @UnresolvedImport
779  # Set class defining attributes.
780  _KEY_OPT = 1
781  _PACKAGE_NAME = 'bbeam'
782  # Files to be processed
783  _INPUT_FILES = GetSourceCode(_KEY_OPT)
784 
785  def _create_command(self):
786  from PyXMake import VTL # @UnresolvedImport
787  from PyXMake.Tools import Utility # @UnresolvedImport
788  # Set library path
789  self.includes = None
790  self.libs = VTL.GetLinkDependency(self._KEY_OPT, self._MAKE_OPT["Fortran"], Utility.GetArchitecture())
791  self.modules = os.path.join(self.base_path,"include",Utility.GetPlatform(), Utility.GetArchitecture())
792  self.libpaths = os.path.join(self.base_path,"lib",Utility.GetPlatform(), Utility.GetArchitecture())
793  # Custom compiler command for building a static Fortran library.
794  return VTL.GetBuildCommand(self._MAKE_OPT["Fortran"])
795 
797  """
798  Base class for encapsulating command line arguments and build process.
799  """
800  _PACKAGE_NAME = ''
801  _INPUT_FILES = []
802 
803  description = "Runs an user-defined build process utilizing the PyXMake build environment."
804  user_options = [
805  # The format is (long option, short option, description).
806  ('msvsc=', None, 'identifier, which compiler version from Microsoft Visual Studio to be used'),
807  ('source-path=', None, 'path to the folder holding source files'),
808  ('source-file=', None, 'source file or list of source files. Defaults to "mcd_astandard"'),
809  ('verbose=', None, 'controls the logging level (0 - Nothing) Default: 2 - Everything'),
810  ('scratch-path=', None, 'path to scratch folder where all temporary data is located during the build event'),
811  ('base-path=', None, 'path to base folder - optional'),
812  ('output-file-path=', None, 'path to the output directory'),
813  ]
814 
816  """
817  Set default values for options.
818  """
819  # Each user option must be listed here with their default value.
820  self.verbose = 2
821  self.source_path = ''
822  self.source_file = 'mcd_astandard'
823  self.output_file_path = ''
824  self.base_path = ''
825  self.scratch_path = os.getcwd()
826  self.libs = None
827  self.includes = None
828  self.libpaths = None
829 
830  # Select Visual Studio version in dependence of operating system.
831  if sys.getwindowsversion() >= (10, 0, 0):
832  # Jenkins2 // Windows 10
833  self.msvsc = "vs2015"
834  else:
835  # Jenkins // Windows 7
836  self.msvsc = "vs2010"
837 
838  def finalize_options(self):
839  """
840  Post-process options.
841  """
842  if self.source_path:
843  assert os.path.exists(self.source_path), (
844  'Source path to build files '+self.source_path+' does not exist.')
845  if self.base_path:
846  assert os.path.exists(self.base_path), (
847  'Path to base folder '+self.base_path+' does not exist.')
848 
849  def _run_command(self, command):
850  """
851  Execute build command
852  """
853  import PyXMake.Build.Make as pyx # @UnresolvedImport // Take care to set paths to PyXMake properly
854 
855  # Execute custom commands directly, but utilize PyXMake syntax to set up the appropriate environment.
856  CBuild = pyx.Custom(self._PACKAGE_NAME, self.source_file, msvsc=self.msvsc, scratch=self.scratch_path, verbose=self.verbose)
857  CBuild.SourcePath(self.source_path)
858  CBuild.OutputPath(self.output_file_path, files=self.copyfiles)
859  CBuild.Preprocessing('fpp /P /e', inend='.f', outend='.for')
860  CBuild.Build(command)
861  if self.includes:
862  CBuild.AddIncludePath(self.includes)
863  if self.libpaths:
864  CBuild.AddDependencyPath(self.libpaths)
865  if self.libs:
866  CBuild.UseLibraries(self.libs)
867  CBuild.create()
868 
870  """
871  Runs the build process of MCODAC for ABAQUS.
872  """
873  # Set class defining attributes.
874  _PACKAGE_NAME = 'mcd_abaqus'
875  _MAKE_OPT = 6
876 
877  def _create_command(self):
878  from PyXMake import VTL # @UnresolvedImport
879  from PyXMake.Tools import Utility # @UnresolvedImport
880 
881  # Architecture dependencies
882  if (sys.version_info < (3, 0)):
883  raise NotImplementedError
884 
885  elif (sys.version_info > (3, 0)):
886  self.copyfiles = ["standardU.dll","explicitU-D.dll"]
887  self.libs = "mcd_corex64"
888  self.includes = [os.path.join(self.base_path,"include",Utility.GetPlatform(),Utility.GetArchitecture(), x)
889  for x in VTL.GetIncludeDirectory(self.base_path, 0, 4, Utility.GetArchitecture())]
890  self.includes.append(os.path.join(self.base_path,"include", Utility.GetPlatform(), Utility.GetArchitecture()))
891  self.libpaths = os.path.join(self.base_path,"lib",Utility.GetPlatform(),Utility.GetArchitecture())
892 
893  return VTL.GetBuildCommand(self._MAKE_OPT)
894 
895 
897  """
898  Runs the pylint command.
899  """
900  _PACKAGE_NAME = "src"
901 
902  description = "Runs the pylint command."
903  user_options = [
904  ("command=", None, "Path and name of the command line tool."),
905  ("out=", None, "Specifies the output type (html, parseable). Default: html")]
906 
907  def initialize_options(self):
908  self.command = "pylint"
909  self.out = "html"
910  self.output_file_path = "build/pylint.txt"
911 
912  def finalize_options(self):
913  self.verbose = self.distribution.verbose
914  if self.out == "parseable":
915  self.output_file_path = "build/pylint.txt"
916 
917  def _create_command(self):
918  return (
919  "{0} --rcfile=dev/pylintrc --output-format=parseable src > {3}".
920  format(self.command, self.out, self._PACKAGE_NAME, self.output_file_path))
921 
922  def _perform_post_actions(self):
923  if self.out == "parseable":
924  new_content = list()
925  with open(self.output_file_path, "rb") as file_object:
926  for line in file_object.readlines():
927  line = line.replace("\\", "/")
928  new_content.append(line)
929  with open(self.output_file_path, "wb") as file_object:
930  file_object.writelines(new_content)
931 
932 
934  """
935  Base class for all test classes
936  """
937  description = "Runs all unit tests using py.test."
938  user_options = [
939  ("command=", None, "Path and name of the command line tool."),
940  ("out=", None, "Specifies the output format of the test results." \
941  + "Formats: xml, standard out. Default: standard out."),
942  ("covout=", None, "Specifies the output format of the coverage report." \
943  + "Formats: xml, html.")]
944 
945  def initialize_options(self):
946  self.command = "py.test"
947  self.out = None
948  self.covout = None
949 
950  def finalize_options(self):
951  self.verbose = self.distribution.verbose
952 
954  """
955  Runs all unit tests.
956  """
957  def _create_command(self):
958  options = " test"
959  if self.out == "xml":
960  options = "--junitxml=build/xunit.xml test"
961  if not self.covout is None:
962  options = (
963  "--cov=src --cov-report={0} --cov-config=dev/coveragerc {1}".format(self.covout, options))
964  return "py.test --cov=src --cov-report=xml --cov-config=dev/coveragerc --junitxml=build/xunit.xml test -m \"not long and not indevelopment\""
965 
966 
968  """
969  Runs all unit tests.
970  """
971  def _create_command(self):
972  options = " test"
973  if self.out == "xml":
974  options = "--junitxml=build/xunit.xml test"
975  if not self.covout is None:
976  options = (
977  "--cov=src --cov-report={0} --cov-config=dev/coveragerc {1}".format(self.covout, options))
978  return "py.test test --junitxml=build/xunit.xml -s -m \"indevelopment\""
979 
980 
982  """
983  Runs all unit tests.
984  """
985  def _create_command(self):
986  options = " test"
987  if self.out == "xml":
988  options = "--junitxml=build/xunit.xml test"
989  if not self.covout is None:
990  options = (
991  "--cov=src --cov-report={0} --cov-config=dev/coveragerc {1}".format(self.covout, options))
992  return "py.test --cov=src --cov-report=xml --cov-config=dev/coveragerc --junitxml=build/xunit.xml test -s"
993 
994 
995 def _perform_setup():
996  _set_pythonpath()
997  _run_setup()
998 
999 
1000 def _set_pythonpath():
1001  python_path = []
1002  python_path = os.pathsep.join(python_path) + os.pathsep + os.environ.get("PYTHONPATH", "")
1003  os.environ["PYTHONPATH"] = python_path
1004 
1005 
1006 def _run_setup():
1007 
1008  version = 1.0
1009 
1010  if os.path.exists('test/__pycache__'):
1011  shutil.rmtree('test/__pycache__')
1012 
1013  setuptools.setup(
1014  name='My testing',
1015  version=version,
1016  cmdclass={"clean": Clean,
1017  "doxy_pyxmake": doxy_pyxmake,
1018  "doxy_boxbeam": doxy_boxbeam,
1019  "doxy_mcdcore": doxy_mcdcore,
1020  "doxy_mcdpycodac": doxy_mcdpycodac,
1021  "doxy_mcdmapper": doxy_mcdmapper,
1022  "doxy_mcdsubbuck": doxy_mcdsubbuck,
1023  "sphinx_stmlab": sphinx_stmlab,
1024  "f2py_beos": f2py_beos,
1025  "f2py_boxbeam": f2py_boxbeam,
1026  "f2py_mcodac": f2py_mcodac,
1027  "java_boxbeam": java_boxbeam,
1028  "java_mcodac": java_mcodac,
1029  "win_boxbeam": win_boxbeam,
1030  "win_mcodac": win_mcodac,
1031  "abq_mcodac": abq_mcodac,
1032  "app_pycodac": app_pycodac,
1033  "bundle_pycodac": bundle_pycodac,
1034  "shorttest": Test, "longtest": LongTest, "indevelopmenttest": InDevelopmentTest,
1035  "pylint": pylint
1036  },
1037  author="Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR)",
1038  author_email="marc.garbade@dlr.de",
1039  maintainer="Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR)",
1040  maintainer_email="marc.garbade@dlr.de",
1041  license="Copyright DLR",
1042  platforms=["Linux", "Unix", "Windows"],
1043  packages=setuptools.find_packages("src"),
1044  include_package_data=True,
1045  package_dir={"" : "src"},
1046  command_options={
1047  "build_sphinx": {
1048  "version": ("test.py", version),
1049  "release": ("test.py", version)}},
1050  )
1051 
1052 
1053 if __name__ == "__main__":
1054  _perform_setup()
1055 
1056 
1057 
def GetBuildCommand(make_opt=0, _format="fixed", _arch=Utility.GetArchitecture())
Definition: __init__.py:116
def GetSourceCode(key_opt=0)
Definition: __init__.py:41
Module containing virtual testing & benchmark scripts.
Definition: __init__.py:1
Module containing basic functionalities defined for convenience.
Definition: __init__.py:1
Create a make object to define the building environment.
Definition: Make.py:1