Glasswallライブラリの読み込み
前提条件
一般
- Python >= 3.6
- 一般的なOS固有の要件および環境設定については、Installationを参照してください。
Glasswall Python Wrapper のインストール
オンラインインストール
pip install --upgrade glasswall
オフラインインストール
オフラインインストール用ファイルを含むディレクトリ内で、次のコマンドを実行します。
pip install --upgrade --no-index --find-links=. glasswall
注: オフラインインストールで利用可能な wheel には、それぞれのパッケージに必要な依存関係がすべて含まれており、amazonlinux.2023、rockylinux.8.9、ubuntu.22.04 環境でテストされています。
Glasswall ライブラリの読み込み
Editor
ライブラリは初期化時に読み込まれ、必須引数が 1 つあります: library_path。これはファイルまたはディレクトリへのパスにできます。ディレクトリが指定された場合は再帰的に検索され、変更時刻が最新のライブラリが読み込まれます。
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 は Editor ライブラリに依存しています。WordSearch を読み込む際は、WordSearch ライブラリと Editor ライブラリが同じ作業ディレクトリ内に配置されていることを確認してください。
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
ライセンスの提供
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")
または、ライセンスデータを bytes、bytearray、または io.BytesIO オブジェクトとしてメモリ内で渡すこともできます。
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
)