PyXMake Developer Guide: D:/03_Workspaces/01_Eclipse/pyx_core/PyXMake/VTL/app.py Source File

| PyXMake Developer Guide 1.0 PyXMake

D:/03_Workspaces/01_Eclipse/pyx_core/PyXMake/VTL/app.py
1 # -*- coding: utf-8 -*-
2 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 # % PyXMake - Build environment for PyXMake %
4 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 """
6 Triple-use minimum working example for PyXMake. This script can be
7 executed in three different ways in varying levels of accessibility
8
9 @note: Compile a stand-alone application using PyInstaller
10 Created on 02.05.2020
11
12 @version: 1.0
13 ----------------------------------------------------------------------------------------------
14 @requires:
15 - PyXMake
16
17 @change:
18 - Requires PyCODAC in PYTHONPATH.
19
20 @author: garb_ma [DLR-FA,STM Braunschweig]
21 ----------------------------------------------------------------------------------------------
22 """
23 import os, sys
24 import argparse
25
26 try:
27 import PyXMake as _ #@UnusedImport
28 except ImportError:
29 # Script is executed as a plug-in
30 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
31 finally:
32 from PyXMake.Build import Make as pyx #@UnresolvedImport
33 from PyXMake import VTL #@UnresolvedImport
34
35 try:
36 # Import PyCODAC to build library locally during setup.
37 import PyCODAC
38 # Get absolute package paths
39 __pyc_src_path = PyCODAC.PyCODACPath
40 except ImportError:
41 # This script is not executed as plug-in for PyCODAC
42 __pyc_src_path = ""
43 pass
44
45 def main(
46 BuildID,
47 # Build stand-alone application of PyCODAC
48 script=VTL.GetSourceCode(8),
49 # Resource paths
50 source=__pyc_src_path,
51 include=VTL.GetIncludeDirectory(os.path.dirname(__pyc_src_path), 8),
52 dependency=VTL.GetLinkDependency(8),
53 # Define output path
54 output=os.path.join(__pyc_src_path,"Plugin","JupyterLab","src",".dist"),
55 # Encryption, mode, verbose and scratch directory
56 encryption=True, mode="onefile", scratch=VTL.Scratch, verbosity=2,
57 # Additional keyword arguments
58 **kwargs):
59 """
60 Main function to execute the script.
61 """
62 # Create a new class instance
63 Py2App = pyx.PyInstaller(BuildID, script, scratch=scratch, verbose=verbosity)
64 # Activate or deactivate encryption. Defaults to True.
65 Py2App.Encryption(encryption)
66 # Add source, module and library paths
67 Py2App.SourcePath(source)
68 Py2App.AddIncludePath(include)
69 Py2App.AddDependencyPath(dependency)
70 # Define output directory
71 Py2App.OutputPath(output)
72 # Set pre-processing command
73 Py2App.Preprocessing(kwargs.get("preprocessing",""))
74 # Modify build mode
75 Py2App.Build(mode)
76 # Build application
77 Py2App.create(**kwargs)
78
79 if __name__ == "__main__":
80 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 # % Access command line inputs %
82 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 parser = argparse.ArgumentParser(description="Build a stand-alone python application")
84 parser.add_argument("entry", metavar="file.py", nargs=1, help="Main entry point of executable")
85
86 try:
87 _ = sys.argv[1]
88 args, _ = parser.parse_known_args()
89 # Extract command line option to identify the requested make operation
90 make_opt = args.make[0]
91 except:
92 # This is the default build option
93 make_opt = -1
94 # Build all supported features
95 if make_opt == -1:
96
97 # Build stand-alone PyCODAC application
98 delimn = " "; continuation = "&&"
99 command = delimn.join([
100 sys.executable,os.path.join(__pyc_src_path,"Plugin","DELiS","__install__.py"),continuation,
101 sys.executable,os.path.join(__pyc_src_path,"Plugin","DELiS","__update__.py"),continuation,
102 sys.executable,os.path.join(__pyc_src_path,"Plugin","Smetana","__install__.py"),continuation,
103 sys.executable,os.path.join(__pyc_src_path,"Plugin","Smetana","__update__.py")
104 ])
105
106 main("pycodac", mode="onedir", preprocessing=command)
107
108 # Finish
109 print("==================================")
110 print("Finished building stand-alone application")
111 print("==================================")
112 sys.exit()
PyXMake.VTL.app.main
def main(BuildID, script=VTL.GetSourceCode(8), source=__pyc_src_path, include=VTL.GetIncludeDirectory(os.path.dirname(__pyc_src_path), 8), dependency=VTL.GetLinkDependency(8), output=os.path.join(__pyc_src_path,"Plugin","JupyterLab","src",".dist"), encryption=True, mode="onefile", scratch=VTL.Scratch, verbosity=2, kwargs)
Definition: app.py:58
PyXMake.Build
Module containing all relevant modules and scripts associated with the building process.
Definition: __init__.py:1