Repository: cloud-custodian/cloud-custodian

Issue:
Error running `custodian validate`: ModuleNotFoundError: No module named 'distutils'
### Describe the bug

Trying to run `custodian validate file.yml` results in a stacktrace and error:

> ModuleNotFoundError: No module named 'distutils'

Looks like Python 3.12 removed `distutils`, and according to #8394 `distutils` references should have been removed (or "vendored" but not entirely sure what this means) from the codebase, but I still get the error message with version `0.9.33.0` which was just released a few days ago.

### What did you expect to happen?

I expected `custodian` to attempt to validate the yml file.

### Cloud Provider

Amazon Web Services (AWS)

### Cloud Custodian version and dependency information

```shell
Custodian:   0.9.33
Python:      3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
Platform:   win32
Using venv:  True
Docker: False
Installed:

argcomplete==3.1.6
attrs==23.1.0
boto3==1.33.1
botocore==1.33.1
docutils==0.18.1
importlib-metadata==5.2.0
jmespath==1.0.1
jsonschema==4.20.0
jsonschema-specifications==2023.11.1
python-dateutil==2.8.2
pyyaml==6.0.1
referencing==0.31.0
rpds-py==0.13.1
s3transfer==0.8.0
six==1.16.0
tabulate==0.9.0
urllib3==1.26.18
zipp==3.17.0
```


### Policy

_No response_

### Relevant log/traceback output

```shell
custodian validate src/aws/ami.yml
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\bender\Onedrive-NoSpaces\src\Projects\Packer_Builds\WinSA-CloudCustodianPolicies\custodian\Scripts\custodian.exe\__main__.py", line 7, in <module>
  File "C:\Users\bender\OneDrive - Company Inc\src\Projects\Packer_Builds\WinSA-CloudCustodianPolicies\custodian\Lib\site-packages\c7n\cli.py", line 363, in main
    command(config)
  File "C:\Users\bender\OneDrive - Company Inc\src\Projects\Packer_Builds\WinSA-CloudCustodianPolicies\custodian\Lib\site-packages\c7n\commands.py", line 228, in validate
    load_resources(structure.get_resource_types(data))
  File "C:\Users\bender\OneDrive - Company Inc\src\Projects\Packer_Builds\WinSA-CloudCustodianPolicies\custodian\Lib\site-packages\c7n\resources\__init__.py", line 20, in load_resources
    load_providers(set(pmap))
  File "C:\Users\bender\OneDrive - Company Inc\src\Projects\Packer_Builds\WinSA-CloudCustodianPolicies\custodian\Lib\site-packages\c7n\resources\__init__.py", line 70, in load_providers
    import c7n.resources.ssm # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bender\OneDrive - Company Inc\src\Projects\Packer_Builds\WinSA-CloudCustodianPolicies\custodian\Lib\site-packages\c7n\resources\ssm.py", line 19, in <module>        
    from .ec2 import EC2
  File "C:\Users\bender\OneDrive - Company Inc\src\Projects\Packer_Builds\WinSA-CloudCustodianPolicies\custodian\Lib\site-packages\c7n\resources\ec2.py", line 10, in <module>        
    from distutils.version import LooseVersion
ModuleNotFoundError: No module named 'distutils'
```


### Extra information or context

_No response_


Discussion:
We have a separate issue tracking python 3.12 compatibility. 
Thank you, I did not realize that or that custodian is not currently compatible with 3.12. I will try an earlier version of Python for now.

Resolving patch:
diff --git a/c7n/resources/ec2.py b/c7n/resources/ec2.py
--- a/c7n/resources/ec2.py
+++ b/c7n/resources/ec2.py
@@ -7,7 +7,7 @@
 import re
 import zlib
 from typing import List
-from distutils.version import LooseVersion
+from c7n.vendored.distutils.version import LooseVersion
 
 import botocore
 from botocore.exceptions import ClientError


Test patch:
diff --git a/tools/c7n_oci/tests/test_instance_principal_auth.py b/tools/c7n_oci/tests/test_instance_principal_auth.py
--- a/tools/c7n_oci/tests/test_instance_principal_auth.py
+++ b/tools/c7n_oci/tests/test_instance_principal_auth.py
@@ -1,6 +1,6 @@
 import os
 import sys
-from distutils.util import strtobool
+from c7n.vendored.distutils.util import strtobool
 
 import oci
 import pytest