Script Processing

The XML extension definition file for an extension can reference multiple IronPython scripts. For example, consider this excerpt from the XML file for the extension WizardDemos:

<extension version="2" minorversion="1" name="WizardDemos">
	<guid shortid="WizardDemos">7fdb141e-3383-433a-a5af-32cb19971771</guid>
	<author>ANSYS Inc.</author>
	<description>Simple extension to test wizards in different contexts.</description>

	<script src="main.py" />
	<script src="ds.py" />
	<script src="dm.py" />
	<script src="sc.py" />

This extension has four <script> blocks. All four scripts referenced by this extension are placed in the extension folder. When ACT processes multiple scripts, it loads them into a single scope, as if the contents of all scripts are contained in a single flat file. This works for a scripted extension that uses import statements because all scripts reside in the extension folder.

When a scripted extension is to be compiled into a binary extension, you can specify which files to compile by setting the attribute compiled for the <script> blocks to true before building the WBEX file:

	<script src="main.py" compiled="true" />
	<script src="ds.py" compiled="true" />
	<script src="dm.py" compiled="true" />
	<script src="sc.py" compiled="true" />

When ACT processes a WBEX file with multiple <script> blocks that are marked as compiled, it essentially pushes all of the content in these scripts into the binary buffer stream. When the installed WBEX file is loaded, ACT then reads the <script> blocks from the binary buffer and loads the script content into a single scope.

Consequently, the result for the binary version is the same as the scripted version. All contents in the multiple IronPython scripts are loaded into a single scope without any module designations, just as if you had originally combined the different scripts into one large, single script.

Unlike a scripted extension, the installed binary extension can no longer import another IronPython script as a module because the scripts no longer reside in an extension folder. Before building a binary extension, you must remove import statements and module prefixes because methods and classes are invoked as if all scripts are in one large, single script. By flattening IronPython scripts in this way, both the scripted and binary versions of the extension run successfully.

This flattening does make it difficult to test the scripted extension before building the binary version because you cannot truly test the implementation until after you create and install the WBEX file. However, you can compile your IronPython modules into DLLs, remove their corresponding <script> blocks from the XML extension definition file, and import them as required in your main IronPython script.


Note:  You cannot currently flag files to have the binary extension builder skip them. During the building of a WBEX file, any messages that you see about files being skipped are the result of ACT no longer needing the plain-text scripts because the <script> blocks are marked as compiled="true".



Release 18.2 - © ANSYS, Inc. All rights reserved.