Skip to content

Commit

Permalink
[SPARK-48069][INFRA] Handle PEP-632 by checking `ModuleNotFoundErro…
Browse files Browse the repository at this point in the history
…r` on `setuptools` in Python 3.12

### What changes were proposed in this pull request?

This PR aims to handle `PEP-632` by checking `ModuleNotFoundError` on `setuptools`.
- [PEP 632 – Deprecate distutils module](https://peps.python.org/pep-0632/)

### Why are the changes needed?

Use `Python 3.12`.
```
$ python3 --version
Python 3.12.2
```

**BEFORE**
```
$ dev/lint-python --mypy | grep ModuleNotFoundError
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'
```

**AFTER**
```
$ dev/lint-python --mypy | grep ModuleNotFoundError
```

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass the CIs and manual test.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #46315 from dongjoon-hyun/SPARK-48069.

Authored-by: Dongjoon Hyun <dhyun@apple.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
  • Loading branch information
dongjoon-hyun committed May 1, 2024
1 parent 65cf5b1 commit ff401dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dev/lint-python
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ function satisfies_min_version {
local expected_version="$2"
echo "$(
"$PYTHON_EXECUTABLE" << EOM
from setuptools.extern.packaging import version
try:
from setuptools.extern.packaging import version
except ModuleNotFoundError:
from packaging import version
print(version.parse('$provided_version') >= version.parse('$expected_version'))
EOM
)"
Expand Down

0 comments on commit ff401dd

Please sign in to comment.