gdsfactory provides you with generic component functions to build your PDKs and masks for different foundries.

You just need to adapt the functions to your foundry and build your own PDK (see UBC PDK example).

Gdsfactory extends phidl and gdspy with some useful photonics functions (see photonics package pp) to generate GDS layouts (GDSII is the standard format to create masks sets in the CMOS industry)

  • functions easily adaptable to define components
  • define component sweeps (Design of Experiments or DOEs) in YAML files and GDS masks (together with JSON metadata)
  • route optical/electrical ports to pads and grating couplers


Works for python>=3.7 for Windows, MacOs and Linux.
Github runs all the tests at least once a day for different versions of python (3.7, 3.8, 3.9)

If you are on Windows, I recommend you install it with Anaconda3 or Miniconda3.

I also recommend that you install klayout to visualize the GDS files that you create.

For Windows, Linux and MacOs you can install the latest released version:

conda install -c conda-forge gdspy
pip install gdsfactory
pf install

Or you can install the development version:

git clone
cd gdsfactory


You can run tests with pytest. This will run 3 types of tests:

  • pytest will test any function in the pp package that starts with test_
  • lytest: writes all components GDS in run_layouts and compares them with ref_layouts
    • you can check out any changes in the library with pf diff ref_layouts/bbox.gds run_layouts/bbox.gds
  • regressions tests: avoids unwanted regressions by storing Components ports position and metadata in YAML files. You can force to regenerate those files running make test-force from the repo root directory.
    • pp/ stores container function settings in YAML and port locations in a CSV file
    • pp/components/ stores all the component settings in YAML
    • pp/components/ stores all port locations in a CSV file


  • pp photonic-package
    • components: define components
    • drc: check geometry
    • gdsdiff: hash geometry and show differences by displaying boolean operations in klayout
    • klive: stream GDS directly to klayout
    • ports: to connect components
    • routing: add waveguides to connect components
    • samples: python tutorial
    • tests:
    • klayout: klayout generic tech layers and klive macro
  • notebooks: jupyter-notebooks for training

pf Photonic factory command line interface

pf builds, tests, and configures masks and components from the command line. Just type pf in a terminal.

  build    Commands for building masks
  config   Work with pdk.CONFIG
  drc      Run DRC
  log      Work with logs
  show     Show a GDS file in Klayout using KLive
  status   Shows version and configuration info
  test     Run tests using pytest.