Registry / data / klayout

klayout

JSON →
library0.30.7pypypi✓ verified 35d ago

KLayout is a layout viewer and editor primarily for integrated circuit layouts (GDSII, OASIS). The `klayout` Python package (v0.30.7) provides a standalone scripting interface to KLayout's powerful database and geometry manipulation functionalities, allowing users to programmatically create, modify, and analyze layouts without requiring the full graphical application. It maintains an active release cadence, with minor updates released frequently to address issues and enhance features, often multiple times a month.

dataserialization
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

For Python scripting, `klayout.db` is the recommended and modern way to access the layout database. `pya` is a legacy module, primarily for backward compatibility within the KLayout application's own interpreter, and may not be reliably available or updated with `pip install klayout`.

import klayout.db as db

The `Layout` class is part of the `klayout.db` module.

layout = db.Layout()

The `LayerInfo` class for defining layers is part of the `klayout.db` module.

layer_info = db.LayerInfo(1, 0)

This quickstart demonstrates how to create a new GDSII layout, define a cell and layer, add a simple rectangular shape, and save the result using the `klayout.db` module.

import klayout.db as db # Create a new layout object layout = db.Layout() # Set the database unit (DBU) to 1 nanometer (0.001 micrometers) layout.dbu = 0.001 # Create a top cell named 'TOP' top_cell = layout.create_cell("TOP") # Define a layer (e.g., GDS layer 1, datatype 0) layer_info = db.LayerInfo(1, 0) layer_idx = layout.layer(layer_info) # Add a box to the layer in the top cell # Coordinates are in micrometers if DBU is 0.001 (e.g., 100x200 um) box = db.DBox(0, 0, 100, 200) top_cell.shapes(layer_idx).insert(box) # Save the layout to a GDSII file output_filename = "my_first_layout.gds" layout.write(output_filename) print(f"Layout '{output_filename}' created successfully.")
Debug
Known footguns
breakingThe recommended way to access KLayout's database objects transitioned from `pya` to `klayout.db` starting with KLayout v0.30.0. While `pya` might still be available for compatibility, `klayout.db` offers a more consistent and future-proof interface.
gotchaThe `klayout` Python package (installed via `pip`) provides only the scripting interface. It does NOT include the full KLayout graphical user interface (GUI) application. For the GUI, you must download and install the KLayout application separately from the official website.
gotchaKLayout operates with a 'database unit' (DBU) which determines the internal resolution. All coordinates and dimensions are implicitly in DBU units. If not explicitly set, the default DBU can lead to unexpected scaling.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources