pulumi/tests/integration/python/resource_args
Justin Van Patten e9ac6f3c9c
[tests/integration] Fix `resource_args` for Python 3.12 (#15224)
In preparation for supporting Python 3.12...

This test is generating a local example library using SDKgen and then
running a program that uses it.

When running on Python 3.12, without this fix, we get an error from the
generated example library's `_utilities.py` file:

```
ModuleNotFoundError: No module named 'pkg_resources'
```

This is because `_utilities.py` depends on `pkg_resources` from
`setuptools`, but our generated provider SDKs do not specify they have a
dependency on `setuptools`. The problem on Python 3.12 is because
virtual environments created with `python -m venv` no longer include
`setuptools` in the virtual environment
(https://github.com/python/cpython/issues/95299).

This generally isn't a problem with projects created using `pulumi new`
because we will explicitly install `setuptools` in the created virtual
environment. But it is a problem in this case, because `ProgramTest` is
creating the virtual environment, and it doesn't install setuptools in
it.

To workaround, for now, include `setuptools` in the test program's
`requirements.txt`.

When we fix Python SDKgen to no longer use `pkg_resources`, we can
remove `setuptools` from the test program's `requirements.txt`
(https://github.com/pulumi/pulumi/issues/12414).

Also remove the `pulumi` dependency in `requirements.txt` as it the
currently published package can't be installed on Python 3.12 due to the
dependency on `grpcio` that doesn't work on Python 3.12. The test
installs the locally built Python SDK, so it's not needed in
`requirements.txt` anyway.

Aside: This test really should be a runtime SDKgen test, which wouldn't
have this problem because it uses the CLI's code for creating the
virtual environment, which installs `setuptools`.

Also note: While looking at this test, I cleaned up a part of the test
that was replacing `${VERSION}` in the generated library's `setup.py`,
which is no longer necessary because that's not how the version is
replaced anymore. A default placeholder version is included that will
work as-is.
2024-01-24 12:47:34 +00:00
..
.gitignore [codegen/python] Support `<Resource>Args` classes (#6525) 2021-04-02 10:09:17 -07:00
Pulumi.yaml [codegen/python] Support `<Resource>Args` classes (#6525) 2021-04-02 10:09:17 -07:00
__main__.py Refactor Mock newResource and call to accept property bag rather than individual args (#6672) 2021-04-14 19:32:18 +01:00
requirements.txt [tests/integration] Fix `resource_args` for Python 3.12 (#15224) 2024-01-24 12:47:34 +00:00
schema.json [codegen/python] Support `<Resource>Args` classes (#6525) 2021-04-02 10:09:17 -07:00