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

bug: File named types.py will crash pulumi install and pulumi pre on dynamically wrapped provider #2384

Open
tmeckel opened this issue Sep 1, 2024 · 1 comment
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@tmeckel
Copy link
Contributor

tmeckel commented Sep 1, 2024

What happened?

When adding a source file named types.py to a Pulumi program containing a dynamically wrapped provider, pulumi install and pulumi pre will crash

I0901 19:55:13.903801   90508 plugins.go:1865] GetPluginPath(language, python, <nil>): found on $PATH /home/vagrant/.pulumi/bin/pulumi-language-python
I0901 19:55:13.904081   90508 plugins.go:1888] GetPluginPath(language, python, <nil>): found next to current executable /home/vagrant/.pulumi/bin/pulumi-language-python
I0901 19:55:13.904135   90508 plugin.go:186] newPlugin(): Launching plugin 'python' from '/home/vagrant/.pulumi/bin/pulumi-language-python' with args: -virtualenv=.venv,-toolchain=pip,-root=/home/vagrant/code/pulumi-dynamic-wrapping-test,127.0.0.1:32955
I0901 19:55:14.005136   90508 sink.go:170] defaultSink::Infoerr(^[[0mI0901 19:55:14.004922   90513 main.go:131] language host identified executor from path: `/home/vagrant/.pulumi/bin/pulumi-language-python-exec`
^[[0m)
^[[0mI0901 19:55:14.004922   90513 main.go:131] language host identified executor from path: `/home/vagrant/.pulumi/bin/pulumi-language-python-exec`
^[[0m
I0901 19:55:14.009749   90508 langruntime_plugin.go:250] langhost[python].GetPluginInfo() executing
I0901 19:55:14.010722   90508 langruntime_plugin.go:287] langhost[python].InstallDependencies(Info=[root=/home/vagrant/code/pulumi-dynamic-wrapping-test, program=/home/vagrant/code/pulumi-dynamic-wrapping-test, entryPoint=.], UseLanguageVersionTools=false) executing
I0901 19:55:14.012075   90508 sink.go:170] defaultSink::Infoerr(^[[0mI0901 19:55:14.011973   90513 pip.go:53] Python toolchain: using pip at /home/vagrant/code/pulumi-dynamic-wrapping-test/.venv
^[[0m)
^[[0mI0901 19:55:14.011973   90513 pip.go:53] Python toolchain: using pip at /home/vagrant/code/pulumi-dynamic-wrapping-test/.venv
^[[0m
I0901 19:55:17.139247   90508 langruntime_plugin.go:322] langhost[python].InstallDependencies(Info=[root=/home/vagrant/code/pulumi-dynamic-wrapping-test, program=/home/vagrant/code/pulumi-dynamic-wrapping-test, entryPoint=.], UseLanguageVersionTools=false) failed: err=updating pip, setuptools, and wheel via '/home/vagrant/code/pulumi-dynamic-wrapping-test/.venv/bin/python -m pip install --upgrade pip setuptools wheel': exit status 1
I0901 19:55:17.169082   90508 sink.go:178] defaultSink::Error(^[[38;5;1merror: ^[[0m^[[0minstalling dependencies: updating pip, setuptools, and wheel via '/home/vagrant/code/pulumi-dynamic-wrapping-test/.venv/bin/python -m pip install --upgrade pip setuptools wheel': exit status 1^[[0m)
^[[38;5;1merror: ^[[0m^[[0minstalling dependencies: updating pip, setuptools, and wheel via '/home/vagrant/code/pulumi-dynamic-wrapping-test/.venv/bin/python -m pip install --upgrade pip setuptools wheel': exit status 1^[[0m

Example

Steps to reproduce:

  1. pulumi new python

  2. pulumi package add terraform-provider planetscale/planetscale

  3. echo sdks/planetscale >> requirements.txt

  4. vi types.py

     import pulumi_planetscale as planetscale
    
     import pulumi
     import pulumi_planetscale as planetscale
    
     db = planetscale.Database(
         resource_name="mydb",
         organization="lukehoban",
         cluster_size="PS-10"
     )
    
     pulumi.export("db_url", db.url)
  5. pulumi install

pulumi install --logtostderr --logflow -v=10 2> out.txt
Installing dependencies...

Creating virtual environment...
Finished creating virtual environment
Updating pip, setuptools, and wheel in virtual environment...
Could not import runpy module
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 15, in <module>
    import importlib.util
  File "/usr/lib/python3.10/importlib/util.py", line 14, in <module>
    from contextlib import contextmanager
  File "/usr/lib/python3.10/contextlib.py", line 6, in <module>
    from functools import wraps
  File "/usr/lib/python3.10/functools.py", line 22, in <module>
    from types import GenericAlias
  File "/home/vagrant/code/pulumi-dynamic-wrapping-test/types.py", line 1, in <module>
    import pulumi_planetscale as planetscale
ModuleNotFoundError: No module named 'pulumi_planetscale'

Output of pulumi about

CLI          
Version      3.130.0
Go Version   go1.22.6
Go Compiler  gc

Host     
OS       ubuntu
Version  22.04
Arch     x86_64

This project is written in python: executable='/home/vagrant/code/pulumi-dynamic-wrapping-test/.venv/bin/python' version='3.10.12'

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

@tmeckel tmeckel added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Sep 1, 2024
@guineveresaenger
Copy link
Contributor

Thanks for finding this, @tmeckel. We'll be looking at this soon.

@iwahbe iwahbe removed the needs-triage Needs attention from the triage team label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

3 participants