-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-45390][PYTHON] Remove distutils usage
#43192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,3 +142,4 @@ empty.proto | |
| LimitedInputStream.java | ||
| TimSort.java | ||
| xml-resources/* | ||
| loose_version.py | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 | ||
| # https://github.com/python/cpython/blob/3.11/LICENSE | ||
| # File originates from the cpython source | ||
| # https://github.com/python/cpython/blob/3.11/Lib/distutils/version.py | ||
|
|
||
| import re | ||
| from typing import Optional | ||
|
|
||
|
|
||
| class LooseVersion: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this copy from
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For example,
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, it's reimplemented by squashing |
||
| component_re = re.compile(r"(\d+ | [a-z]+ | \.)", re.VERBOSE) | ||
|
|
||
| def __init__(self, vstring: Optional[str]) -> None: | ||
| if vstring: | ||
| self.parse(vstring) | ||
|
|
||
| def parse(self, vstring: str) -> None: | ||
| self.vstring = vstring | ||
| components = [x for x in self.component_re.split(vstring) if x and x != "."] | ||
| for i, obj in enumerate(components): | ||
| try: | ||
| components[i] = int(obj) | ||
| except ValueError: | ||
| pass | ||
|
|
||
| self.version = components | ||
|
|
||
| def __str__(self) -> str: | ||
| return self.vstring | ||
|
|
||
| def __repr__(self) -> str: | ||
| return "LooseVersion ('%s')" % str(self) | ||
|
|
||
| def __eq__(self, other): # type: ignore[no-untyped-def] | ||
| c = self._cmp(other) | ||
| if c is NotImplemented: | ||
| return c | ||
| return c == 0 | ||
|
|
||
| def __lt__(self, other): # type: ignore[no-untyped-def] | ||
| c = self._cmp(other) | ||
| if c is NotImplemented: | ||
| return c | ||
| return c < 0 | ||
|
|
||
| def __le__(self, other): # type: ignore[no-untyped-def] | ||
| c = self._cmp(other) | ||
| if c is NotImplemented: | ||
| return c | ||
| return c <= 0 | ||
|
|
||
| def __gt__(self, other): # type: ignore[no-untyped-def] | ||
| c = self._cmp(other) | ||
| if c is NotImplemented: | ||
| return c | ||
| return c > 0 | ||
|
|
||
| def __ge__(self, other): # type: ignore[no-untyped-def] | ||
| c = self._cmp(other) | ||
| if c is NotImplemented: | ||
| return c | ||
| return c >= 0 | ||
|
|
||
| def _cmp(self, other): # type: ignore[no-untyped-def] | ||
| if isinstance(other, str): | ||
| other = LooseVersion(other) | ||
| elif not isinstance(other, LooseVersion): | ||
| return NotImplemented | ||
|
|
||
| if self.version == other.version: | ||
| return 0 | ||
| if self.version < other.version: | ||
| return -1 | ||
| if self.version > other.version: | ||
| return 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,6 @@ | |
|
|
||
| import datetime | ||
|
|
||
| from distutils.version import LooseVersion | ||
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ | |
| # | ||
|
|
||
| import unittest | ||
| from distutils.version import LooseVersion | ||
|
|
||
| import pandas as pd | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ | |
|
|
||
| import unittest | ||
| import sys | ||
| from distutils.version import LooseVersion | ||
|
|
||
| import pandas as pd | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ | |
| # | ||
|
|
||
| import unittest | ||
| from distutils.version import LooseVersion | ||
| import numpy as np | ||
| import pandas as pd | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So actually we already have PSF License stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and no~
Yes, we had
copybutton.jsfile.But, still no. We didn't have no PSF entry in
LICENSE-binarywhich is a part of Apache Spark binary distribution. So, I added in this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about
copybutton.jsbut we need to add loose_version to binary because we hadpython/pyspark/cloudpickle.pyandpython/pyspark/join.pyin BSD 3-Clause section. So, I added it to LICENSE-binary too.