Skip to content

Commit

Permalink
chore: remove Python 3.8, ensure Python 3.13 is included (#1332)
Browse files Browse the repository at this point in the history
* chore: remove Python 3.8, ensure Python 3.13 is included

* Clean up fsspec.py now that Python 3.8 was dropped

* Fix support for numpy v1.x

* Use Python 3.9 for ReadTheDocs

* Fixed numpy v1 support (attempt 2)

---------

Co-authored-by: Andres Rios Tascon <[email protected]>
  • Loading branch information
jpivarski and ariostas authored Nov 7, 2024
1 parent a331467 commit 95b998b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
platform: [windows-latest, macos-latest, ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

runs-on: ${{ matrix.platform }}
timeout-minutes: 30
Expand All @@ -41,7 +41,7 @@ jobs:
run: python -c "import sys; assert '.'.join(str(s) for s in sys.version_info[:2]) == '${{ matrix.python-version }}', f'{version} incorrect!'"

- name: Install ROOT
if: matrix.python-version == 3.8 && runner.os != 'macOS' && runner.os != 'Windows'
if: matrix.python-version == 3.9 && runner.os != 'macOS' && runner.os != 'Windows'
run: |
conda env list
mamba install root
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sphinx:
build:
os: ubuntu-22.04
tools:
python: '3.8'
python: '3.9'

python:
install:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![PyPI version](https://badge.fury.io/py/uproot.svg)](https://pypi.org/project/uproot)
[![Conda-Forge](https://img.shields.io/conda/vn/conda-forge/uproot)](https://github.com/conda-forge/uproot-feedstock)
[![Python 3.8‒3.12](https://img.shields.io/badge/python-3.8%E2%80%923.12-blue)](https://www.python.org)
[![Python 3.9‒3.13](https://img.shields.io/badge/python-3.9%E2%80%923.13-blue)](https://www.python.org)
[![BSD-3 Clause License](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![Continuous integration tests](https://github.com/scikit-hep/uproot5/actions/workflows/build-test.yml/badge.svg)](https://github.com/scikit-hep/uproot5/actions)

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down Expand Up @@ -53,7 +52,7 @@ dynamic = [
license = "BSD-3-Clause"
name = "uproot"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = [
Expand Down
5 changes: 4 additions & 1 deletion src/uproot/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def ensure_numpy(array, types=(numpy.bool_, numpy.integer, numpy.floating)):
else:
try:
out = numpy.asarray(array)
except (ValueError, numpy.VisibleDeprecationWarning) as err:
except (
ValueError,
getattr(numpy, "exceptions", numpy).VisibleDeprecationWarning,
) as err:
raise TypeError("cannot be converted to a NumPy array") from err
if not issubclass(out.dtype.type, types):
raise TypeError(f"cannot be converted to a NumPy array of type {types}")
Expand Down
16 changes: 1 addition & 15 deletions src/uproot/source/fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,10 @@ def chunks(
self._num_requested_chunks += len(ranges)
self._num_requested_bytes += sum(stop - start for start, stop in ranges)

try:
# not available in python 3.8
to_thread = asyncio.to_thread
except AttributeError:
import contextvars
import functools

async def to_thread(func, /, *args, **kwargs):
loop = asyncio.get_running_loop()
ctx = contextvars.copy_context()
func_call = functools.partial(ctx.run, func, *args, **kwargs)
return await loop.run_in_executor(None, func_call)

async def async_wrapper_thread(blocking_func, *args, **kwargs):
if not callable(blocking_func):
raise TypeError("blocking_func must be callable")
# TODO: when python 3.8 is dropped, use `asyncio.to_thread` instead (also remove the try/except block above)
return await to_thread(blocking_func, *args, **kwargs)
return await asyncio.to_thread(blocking_func, *args, **kwargs)

def submit(request_ranges: list[tuple[int, int]]):
paths = [self._file_path] * len(request_ranges)
Expand Down
12 changes: 10 additions & 2 deletions src/uproot/writing/_cascadetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,20 @@ def extend(self, file, sink, data):
try:
with warnings.catch_warnings():
warnings.simplefilter(
"error", category=numpy.VisibleDeprecationWarning
"error",
category=getattr(
numpy, "exceptions", numpy
).VisibleDeprecationWarning,
)
v = numpy.array(v) # noqa: PLW2901 (overwriting v)
if v.dtype == numpy.dtype("O"):
raise Exception
except (numpy.VisibleDeprecationWarning, Exception):
except (
getattr(
numpy, "exceptions", numpy
).VisibleDeprecationWarning,
Exception,
):
try:
awkward = uproot.extras.awkward()
except ModuleNotFoundError as err:
Expand Down

0 comments on commit 95b998b

Please sign in to comment.