Skip to content

headerToModule() is destructive when CustomWidget path is a Python . path #401

@jasonbrackman

Description

@jasonbrackman

In the following function:

def headerToModule(header):
                    """
                    Translate a header file to python module path
                    foo/bar.h => foo.bar
                    """
                    # Remove header extension
                    module = os.path.splitext(header)[0]

This will break imports if they were written in Python as the structure of the custom widget is "path.to.module"

Since the function always expects a path and a .h extension -- the above is destructive and removes the .module in my example above. Custom widgets are not possible if using Python to author the custom widget with Qt.py

Possible Fix?
Patch the Qt.py:
module = os.path.splitext(header)[0] if header.endswith(".h") else header

The issue here is that if its a python module you simply can't use '.h' as a module name. Its a gotcha with the above.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions