This is an automated email from the ASF dual-hosted git repository.
jmalkin pushed a commit to branch python
in repository https://gitbox.apache.org/repos/asf/datasketches-spark.git
The following commit(s) were added to refs/heads/python by this push:
new 70742f2 Remove deprecation warning for reading package resource files
70742f2 is described below
commit 70742f23f31e3e4030b6b0639a03cf11ef1b0b3b
Author: Jon <[email protected]>
AuthorDate: Thu Feb 13 23:34:24 2025 -0800
Remove deprecation warning for reading package resource files
---
python/pyproject.toml | 2 +-
python/src/datasketches_spark/_version.py | 4 ++--
python/src/datasketches_spark/common.py | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/python/pyproject.toml b/python/pyproject.toml
index beac16e..d824b6a 100644
--- a/python/pyproject.toml
+++ b/python/pyproject.toml
@@ -28,7 +28,7 @@ authors = [
]
license = { text = "Apache License 2.0" }
readme = "README.md"
-requires-python = ">=3.8"
+requires-python = ">=3.9"
dependencies = [
"pyspark",
"datasketches"
diff --git a/python/src/datasketches_spark/_version.py
b/python/src/datasketches_spark/_version.py
index 424e4d1..0a85d86 100644
--- a/python/src/datasketches_spark/_version.py
+++ b/python/src/datasketches_spark/_version.py
@@ -15,11 +15,11 @@
# specific language governing permissions and limitations
# under the License.
-import importlib.resources
+from importlib.resources import files
def get_version():
try:
- with importlib.resources.open_text('datasketches_spark', 'version.txt') as
f:
+ with (files('datasketches_spark') / 'version.txt').open('r') as f:
return f.read().strip()
except:
return '0.0.0'
diff --git a/python/src/datasketches_spark/common.py
b/python/src/datasketches_spark/common.py
index d325186..d58924c 100644
--- a/python/src/datasketches_spark/common.py
+++ b/python/src/datasketches_spark/common.py
@@ -23,7 +23,7 @@ from functools import lru_cache
from ._version import __version__
import os
-import importlib.resources
+from importlib.resources import files, as_file
ColumnOrName = Union[Column, str]
ColumnOrName_ = TypeVar("ColumnOrName_", bound=ColumnOrName)
@@ -37,7 +37,7 @@ def get_dependency_path(filename: str) -> str:
:exception FileNotFoundError: If a file is not found in the package
"""
try:
- with importlib.resources.path("datasketches_spark.deps", filename) as
file_path:
+ with as_file(files("datasketches_spark.deps") / filename) as file_path:
return str(file_path)
except FileNotFoundError:
raise FileNotFoundError(f"File {filename} not found in
datasketches_spark.deps")
@@ -51,7 +51,7 @@ def get_dependency_classpath() -> list[str]:
# we need whatever is listed in dependencies.txt as well as
# datasketches-spark_<scala_veersion>-<ds-spark_version>.jar
jar_files = []
- with importlib.resources.open_text("datasketches_spark.deps",
"dependencies.txt") as dependencies:
+ with (files("datasketches_spark.deps") / "dependencies.txt").open('r') as
dependencies:
for dep in dependencies:
jar_files.append(dep.strip())
ds_spark_version = __version__
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]