Skip to main content

pytest PyPI version

BPY Stub Generator

A utility to generate Python API stubs from documentation files in reStructuredText format.

Introduction

The main usage of the program is to create Python API stubs from the documentation generated during the build process of Blender or UPBGE so that an IDE can provide autocompletion support and type hints for relevant modules like bpy or bge.

There are already a number of tools created with a similar goal in mind, notably fake-bpy-module which can be a good alternative to this project.

However, bpystubgen has a few advantages over the others:

  • It's very fast - Some of those tools may take over an hour to generate the entire stubs for Blender. But bpystubgen can do it under a minute (1,593 source documents).
  • The generated stub modules preserve most of the source documentation, so you can use them as a manual as well.
  • It generates PEP-561 compliant stub modules, so it's safe to include them in your runtime module path.
  • Along with its fast execution speed, the project also provides well-organised API and test suites to make it easier to fix bugs or improve the output quality.

Screenshots

Auto-completion at work in PyCharm: Screenshot in PyCharm

Pop-up documentation support in VSCode: Screenshot in VSCode

Installation

The library can be installed using pip as follows:

$ pip install bpystubgen

Usage

Generating Stubs

If you want to generate the API stubs yourself, you can use bpystubgen module which can be invoked with the following options:

$ python -m bpystubgen -h

usage: bpystubgen [-h] [--verbose] [--quiet] input output

Generate Python API stubs from Blender documentation.

positional arguments:
  input       Source directory where *.rst files are located
  output      Output directory where generated modules will be saved

optional arguments:
  -h, --help  show this help message and exit
  --verbose   Print debug messages
  --quiet     Print only error messages

Using Stubs

If you just want to use the API stubs, you can install them from PyPI without having to generate them yourself.

There are two variants of the API stubs, one for Blender and the other for UPBGE. For Blender, you can install blender-stubs module with an appropriate version qualifier as follows:

$ pip install blender-stubs==3.1.*

This will install the latest module for Blender 3.1, and for now stubs are provided for Blender 2.80 and onwards. You can also specify the next unreleased version as 3.2.* to get the latest snapshot of the module.

As for UPBGE, stubs are available for the 0.3 release, which you can install as follows:

$ pip install upbge-stubs==0.3.0.*

And for the latest snapshot version,

$ pip install upbge-stubs==0.3.1.*

You can also install it using Pipenv. Note that it is required to set allow_preleases option in case the target application has no stable release (i.e. UPBGE 0.3 branch). You can use the following content as a template for your Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[packages]
"upbge-stubs" = "==0.3.1.*"

[requires]
python_version = "3.10"

[pipenv]
allow_prereleases = true

Also, it would be more correct to use [dev-packages] instead of [packages], in which case you can install or update the stubs using the -d flag like pipenv update -d.

License

This project is provided under the terms of GNU General Public License v3 (GPL3).

Metadata

Release files for bpystubgen 0.2.7

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

Source distribution (sdist)

Source distribution for bpystubgen 0.2.7
File Size Uploaded Provenance
bpystubgen-0.2.7.tar.gz 36.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bpystubgen 0.2.7
File Interpreter ABI Platform
bpystubgen-0.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 74.8 kB

Release files / bpystubgen-0.2.7.tar.gz

Download URL bpystubgen-0.2.7.tar.gz
Size 36.8 kB
Tags Source
SHA-256 checksum
How to use checksums
74eabde8d490dd2a348534d9819bbd8b286211bca78b53f1316584d2095d81ca
BLAKE2b-256 checksum
How to use checksums
06088ddcaba0916aaeb4ecc89066d457e8401ba222259ad6a8bd42c1d981588f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / bpystubgen-0.2.7-py3-none-any.whl

Download URL bpystubgen-0.2.7-py3-none-any.whl
Size 38.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7200b82106ae1720dbdcc7d3472c2ab87a84ea8532ccaf65cd50896eeb270d13
BLAKE2b-256 checksum
How to use checksums
433fb5e3f157a4452000cf000f445314cb1ed4b2ec03960899bbb60261d72aa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Security for bpystubgen 0.2.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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