Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure python overlays work as expected #4043

Merged
merged 1 commit into from
Mar 9, 2020
Merged

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented Mar 9, 2020

Fixes: pulumi/pulumi-terraform-bridge#119

This allows us to specify an overlays block e.g.

Overlay: &tfbridge.OverlayInfo{
	DestFiles: []string{
		"pulumi_docker/docker.py",
		"pulumi_docker/image.py",
	},
},

The overlays files are treated differently to normal module files
as they are not generated. This structure means that we will emit
the correct entries in the init.py file

Without this structure (ie. pulumi_pkgname), the generator actually
copies the file (i.e. docker.py) to the root of the Python SDK. This
is because the structure of the Python SDK has a sub-folder than that
of the NodeJS SDK

I tested this using PR pulumi/pulumi-docker#141
and this now works as expected and we can take advantage of the new
Python overlays for Docker

@stack72 stack72 self-assigned this Mar 9, 2020
Copy link
Member

@lukehoban lukehoban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't exactly follow why dropping the full path is "right" here in the general case - but if this works to unblock pulumi/pulumi-docker#141 then it is likely at least better than what we have currently.

pkg/codegen/python/gen.go Outdated Show resolved Hide resolved
Fixes: pulumi/pulumi-terraform-bridge#119

This allows us to specify an overlays block e.g.

```
Overlay: &tfbridge.OverlayInfo{
	DestFiles: []string{
		"pulumi_docker/docker.py",
		"pulumi_docker/image.py",
	},
},
```

The overlays files are treated differently to normal module files
as they are not generated. This structure means that we will emit
the correct entries in the __init__.py file

Without this structure (ie. pulumi_pkgname), the generator actually
copies the file (i.e. docker.py) to the root of the Python SDK. This
is because the structure of the Python SDK has a sub-folder than that
of the NodeJS SDK

I tested this using PR pulumi/pulumi-docker#141
and this now works as expected and we can take advantage of the new
Python overlays for Docker
@stack72 stack72 merged commit 4ec9667 into master Mar 9, 2020
@stack72 stack72 deleted the fix-pygen-overlays branch March 9, 2020 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python overlay files not importing as expected
2 participants