7309681b5b
Python 3.12 requires `grpcio` 1.59.0 or higher. Unfortunately, there is a regression in `grpcio` 1.58.0 through the latest version (currently 1.60.0) which causes any error returned from a Python gRPC server to be written to stderr, including UNIMPLEMENTED errors. This primarily affects Python dynamic providers, which don't have implementations for `CheckConfig` and `DiffConfig`, resulting in a traceback error being emitted to stderr when the engine calls these, which is visible to users. This `grpcio` regression has been fixed upstream, but the fix has not been released yet. We've been waiting for a 1.60.1 patch release. This has not been great for our Python users who are using Python 3.12. It's particularly bad for new Pulumi users who are using Python 3.12 and are trying to get started with Pulumi. For these users, when trying to install the `pulumi` PyPi package (i.e. via `pulumi new python`) the installation fails with an error because it is pinned to depending on an older version of `grpcio` which doesn't work on Python 3.12. This commit works around the problem by providing default implementations of `CheckConfig` and `DiffConfig` for python dynamic providers and the component provider API, so that no error is emitted to stderr when the engine calls these methods. The default implementations for these are the same behavior that the engine would use if these methods had returned UNIMPLEMENTED. I believe these are the only two methods affected by this. Other methods like `Invoke`, `Call`, `StreamInvoke`, `Construct`, `Attach`, `GetMapping`, and `GetMappings`, continue to return UNIMPLEMENTED for dynamic providers, which I think is OK; I don't believe these will be called by the engine under normal circumstances. Out of an abundance of caution, the `pulumi` package continues to depend on the pinned version of `grpcio` when installing on versions of Python less than 3.12. On Python 3.12 or greater, we now depend on `grpcio` `~=1.60.0`. 1.60.0 doesn't have the fix for the regression, but the workaround should allow things to work on Python 3.12 as before. Once 1.60.1 is released, we can look into updating the `grpcio` dependency to `~=1.60.1` for all versions of Python, and possibly revert the workarounds, if we want. Note: #14474 added a test for dynamic providers to ensure nothing is written to stderr. The test would fail if the workaround in this PR did not work as intended: https://github.com/pulumi/pulumi/pull/14474/files#diff-d92ccd283e08eadab2597825103e45cdaa96fea93324bc4d4d3b1d2b83c51b76 This PR depends on several other smaller PRs: - https://github.com/pulumi/pulumi/pull/15220 - https://github.com/pulumi/pulumi/pull/15221 - https://github.com/pulumi/pulumi/pull/15222 - https://github.com/pulumi/pulumi/pull/15223 - https://github.com/pulumi/pulumi/pull/15224 - https://github.com/pulumi/pulumi/pull/15225 - https://github.com/pulumi/pulumi/pull/15226 Fixes #14258 |
||
---|---|---|
.. | ||
cmd | ||
dist | ||
lib | ||
scripts | ||
stubs | ||
.gitignore | ||
.pylintrc | ||
Makefile | ||
README.md | ||
mypy.ini | ||
python.go | ||
python_test.go | ||
requirements.txt | ||
shim_unix.go | ||
shim_windows.go |
README.md
Pulumi Python SDK
The Pulumi Python SDK (pulumi) is the core package used when writing Pulumi programs in Python. It contains everything that you’ll need in order to interact with Pulumi resource providers and express infrastructure using Python code. Pulumi resource providers all depend on this library and express their resources in terms of the types defined in this module.
The Pulumi Python SDK requires Python version 3.7 or greater through official python installer
note: pip is required to install dependencies. If you installed Python from source, with an installer from python.org, or via Homebrew you should already have pip. If Python is installed using your OS package manager, you may have to install pip separately, see Installing pip/setuptools/wheel with Linux Package Managers. For example, on Debian/Ubuntu you must run sudo apt install python3-venv python3-pip.
Getting Started
The fastest way to get up and running is to choose from one of the following Getting Started guides: -aws -microsoft azure -google cloud -kubernetes
Pulumi Programming Model
The Pulumi programming model defines the core concepts you will use when creating infrastructure as code programs using Pulumi. Architecture & Concepts describes these concepts with examples available in Python. These concepts are made available to you in the Pulumi SDK.
The Pulumi SDK is available to Python developers as a Pip package distributed on PyPI . To learn more, refer to the Pulumi SDK Reference Guide.
The Pulumi programming model includes a core concept of Input and Output values, which are used to track how outputs of one resource flow in as inputs to another resource. This concept is important to understand when getting started with Python and Pulumi, and the [Inputs and Outputs] (https://www.pulumi.com/docs/intro/concepts/inputs-outputs/)documentation is recommended to get a feel for how to work with this core part of Pulumi in common cases.
The Pulumi Python Resource Model
Like most languages usable with Pulumi, Pulumi represents cloud resources as classes and Python programs can instantiate those classes. All classes that can be instantiated to produce actual resources derive from the pulumi.Resource class.