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_painterpackage and output it tosubstance_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_ROOTto the substance painter install directory. --search-pathto find the_substance_painter/files-oto 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file types_substance_painter-2024.10.1.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: types_substance_painter-2024.10.1.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 34.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0492f68d55fd32bb45de51cee08275b05d454976df2f588be5287bc5ae5731b
|
|
| MD5 |
4f4856de5f501e59b1cbb39bf79be1fa
|
|
| BLAKE2b-256 |
79e4de23799837ace33b8e504c569cc754ff57cf3043dc5fa7fcb2a5285cd2b8
|