Windows environment variables

The Windows user environment variable PATH

During installation, the location of the folder containing gtc.exe is added to the Windows environment variable for the user’s PATH.

The user’s environment variable GTC_LIB

During installation, an environment variable GTC_LIB is created for the current user (if it does not exist already).

The paths in GTC_LIB identify folders that GTC will search when an import statement is executed.

The lib folder in the installation directory (e.g.: C:\Users\user.name\AppData\Local\gtc\lib) is added to GTC_LIB during installation, as is the user’s My GTC\lib folder.

If other paths are added to GTC_LIB, they will not be removed when GTC is uninstalled, so software updates will not affect user-defined extensions.

The user’s environment variable GTC_SCRIPTS

During installation, there is an option to create a My GTC folder in the user’s home directory. When this option is selected (by default) an environment variable GTC_SCRIPTS is created for the current user (if it does not exist already). A folder My GTC\scripts is created and the path is added to GTC_SCRIPTS.

The GTC_SCRIPTS variable is used to identify folders of user defined scripts. When GTC runs, it first tries to find a script in the current folder, but if this fails it will search the folders in the order that they appear in GTC_SCRIPTS.

Extension modules and packages

Python uses structures called a module and a package.

  • a module is a file containing Python definitions and statements
  • a package is a collection of modules in a folder or folders.

If a GTC script contains an import statement of the form:

import my_module

the paths in the environment variable GTC_LIB, plus the current working directory, will be searched for my_module.py (in addition to a search of the modules included with GTC).

If a GTC script contains an import statement of the form:

import my_package.my_module

or

from my_package import my_module

a search for the folder my_package is carried out by looking in the paths defined in GTC_LIB. When found, my_package is then searched for my_module.py.

The Python documentation should be consulted for more information about modules and packages.