Skip to main content

Unofficial python stubs for Adobe Substance 3D Painter

Project description

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.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

types_substance_painter-2024.10.1.2.0-py2.py3-none-any.whl (34.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file types_substance_painter-2024.10.1.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for types_substance_painter-2024.10.1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f0492f68d55fd32bb45de51cee08275b05d454976df2f588be5287bc5ae5731b
MD5 4f4856de5f501e59b1cbb39bf79be1fa
BLAKE2b-256 79e4de23799837ace33b8e504c569cc754ff57cf3043dc5fa7fcb2a5285cd2b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page