This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new ff401dde5034 [SPARK-48069][INFRA] Handle `PEP-632` by checking 
`ModuleNotFoundError` on `setuptools` in Python 3.12
ff401dde5034 is described below

commit ff401dde50343c9bbc1c49a0294272f2da7d01e2
Author: Dongjoon Hyun <dh...@apple.com>
AuthorDate: Tue Apr 30 23:54:06 2024 -0700

    [SPARK-48069][INFRA] Handle `PEP-632` by checking `ModuleNotFoundError` 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 <dh...@apple.com>
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
---
 dev/lint-python | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dev/lint-python b/dev/lint-python
index 8d587bd52aca..6bd843103bd7 100755
--- a/dev/lint-python
+++ b/dev/lint-python
@@ -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
     )"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to