Skip to main content

stubgenj

PEP-484 python stub generator for Java modules using the JPype import system. Originally based on mypy stubgenc.

Usage through cmmnbuild-dep-manager

$ python -m cmmnbuild_dep_manager stubgen

Every package registered in cmmnbuild_dep_manager can request stubs to be generated for particular prefixes by defining __stubgen_packages__ next to __cmmnbuild_deps__.

For more details, consult the cmmnbuild_dep_manager docs.

CLI usage

$ python -m stubgenj --help
usage: __main__.py [-h] [--jvmpath JVMPATH] [--classpath CLASSPATH]
                   [--output-dir OUTPUT_DIR] [--convert-strings]
                   [--no-stubs-suffix]
                   prefixes [prefixes ...]

Generate Python Type Stubs for Java classes.

positional arguments:
  prefixes              package prefixes to generate stubs for (e.g.
                        org.myproject)

optional arguments:
  -h, --help            show this help message and exit
  --jvmpath JVMPATH     path to the JVM ("libjvm.so", "jvm.dll", ...)
                        (default: use system default JVM)
  --classpath CLASSPATH
                        java class path to use, separated by ":". glob-like
                        expressions (e.g. dir/*.jar) are supported (default:
                        .)
  --output-dir OUTPUT_DIR
                        path to write stubs to (default: .)
  --convert-strings     convert java.lang.String to python str in return
                        types. consult the JPype documentation on the
                        convertStrings flag for details
  --no-stubs-suffix     do not use PEP-561 "-stubs" suffix for top-level
                        packages
  --no-javadoc          do not generate docstrings from JavaDoc where 
                        available

E.g. generate stubs for java packages cern.lsa.* and java.* using the JARs from cmmnbuild-dep-manager:

$ python -m stubgenj --convert-strings --classpath "/path/to/cmmnbuild_dep_manager/lib/*.jar" cern.lsa java

The stubs will be put in the working directory as stub-only packages (PEP-561).

Python API usage

Start up the JVM, enable the JPype import system, then invoke stubgenj.generateJavaStubs.

With plain JPype:

import jpype
import stubgenj

jpype.startJVM(None, convertStrings=True)  # noqa
import jpype.imports  # noqa
import java.util  # noqa

stubgenj.generateJavaStubs([java.util], useStubsSuffix=True)

Through cmmnbuild-dep-manager:

import cmmnbuild_dep_manager
import stubgenj

with cmmnbuild_dep_manager.Manager().imports():
    import java.util  # noqa
    stubgenj.generateJavaStubs([java.util], useStubsSuffix=True)

Metadata

Release files for stubgenj 0.2.12

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

Source distribution (sdist)

Source distribution for stubgenj 0.2.12
File Size Uploaded Provenance Actions
stubgenj-0.2.12.tar.gz 23.7 kB Without provenance Details for stubgenj-0.2.12.tar.gz

Built distribution (wheel)

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

Total release size: 45.8 kB

Release files / stubgenj-0.2.12.tar.gz

Download URL stubgenj-0.2.12.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b49240edbbb1c89f449b7cb547b0dac8fde531366641dad07b0a83e634c91f1f
BLAKE2b-256 checksum
How to use checksums
3efba437e750af248b89d871ef011d56d00fd4d3cf6539d74b5f6d4e4d4b7c4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.14.2 setuptools/27.2.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.1

Release files / stubgenj-0.2.12-py3-none-any.whl

Download URL stubgenj-0.2.12-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf7cc475536e92e5958c8e2dcbb5c1d7cfbb3753b17f4df2ac86e0b385ee6683
BLAKE2b-256 checksum
How to use checksums
47ba408d9c326f8f6a7dcb6ca181f97b256f32cd64289b4c59ff224964be5f8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.14.2 setuptools/27.2.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.1

Security for stubgenj 0.2.12

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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