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

Generated setup.py is broken #100

Closed
sebbegg opened this issue Oct 1, 2022 · 4 comments · Fixed by #143
Closed

Generated setup.py is broken #100

sebbegg opened this issue Oct 1, 2022 · 4 comments · Fixed by #143
Assignees
Labels
area/codegen Affects quality or correctness of generated code kind/bug Some behavior is incorrect or out of spec language/python resolution/fixed This issue was fixed

Comments

@sebbegg
Copy link

sebbegg commented Oct 1, 2022

What happened?

I was trying to generate traefik CRD resources:

> crd2pulumi version
v1.2.2

> crd2pulumi -p --pythonName traefik --pythonPath traefik -v 0.1.0 https://raw.githubusercontent.com/traefik/traefik/v2.9/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml

this produces the following setup.py

# coding=utf-8
# *** WARNING: this file was generated by crd2pulumi. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import errno
from setuptools import setup, find_packages
from setuptools.command.install import install
from subprocess import check_call


VERSION = "0.0.0"
PLUGIN_VERSION = "0.0.0"

class InstallPluginCommand(install):
    def run(self):
        install.run(self)
        try:
            check_call(['pulumi', 'plugin', 'install', 'resource', 'traefik', PLUGIN_VERSION])
        except OSError as error:
            if error.errno == errno.ENOENT:
                print(f"""
                There was an error installing the traefik resource provider plugin.
                It looks like `pulumi` is not installed on your system.
                Please visit https://pulumi.com/ to install the Pulumi CLI.
                You may try manually installing the plugin by running
                `pulumi plugin install resource traefik {PLUGIN_VERSION}`
                """)
            else:
                raise


def readme():
    try:
        with open('README.md', encoding='utf-8') as f:
            return f.read()
    except FileNotFoundError:
        return "traefik Pulumi Package - Development Version"


setup(name='pulumi_traefik',
      version=VERSION,
      long_description=readme(),
      long_description_content_type='text/markdown',
      cmdclass={
          'install': InstallPluginCommand,
      },
      packages=find_packages(),
      package_data={
          'pulumi_traefik': [
              'py.typed',
              'pulumi-plugin.json',
          ]
      },
      install_requires=[
          'parver>=0.2.1',
          'pulumi>=3.0.0,<4.0.0',
          'pyyaml>=5.3',
          'requests>=2.21.0,<2.22.0',
          'semver>=2.8.1'
      ],
      zip_safe=False)

There's several things apparently broken:

  • VERSION and PLUGIN_VERSION seem to be 0.0.0, irrespective of the version supplied on the command-line
  • The custom install command tries to install the traefik plugin resource provider. That seems wrong? Shouldn't this rather include an install command for the kubernetes plugin?
  • The install_requires contains requests (with a very narrow version constraint) and pyaml. Both don't seem to be used by the generated code

I would have liked to build a pip-installable package for traefik crds on our internal pip repo.
This seems possible only by handcrafting the setup.py after generation.
Is this an expected use-case or is the generated code expected to be used as "source" part of an existing project (effectively ignoring the setup.py) ?

Steps to reproduce

See above

Expected Behavior

A well-formed setup.py should be generated that can be used to build and install the package.

Actual Behavior

Packages build from setup.py will most probably fail during installation.

Output of pulumi about

No pulum involved

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).

@sebbegg sebbegg added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Oct 1, 2022
@Frassle Frassle added area/codegen Affects quality or correctness of generated code language/python and removed needs-triage Needs attention from the triage team labels Oct 4, 2022
@goolzerg
Copy link

goolzerg commented Oct 27, 2022

Same issue. I think the problem in these lines of setup.py:

class InstallPluginCommand(install):
    def run(self):
        install.run(self)
        try:
            check_call(['pulumi', 'plugin', 'install', 'resource', 'crd', PLUGIN_VERSION])

so it is trying to installl plugin which does not exists. But I'm not sure how to fix it

@goolzerg
Copy link

goolzerg commented Oct 28, 2022

During installation I get this error
image
For some reason it goes to https://get.pulumi.com/releases/plugins/ and trying to download a plugin which does not exists obviously

@blampe blampe self-assigned this Jul 2, 2024
@mjeffryes mjeffryes assigned iwahbe and rquitales and unassigned blampe and iwahbe Jul 22, 2024
@mjeffryes mjeffryes modified the milestones: 0.108, 0.107 Jul 24, 2024
@cleverguy25
Copy link

Added to epic https://github.com/pulumi/home/issues/3431

@mjeffryes mjeffryes removed this from the 0.108 milestone Aug 19, 2024
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Sep 13, 2024
@pulumi-bot
Copy link

This issue has been addressed in PR #143 and shipped in release v1.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen Affects quality or correctness of generated code kind/bug Some behavior is incorrect or out of spec language/python resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants