Skip to content

Issue importing generated crd with python 3.11 #113

@jaxxstorm

Description

@jaxxstorm

What happened?

I have previously been able to get this to work, but on python 3.11 I get the following error:

Diagnostics:
  pulumi:pulumi:Stack (varnish_crd-dev):
    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "/Users/lbriggs/src/github/jaxxstorm/pulumi-examples/python/kubernetes/varnish_crd/__main__.py", line 5, in <module>
        import crds.python.pulumi_crds as varnish
      File "/Users/lbriggs/src/github/jaxxstorm/pulumi-examples/python/kubernetes/varnish_crd/crds/python/pulumi_crds/__init__.py", line 5, in <module>
        from . import _utilities
      File "/Users/lbriggs/src/github/jaxxstorm/pulumi-examples/python/kubernetes/varnish_crd/crds/python/pulumi_crds/_utilities.py", line 94, in <module>
        _version = _get_semver_version()
                   ^^^^^^^^^^^^^^^^^^^^^
      File "/Users/lbriggs/src/github/jaxxstorm/pulumi-examples/python/kubernetes/varnish_crd/crds/python/pulumi_crds/_utilities.py", line 73, in _get_semver_version
        pep440_version_string = pkg_resources.require(root_package)[0].version
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/lbriggs/src/github/jaxxstorm/pulumi-examples/python/kubernetes/varnish_crd/venv/lib/python3.11/site-packages/pkg_resources/__init__.py", line 966, in require
        needed = self.resolve(parse_requirements(requirements))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/lbriggs/src/github/jaxxstorm/pulumi-examples/python/kubernetes/varnish_crd/venv/lib/python3.11/site-packages/pkg_resources/__init__.py", line 827, in resolve
        dist = self._resolve_dist(
               ^^^^^^^^^^^^^^^^^^^
      File "/Users/lbriggs/src/github/jaxxstorm/pulumi-examples/python/kubernetes/varnish_crd/venv/lib/python3.11/site-packages/pkg_resources/__init__.py", line 868, in _resolve_dist
        raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'crds' distribution was not found and is required by the application

Expected Behavior

I can provision a custom resource

Steps to reproduce

Download a CRD:

wget https://raw.githubusercontent.com/IBM/varnish-operator/main/varnish-operator/crds/varnishcluster.yaml

Generate the default types

crd2pulumi -p varnishcluster.yaml

Import and use:

import crds.python.pulumi_crds as varnish


varnish_cluster = varnish.caching.v1alpha1.VarnishCluster(
    "example",
    spec=varnish.caching.v1alpha1.VarnishClusterSpecArgs(
        vcl=varnish.caching.v1alpha1.VarnishClusterSpecVclArgs(
            config_map_name="example-vcl",
            entrypoint="entrypoint.vcl",
        ),
        backend=varnish.caching.v1alpha1.VarnishClusterSpecBackendArgs(
            port=8080,
        )
    )
)

Output of pulumi about

CLI
Version      3.67.0
Go Version   go1.20.4
Go Compiler  gc

Plugins
NAME        VERSION
kubernetes  3.27.1
python      3.11.3

Host
OS       darwin
Version  13.3.1
Arch     arm64

This project is written in python: executable='/opt/homebrew/bin/python3' version='3.11.3
'

Current Stack: lbrlabs58/varnish_crd/dev

Found no resources associated with dev

Found no pending operations associated with dev

Backend
Name           pulumi.com
URL            https://app.pulumi.com/lbrlabs58
User           jaxxstorm
Organizations  jaxxstorm, lbrlabs, demo

Dependencies:
NAME               VERSION
pip                23.1.2
pulumi-kubernetes  3.27.1
setuptools         67.7.2
wheel              0.40.0

Pulumi locates its logs in /var/folders/rk/2c715ngd14jc4c7d3659m7pm0000gn/T/ by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Metadata

Metadata

Assignees

Labels

area/codegenAffects quality or correctness of generated codeimpact/usabilitySomething that impacts users' ability to use the product easily and intuitivelykind/bugSome behavior is incorrect or out of specresolution/fixedThis issue was fixed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions