hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.88k stars 455 forks source link

Python: Use PEP-420 package namespaces #3773

Open kedare opened 3 days ago

kedare commented 3 days ago

Description

Today, the way module are exposed to python is not really ergonomic as 1 root module is created for each terraform provider:

from cdktf_cdktf_provider_docker.image import Image
from cdktf_cdktf_provider_docker.container import Container
from cdktf_cdktf_provider_docker.provider import DockerProvider

Python is (one of the?) only implementation to have it implemented like this.

It would be interesting to migrate (or at least make it compatible with a non breaking way) with native package namespaces to allow a more natural naming

This would allow for example to have this kind of more natural and flexible imports

from cdktf.cdktf.provider.docker.image import Image
from cdktf.cdktf.provider.docker.container import Container
from cdktf.cdktf.provider.docker.provider import DockerProvider

References

https://packaging.python.org/en/latest/guides/packaging-namespace-packages

https://peps.python.org/pep-0420/

Help Wanted

Community Note