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

[sdkgen/python] Use importlib.metadata instead of pkg_resources #15266

Merged
merged 5 commits into from Jan 27, 2024

Conversation

justinvp
Copy link
Member

This addresses two issues:

  1. pkg_resource is deprecated in favor of importlib.resources and importlib.metadata (https://setuptools.pypa.io/en/latest/pkg_resources.html)

  2. Generated provider SDKs don't indicate that they have a dependency on setuptools (which includes pkg_resources), which can cause problems when installing the package in environments that don't have setuptools installed. That's not often common in Pulumi projects, as the virtual environment created by the CLI will include setuptools, however, if creating the virtual environment manually with python -m venv, setuptools is no longer included in the created virtual environment as of Python 3.12.

Fixes #12414

Based on #14002, thanks @edgarrmondragon!

@pulumi-bot
Copy link
Contributor

Changelog

[uncommitted] (2024-01-26)

Bug Fixes

  • [sdkgen/python] Use importlib.metadata instead of pkg_resources
    #15266

@justinvp justinvp requested a review from a team January 26, 2024 01:36
pkg/codegen/python/gen_test.go Outdated Show resolved Hide resolved
edgarrmondragon and others added 5 commits January 26, 2024 06:49
This addresses two issues:

1. `pkg_resource` is deprecated in favor of `importlib.resources` and
   `importlib.metadata`
   (https://setuptools.pypa.io/en/latest/pkg_resources.html)

2. Generated provider SDKs don't indicate that they have a dependency on
   `setuptools` (which includes `pkg_resources`), which can cause problems when
   installing the package in environments that don't have `setuptools`
   installed. That's not often common in Pulumi projects, as the virtual
   environment created by the CLI will include `setuptools`, however, if
   creating the virtual environment manually with `python -m venv`, `setuptools`
   is no longer included in the created virtual environment as of Python 3.12.
Co-authored-by: Fraser Waters <fraser@pulumi.com>
@justinvp justinvp added this pull request to the merge queue Jan 26, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 26, 2024
@justinvp justinvp added this pull request to the merge queue Jan 26, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 26, 2024
@justinvp justinvp added this pull request to the merge queue Jan 27, 2024
Merged via the queue into master with commit 87b611b Jan 27, 2024
58 checks passed
@justinvp justinvp deleted the justin/importlib branch January 27, 2024 03:22
@justinvp justinvp mentioned this pull request Jan 31, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jan 31, 2024
### Features

- [backend] Allows the PULUMI_SKIP_CHECKPOINTS environment variable to
be set without requiring the PULUMI_EXPERIMENTAL flag.
  [#15318](#15318)

- [auto/go] Add new API to install the Pulumi CLI from the Automation
API
  [#15049](#15049)

- [auto/nodejs] Allow disabling version validation when using a custom
PulumiCommand instance
  [#15242](#15242)

- [auto/python] Add new API to install the Pulumi CLI
  [#15204](#15204)

- [auto/python] Inline programs can now be defined as async functions.
  [#15278](#15278)

- [pkg/testing] Add RequireEmptyPreviewAfterRefresh option to
ProgramTest


### Bug Fixes

- [engine] Fix a hang in preview --import-file.
  [#15203](#15203)

- [engine] Engine will now error if aliases request a parent with no
URN.
  [#15232](#15232)

- [engine] Fix stack name validation when PULUMI_DISABLE_VALIDATION
isn't set.
  [#15245](#15245)

- [engine] Fix a performance issue doing unneeded secret encryption.
  [#15306](#15306)

- [sdk/go] Include error message in local workspace validation.
  [#15279](#15279)

- [sdkgen/go] Remove pulumix references from generated enums
  [#15280](#15280)

- [programgen/nodejs] Fixes generated expression for filebase64 function
to use fs.readFileSync directly with base64 encoding option
  [#15253](#15253)

- [sdkgen/python] Use importlib.metadata instead of pkg_resources
  [#15266](#15266)


### Miscellaneous

- [auto/go] Remove obsolete note from FullyQualifiedStackName comment.
  [#15281](#15281)

- [backend/filestate] Upgrade gocloud.dev to the latest version
  [#15202](#15202)

- [sdk/python] Remove compatability code for Python 3.7 and below.
  [#15276](#15276)
blampe added a commit to pulumi/ci-mgmt that referenced this pull request Jan 31, 2024
We need to regenerate SDKs with
pulumi/pulumi#15266 before we can upgrade to the
latest 3.x. 3.11 should be the last version that included pkg_resources.

Tests:
* [x] pulumi/pulumi-docker#973
* [x] pulumi/pulumi-aws-native#1305
* [ ] pulumi/pulumi-aws#3365
* [x] pulumi/pulumi-kubernetes#2802

Closes #800

---------

Co-authored-by: Bryce Lampe <bryce@pulumi.com>
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_aws python package doesn't specify requirement on setuptools / pkg_resources
4 participants