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

Indicate the PyPi package doesn't have a plugin #358

Merged
merged 1 commit into from
Jul 23, 2024
Merged

Conversation

justinvp
Copy link
Member

@justinvp justinvp commented Jul 20, 2024

This PR is stacked on top of #357, which should be merged first1.


Pulumi automatically determines required plugins for a program. For Python programs, it essentially does this by running python -m pip list --format json, and any packages prefixed with pulumi- or pulumi_ are assumed to have associated plugins, unless the package includes a pulumi-plugin.json file that has indicated there is no plugin via { "resource": false }.

When the GetRequiredPlugins support was originally added to the Python language host, it hardcoded that pulumi-policy did not have an associated plugin. The hardcode mainly for older versions of pulumi-policy that did not contain a pulumi-plugin.json file.

pulumi-plugin.json was actually originally named pulumiplugin.json (no dash). This file wasn't used anywhere, aside from in pulumi-policy, but the hardcod prevented it from ever being loaded in that case. It turned out that there was a bug parsing pulumiplugin.json that caused the CLI to error when that file existed in other packages. Since we were planning to expand the use of the file to other languages, and make it generated by default by SDKgen, we changed the name from pulumiplugin.json to pulumi-plugin.json to avoid breaking older CLIs with the bug (see pulumi/pulumi#8593).

After making that change, we never followed up to rename the pulumiplugin.json file in pulumi-policy to pulumi-plugin.json, largely because it didn't matter since we had the hardcode.

However, this hardcode no longer works with the latest version of pulumi-policy (v1.11.0). This version was built with a newer version of setuptools which has a behavior change where the package name in the metadata will now allow underscores, instead of having underscores replaced with dashes (pypa/setuptools#4159). This means that the package name reported from pip list is now pulumi_policy instead of pulumi-policy, which doesn't match the hardcoded list. And since there is no pulumi-plugin.json file in the package (it's still the old pulumiplugin.json name), the Pulumi Python language host thinks this package needs a plugin and tries to retrieve one that doesn't exist.

This change addresses the issue by renaming pulumiplugin.json to pulumi-plugin.json in the package.

Fixes #356

Footnotes

  1. [sdk/python] Allow editable installs without build step #357 makes it possible to actually test this, because we need a simple version like 1.0.0 rather than 1.12.0a1721429785 for the locally installed package in the test, in order for the Python language host's GetRequiredPlugins not to skip the package.

github-merge-queue bot pushed a commit to pulumi/pulumi that referenced this pull request Jul 22, 2024
In the Python language host, we hardcode that `pulumi-policy` doesn't
have an associated resource (provider) plugin, because we know it
doesn't have one.

However, this hardcode no longer works with the latest version of
`pulumi-policy` (v1.11.0) because it was built with a newer version of
`setuptools` which has a behavior change where the package name in the
metadata will now allow underscores, instead of having underscores
replaced with hyphens (pypa/setuptools#4159).
This means that the package name reported from `pip list` is now
`pulumi_policy` instead of `pulumi-policy`, which doesn't match the
hardcoded list.

Note that this change is really only to help with `pulumi-policy`
v1.11.0. Future versions of `pulumi-policy` will have a
`pulumi-plugin.json` file in the package, which properly indicates that
it doesn't have an associated plugin.

Related: pulumi/pulumi-policy#358
Part of addressing: pulumi/pulumi-policy#356
github-merge-queue bot pushed a commit to pulumi/pulumi that referenced this pull request Jul 22, 2024
In the Python language host, we hardcode that `pulumi-policy` doesn't
have an associated resource (provider) plugin, because we know it
doesn't have one.

However, this hardcode no longer works with the latest version of
`pulumi-policy` (v1.11.0) because it was built with a newer version of
`setuptools` which has a behavior change where the package name in the
metadata will now allow underscores, instead of having underscores
replaced with hyphens (pypa/setuptools#4159).
This means that the package name reported from `pip list` is now
`pulumi_policy` instead of `pulumi-policy`, which doesn't match the
hardcoded list.

Note that this change is really only to help with `pulumi-policy`
v1.11.0. Future versions of `pulumi-policy` will have a
`pulumi-plugin.json` file in the package, which properly indicates that
it doesn't have an associated plugin.

Related: pulumi/pulumi-policy#358
Part of addressing: pulumi/pulumi-policy#356
github-merge-queue bot pushed a commit to pulumi/pulumi that referenced this pull request Jul 22, 2024
In the Python language host, we hardcode that `pulumi-policy` doesn't
have an associated resource (provider) plugin, because we know it
doesn't have one.

However, this hardcode no longer works with the latest version of
`pulumi-policy` (v1.11.0) because it was built with a newer version of
`setuptools` which has a behavior change where the package name in the
metadata will now allow underscores, instead of having underscores
replaced with hyphens (pypa/setuptools#4159).
This means that the package name reported from `pip list` is now
`pulumi_policy` instead of `pulumi-policy`, which doesn't match the
hardcoded list.

Note that this change is really only to help with `pulumi-policy`
v1.11.0. Future versions of `pulumi-policy` will have a
`pulumi-plugin.json` file in the package, which properly indicates that
it doesn't have an associated plugin.

Related: pulumi/pulumi-policy#358
Part of addressing: pulumi/pulumi-policy#356
Base automatically changed from justin/localinstall to main July 22, 2024 14:56
Pulumi automatically determines required plugins for a program. For Python programs, it essentially does this by running `python -m pip list --format json`, and any packages prefixed with `pulumi-` or `pulumi_` are assumed to have associated plugins, unless the package includes a `pulumi-plugin.json` file that has indicated there is no plugin via `{ "resource": false }`.

When the `GetRequiredPlugins` support was originally added to the Python language host, it [hardcoded](https://github.com/pulumi/pulumi/blob/e6d20d26f7f64a624238f86204d862642ff27e16/sdk/python/cmd/pulumi-language-python/main.go#L428-L430) that `pulumi-policy` did not have an associated plugin. The hardcode mainly for older versions of `pulumi-policy` that did not contain a `pulumi-plugin.json` file.

`pulumi-plugin.json` was actually originally named `pulumiplugin.json` (no dash). This file wasn't  used anywhere, aside from in `pulumi-policy`, but the hardcod prevented it from ever being loaded in that case. It turned out that there was a bug parsing `pulumiplugin.json` that caused the CLI to error when that file existed in other packages. Since we were planning to expand the use of the file to other languages, and make it generated by default by SDKgen, we changed the name from `pulumiplugin.json` to `pulumi-plugin.json` to avoid breaking older CLIs with the bug (see pulumi/pulumi#8593).

After making that change, we never followed up to rename the `pulumiplugin.json` file in `pulumi-policy` to `pulumi-plugin.json`, largely because it didn't matter since we had the hardcode.

However, this hardcode no longer works with the latest version of `pulumi-policy` (v1.11.0). This version was built with a newer version of `setuptools` which has a behavior change where the package name in the metadata will now allow underscores, instead of having underscores replaced with dashes (pypa/setuptools#4159). This means that the package name reported from `pip list` is now `pulumi_policy` instead of `pulumi-policy`, which doesn't match the hardcoded list. And since there is no `pulumi-plugin.json` file in the package (it's still the old `pulumiplugin.json` name), the Pulumi Python language host thinks this package needs a plugin and tries to retrieve one that doesn't exist.

This change addresses the issue by renaming `pulumiplugin.json` to `pulumi-plugin.json` in the package.
@justinvp justinvp merged commit dd9a977 into main Jul 23, 2024
5 checks passed
@justinvp justinvp deleted the justin/pulumiplugin branch July 23, 2024 00:27
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.

Pulumi policy v1.11.0 treated as resource plugin and fails to install with python
2 participants