pyside6-qml-stubgen


Namepyside6-qml-stubgen JSON
Version 0.1.0a7 PyPI version JSON
download
home_pageNone
SummaryGenerate QML stub files (.qmltypes) from Python modules (which use PySide6)
upload_time2024-10-29 17:46:55
maintainerNone
docs_urlNone
authorMatthew Joyce
requires_python>=3.10
licenseNone
keywords pyside6 qml qt6 type checking
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pyside6-qml-stubgen
===================

Generate QML stub files (`.qmltypes`) from Python modules (which use PySide6)

Installation
------------

This tool can be installed though PyPI:

```bash
pip install pyside6-qml-stubgen
```

If you want to use a development version, instead clone the repo and then install using pip:

```bash
git clone https://github.com/matsjoyce/pyside6-qml-stubgen.git
pip install ./pyside6-qml-stubgen
```

This tool has been tested on Linux, Windows and MacOS using pip-installed PySide6 (on GitHub Actions), and on Arch Linux using system packages. It does not run with PyQt6, although it should be possible in theory (send a PR if you get it working). And finally, it does not run using Qt 5 (PySide2 or PyQt5), as that version is no longer being developed, and QML in Qt 5 has less features than in Qt 6, making it a less attractive target for this sort of tool.

Simple example
--------------

As an example, we'll run this tool on https://github.com/matsjoyce/fantasia2. There are two steps to type checking your QML code when using PySide6. First generate the QML type stubs using this tool:

```bash
pyside6-qml-stubgen fantasia2 --out-dir qmltypes --ignore fantasia2/alembic/
```

This command will generate a folder tree containing `.qmltypes` files and `qmldir` files matching the runtime structure of QML modules registered by the Python modules.

The second step is to run `qmllint` on your QML files using the type stubs:

```bash
/usr/lib/qt6/bin/qmllint fantasia2/*.qml -I ./qmltypes
```

If you change the QML files, you can just rerun `qmllint`. If you change the Python interface, you should rerun both commands.

Links to other projects
-----------------------

This tool relies heavily on PySide6, and is inspired by the [`metaobjectdump.py`](https://code.qt.io/cgit/pyside/pyside-setup.git/tree/sources/pyside-tools/metaobjectdump.py) tool, although this tool uses a runtime approach instead of static analysis, as that works better on large programs.

Command-line arguments
----------------------

```bash
$ pyside6-qml-stubgen --help
Generate QML stub files (.qmltypes) from Python modules (which use PySide6)

Usage:
    pyside6-qml-stubgen <in-dir>... --out-dir=<out-dir> [--ignore=<path>...] [--metatypes-dir=<dir>] [--qmltyperegistrar-path=<path>] [--force-rebuild] [--file-relative-path=<div>] [--extra-external-modules=<modules>]

Options:
    --ignore=<path>                     Ignore all Python files that are children of this path
    --metatypes-dir=<dir>               Directory of the Qt 6 metatype files for core modules (automatically detected if not provided)
    --qmltyperegistrar-path=<path>      Path of the qmltyperegistrar tool (automatically detected if not provided)
    --force-rebuild                     Rebuild the stubs from scratch instead of doing a partial update
    --file-relative-path=<div>          Make all paths in generated type files relative to this path
                                            (useful for if the generated stubs need to be used on different systems)
    --extra-external-modules=<modules>  Additional modules which should be assumed to contain QML exposed types (comma separated)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyside6-qml-stubgen",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "pyside6, qml, qt6, type checking",
    "author": "Matthew Joyce",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/3e/64/c01caf87088b79de18186146ffc9f4d9005ed9c905cd19b11e0a5e2fbe1c/pyside6_qml_stubgen-0.1.0a7.tar.gz",
    "platform": null,
    "description": "pyside6-qml-stubgen\n===================\n\nGenerate QML stub files (`.qmltypes`) from Python modules (which use PySide6)\n\nInstallation\n------------\n\nThis tool can be installed though PyPI:\n\n```bash\npip install pyside6-qml-stubgen\n```\n\nIf you want to use a development version, instead clone the repo and then install using pip:\n\n```bash\ngit clone https://github.com/matsjoyce/pyside6-qml-stubgen.git\npip install ./pyside6-qml-stubgen\n```\n\nThis tool has been tested on Linux, Windows and MacOS using pip-installed PySide6 (on GitHub Actions), and on Arch Linux using system packages. It does not run with PyQt6, although it should be possible in theory (send a PR if you get it working). And finally, it does not run using Qt 5 (PySide2 or PyQt5), as that version is no longer being developed, and QML in Qt 5 has less features than in Qt 6, making it a less attractive target for this sort of tool.\n\nSimple example\n--------------\n\nAs an example, we'll run this tool on https://github.com/matsjoyce/fantasia2. There are two steps to type checking your QML code when using PySide6. First generate the QML type stubs using this tool:\n\n```bash\npyside6-qml-stubgen fantasia2 --out-dir qmltypes --ignore fantasia2/alembic/\n```\n\nThis command will generate a folder tree containing `.qmltypes` files and `qmldir` files matching the runtime structure of QML modules registered by the Python modules.\n\nThe second step is to run `qmllint` on your QML files using the type stubs:\n\n```bash\n/usr/lib/qt6/bin/qmllint fantasia2/*.qml -I ./qmltypes\n```\n\nIf you change the QML files, you can just rerun `qmllint`. If you change the Python interface, you should rerun both commands.\n\nLinks to other projects\n-----------------------\n\nThis tool relies heavily on PySide6, and is inspired by the [`metaobjectdump.py`](https://code.qt.io/cgit/pyside/pyside-setup.git/tree/sources/pyside-tools/metaobjectdump.py) tool, although this tool uses a runtime approach instead of static analysis, as that works better on large programs.\n\nCommand-line arguments\n----------------------\n\n```bash\n$ pyside6-qml-stubgen --help\nGenerate QML stub files (.qmltypes) from Python modules (which use PySide6)\n\nUsage:\n    pyside6-qml-stubgen <in-dir>... --out-dir=<out-dir> [--ignore=<path>...] [--metatypes-dir=<dir>] [--qmltyperegistrar-path=<path>] [--force-rebuild] [--file-relative-path=<div>] [--extra-external-modules=<modules>]\n\nOptions:\n    --ignore=<path>                     Ignore all Python files that are children of this path\n    --metatypes-dir=<dir>               Directory of the Qt 6 metatype files for core modules (automatically detected if not provided)\n    --qmltyperegistrar-path=<path>      Path of the qmltyperegistrar tool (automatically detected if not provided)\n    --force-rebuild                     Rebuild the stubs from scratch instead of doing a partial update\n    --file-relative-path=<div>          Make all paths in generated type files relative to this path\n                                            (useful for if the generated stubs need to be used on different systems)\n    --extra-external-modules=<modules>  Additional modules which should be assumed to contain QML exposed types (comma separated)\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Generate QML stub files (.qmltypes) from Python modules (which use PySide6)",
    "version": "0.1.0a7",
    "project_urls": {
        "Homepage": "https://github.com/matsjoyce/pyside6-qml-stubgen",
        "Issues": "https://github.com/matsjoyce/pyside6-qml-stubgen/issues",
        "Repository": "https://github.com/matsjoyce/pyside6-qml-stubgen.git"
    },
    "split_keywords": [
        "pyside6",
        " qml",
        " qt6",
        " type checking"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "373e164ff0c33aea9993de854eca3e5e9624ee5b826c034443be9c5fcf898c2e",
                "md5": "5b79f198266167511bda0027fe5a0771",
                "sha256": "9168e22c330647f50555d43b98d42bfa1b4c791dfdaf259d3024f92d08511dcc"
            },
            "downloads": -1,
            "filename": "pyside6_qml_stubgen-0.1.0a7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5b79f198266167511bda0027fe5a0771",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 16520,
            "upload_time": "2024-10-29T17:46:54",
            "upload_time_iso_8601": "2024-10-29T17:46:54.138781Z",
            "url": "https://files.pythonhosted.org/packages/37/3e/164ff0c33aea9993de854eca3e5e9624ee5b826c034443be9c5fcf898c2e/pyside6_qml_stubgen-0.1.0a7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3e64c01caf87088b79de18186146ffc9f4d9005ed9c905cd19b11e0a5e2fbe1c",
                "md5": "a3d13a78a6bb5a390aced6a3206e8204",
                "sha256": "4d2d3e6e46f805cddf51d4cd1f1939459ab499712973b786313d589c974198d2"
            },
            "downloads": -1,
            "filename": "pyside6_qml_stubgen-0.1.0a7.tar.gz",
            "has_sig": false,
            "md5_digest": "a3d13a78a6bb5a390aced6a3206e8204",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 19822,
            "upload_time": "2024-10-29T17:46:55",
            "upload_time_iso_8601": "2024-10-29T17:46:55.392393Z",
            "url": "https://files.pythonhosted.org/packages/3e/64/c01caf87088b79de18186146ffc9f4d9005ed9c905cd19b11e0a5e2fbe1c/pyside6_qml_stubgen-0.1.0a7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-29 17:46:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "matsjoyce",
    "github_project": "pyside6-qml-stubgen",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pyside6-qml-stubgen"
}
        
Elapsed time: 0.53238s