Skip to main content
Version: 16.12.0

Loading a Glasswall library

Prerequisites

General

note

From version 5.12.0 the Glasswall Python Wrapper requires Python 3.8 or higher. If you are running Python 3.6 or 3.7, install version 5.11.0 instead (pip install glasswall==5.11.0).

Glasswall Python Wrapper installation

Online installation

pip install --upgrade glasswall

Offline installation

Run the following commands within the directory containing the offline installation files.

pip install --upgrade --no-index --find-links=. glasswall

Note: The wheels available for offline installation include all necessary dependencies for their respective packages and have been tested on amazonlinux.2023, rockylinux.8.9, and ubuntu.22.04 environments.

Loading a Glasswall library

Editor

Libraries are loaded on initialization and have one required argument: library_path which can be the path to a file or a directory. If a directory is specified it is recursively searched and the library with the latest change time will be loaded.

import glasswall


# Load the Glasswall Editor library
editor = glasswall.Editor(r"C:\gwpw\libraries\10.0")
>>> 2025-03-15 12:27:42.337 glasswall INFO     __init__     Loaded Glasswall Editor version 2.1464.1 from C:\gwpw\libraries\10.0\glasswall_core2.dll

WordSearch

WordSearch has a dependency on the Editor libraries. When loading WordSearch, ensure that the WordSearch and Editor libraries are located within the same working directory.

import glasswall


# Load the Glasswall WordSearch library
word_search = glasswall.WordSearch(r"C:\gwpw\libraries\10.0")
>>> 2025-06-03 11:19:09.223 glasswall.config.logging  INFO    __init__    Loaded Glasswall WordSearch version 1.249.0 from from C:\gwpw\libraries\10.0\glasswall.word.search.dll

Providing a licence

By default, the Editor class expects a valid licence file to be located in the same directory as the library_path. You can also specify a different path to a gwkey.lic licence file using the licence argument.

import glasswall


# Load the Glasswall Editor library with a specified licence file
editor = glasswall.Editor(r"C:\gwpw\libraries\10.0", licence=r"C:\gwpw\licence\gwkey.lic")

Alternatively, you can pass the licence data in-memory as a bytes, bytearray, or io.BytesIO object.

import glasswall


# Alternatively, load the licence from in-memory bytes or bytearray
with open(r"C:\gwpw\licence\gwkey.lic", "rb") as f:
licence_data = f.read()

editor = glasswall.Editor(
r"C:\gwpw\libraries\10.0",
licence=licence_data # In-memory licence data
)