Skip to main content

Unofficial python stubs for Adobe Substance 3D Painter

These stubs are designed to be used with a type checker like mypy to provide static type checking of python code, as well as to provide analysis and completion in IDEs like PyCharm and VSCode (with Pylance).

Installing

pip install types-substance_painter

The version of the package corresponds to the version of Substance Painter that it is generated from, plus a version suffix for the revision of the stubs.

Generating

stubgen_substance_painter.py requires preliminary steps before it can be run. Do these two tasks:

Extract stubs from running Substance Painter

The _substance_painter modules are accessible within Substance Painter. You'll need to run stubgen from inside the console. Mypy by default launches a subprocess when doing stubgen, which isn't what we want. So we patch that behavior with common\src\stubgenlib\moduleinspect.py. For that to work, you'll need to ensure that your Mypy install is pure-python.

# Ensure our mypy is the same version as substance, so we'll be able to import it.
cd cg-stubs/substance_painter && uv sync --python 3.11
# launch painter in the root directory
painter

Within painter:

import sys; sys.path.append("substance_painter/.venv/Lib/site-packages")
import stubgenlib.moduleinspect; stubgenlib.moduleinspect.patch()
import mypy.stubgen; mypy.stubgen.main(['-p', '_substance_painter', '-o', 'substance_painter/stubs'])
  • sys.path.insert(0, ".venv/Lib/site-packages") to put our mypy install on path.
  • moduleinspect.patch() patches mypy to run in-process rather than in-subprocess.
  • mypy.stubgen.main(['-p', '_substance_painter', '-o', 'substance_painter/stubs']) tells mypy to import the _substance_painter package and output it to substance_painter/stubs.

Extract stubs from the Substance Painter folder

In the root of the repository, run:

uv run --directory substance_painter stubgen --no-import $SUBSTANCE_PAINTER_ROOT/resources/python/modules/substance_painter/ --search-path ./stubs -o ./stubs
  • set $SUBSTANCE_PAINTER_ROOT to the substance painter install directory.
  • --search-path to find the _substance_painter/ files
  • -o to output to the stubs folder

Run nox target

nox -s 'generate(substance_painter)'

(A note--this is not idempotent. Your stub folders will be renamed from substance_painter to substance_painter-stubs, so running it again won't find the substance_painter folder.)

Metadata

Release files for types-substance_painter 2024.10.1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for types-substance_painter 2024.10.1.2.0
File Interpreter ABI Platform
types_substance_painter-2024.10.1.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / types_substance_painter-2024.10.1.2.0-py2.py3-none-any.whl

Download URL types_substance_painter-2024.10.1.2.0-py2.py3-none-any.whl
Size 34.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f0492f68d55fd32bb45de51cee08275b05d454976df2f588be5287bc5ae5731b
BLAKE2b-256 checksum
How to use checksums
79e4de23799837ace33b8e504c569cc754ff57cf3043dc5fa7fcb2a5285cd2b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release history Release notifications | RSS feed

This release

2024.10.1.2.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page