Is there a way to use relative imports in Python Pulumi programs?
I know we can import other modules using an absolute reference: https://github.com/pulumi/pulumi/issues/1641#issuecomment-453263416
But that's misleading:
• When reading import, are how we supposed to determine what's internal to the pulumi program vs. what's external?
• Tools like isort believe those imports are 3rd party, so we cannot group the program's internal import together when using it
Did somebody found a workaround I missed?
The same issue also hurts when using pylint:
• It complains if there is no
__init__.py
• It complains when the source code is not in a well named python package (using snake case)
IMO those are signs that Pulumi should conform to the Python ecosystem common practices.
For those who face the same issue: my workaround is to split the actual implementation from the pulumi program.
So I end up with:
• A "library" package that contains the actual implementation (I can manage this part as an actual Python package)
• A pulumi program, that use that library package (it only import the library's entry point, so I no longer have the import issue)