pulumi/sdk/python/cmd
Justin Van Patten 4f2373cafd
Python: Fix determining plugins for old packages (#15576)
The Python language host determines which Pulumi plugins are required by
the program by calling out to `python -m pip list -v -format json` to
get the list of installed packages. If a package contains a
`pulumi-plugin.json` file that indicates it is for a resource plugin,
then that package is considered a Pulumi package that has an associated
plugin.

As a fallback for older packages that do not have a `pulumi-plugin.json`
file, if the package name is prefixed with `pulumi-`, it is also
considered to have an associated Pulumi plugin.

However, this fallback no longer works when using recent versions of
setuptools because of a behavior change in v69.0.3 and later of
setuptools. Previously, underscores were replaced by dashes. So `python
-m pip list --format json` would return the name of the package as:

```
{"name": "pulumi-cloudinit", "version": "1.3.0"}
```

But now with setuptools v69.0.3 and later, it returns the name as
pulumi_cloudinit (with an underscore rather than dash):

```
{"name": "pulumi_cloudinit", "version": "1.3.0"}
```

The underscore in the name is now preserved and the name is no longer
prefixed with pulumi-, so the langhost no longer considers it to have an
associated Pulumi plugin.

This commit fixes the fallback to consider packages prefixed by either
`pulumi_` or `pulumi-` to be Pulumi packages.

Fixes #15536
2024-03-04 07:23:34 +00:00
..
pulumi-language-python Python: Fix determining plugins for old packages (#15576) 2024-03-04 07:23:34 +00:00
pulumi-language-python-exec Clean up legacy Py 3.7 support (#15276) 2024-01-30 10:23:57 +00:00