Skip to content

kwokcb/types-MaterialX

Repository files navigation

MaterialX Type Stub Generator

Logic to create PEP 561 compliant type stubs for MaterialX

  • Enables IntelliSense, autocomplete, and type checking for MaterialX in Python IDEs.
  • The sample stubs are based on head of version 1.39.5.
  • The repo can be cloned to create stubs for the desired MaterialX install.
  • Stubs are generated as MaterialX-stubs/ package to provide types for your installed MaterialX package (PEP 561 compliant).

How It Works

This package follows PEP 561 for distributing type information:

  • The package is named types-MaterialX (standard naming for stub-only packages)
  • Stubs are installed in MaterialX-stubs/ directory
  • When you import MaterialX in your code, type checkers (mypy, Pylance, etc.) automatically discover and use the stubs from MaterialX-stubs/
  • This works alongside your regular MaterialX installation without conflicts

Installation

Standard Installation

For MaterialX versions available on PyPI (1.39.4 and earlier):

pip install .

Installation with Local MaterialX (1.39.5+)

If you have a locally built MaterialX version (e.g., 1.39.5) that's not yet on PyPI:

# First, ensure your local MaterialX is installed
pip install /path/to/your/MaterialX

# Then install types-MaterialX without build isolation
pip install --no-build-isolation .

Note: The --no-build-isolation flag tells pip to use your current environment's MaterialX installation during the build process, rather than creating an isolated build environment with only PyPI packages.

VS Code Setup

pip install .
# Reload VS Code: Ctrl+Shift+P → "Developer: Reload Window"

Requirements: Python and Pylance extension

Included Modules

  • PyMaterialXCore
  • PyMaterialXFormat
  • PyMaterialXGenShader
    • PyMaterialXGenGlsl
    • PyMaterialXGenOsl
    • PyMaterialXGenMsl
    • PyMaterialXGenMdl
  • PyMaterialXRender
    • PyMaterialXRenderGlsl
    • PyMaterialXRenderOsl
  • colorspace
  • datatype
  • main

Development

Building Stubs

Stubs can be rebuild using:

./setup.sh  # Generate stubs, build wheel, and install

Then installed using again using pip

Clean Up

This will remove all build artifacts including generated stubs:

cleanup.sh  # Clean build and stubs

Build distrubtion

./build_dist.sh

If build and / or twine are not found, install using

pip install ".[dev]"

About

MaterialX Python Stub Generator

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published