Skip to content

Commit

Permalink
Add Python 3.13 support (#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
robsdedude authored Oct 16, 2024
1 parent 1d07bb5 commit 1cda454
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.

## NEXT RELEASE
- Python 3.13 support added.
- Deprecated setting attributes on `Neo4jError` like `message` and `code`.
- Deprecated undocumented method `Neo4jError.hydrate`.
It's internal and should not be used by client code.
Expand Down
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ breaking API changes.

See also: https://neo4j.com/developer/kb/neo4j-supported-versions/

+ Python 3.12 supported.
+ Python 3.11 supported.
+ Python 3.13 supported (since driver version 5.26.0).
+ Python 3.12 supported (since driver version 5.14.0).
+ Python 3.11 supported (since driver version 5.3.0).
+ Python 3.10 supported.
+ Python 3.9 supported.
+ Python 3.8 supported.
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Neo4j versions supported:

Python versions supported:

* Python 3.13 (added in driver version 5.26.0)
* Python 3.12 (added in driver version 5.14.0)
* Python 3.11 (added in driver version 5.3.0)
* Python 3.10
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Database",
"Topic :: Software Development",
"Typing :: Typed",
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ tox>=4.0.0
sphinx

# needed for BenchKit
sanic>=23.12.1; python_version >= '3.8.0'
sanic>=23.12.1 ; python_version >= '3.8.0'
8 changes: 7 additions & 1 deletion src/neo4j/_async/work/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
from ..._async_compat import async_sleep
from ..._async_compat.util import AsyncUtil
from ..._conf import SessionConfig
from ..._meta import deprecated


if t.TYPE_CHECKING:
from typing_extensions import deprecated
else:
from ..._meta import deprecated

from ..._util import ContextBool
from ..._work import Query
from ...api import (
Expand Down
8 changes: 7 additions & 1 deletion src/neo4j/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@

from ._codec.hydration import BrokenHydrationObject
from ._conf import iter_items
from ._meta import deprecated


if t.TYPE_CHECKING:
from typing_extensions import deprecated
else:
from ._meta import deprecated

from ._spatial import Point
from .exceptions import BrokenRecordError
from .graph import (
Expand Down
20 changes: 14 additions & 6 deletions src/neo4j/_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,23 @@ def deprecated(message: str) -> t.Callable[[_FuncT], _FuncT]:
@deprecated("'foo' has been deprecated in favour of 'bar'")
def foo(x):
pass
"""
return _make_warning_decorator(message, deprecation_warn)
@property
@deprecated("'bar' will be internal without a replacement")
def bar(self):
return "bar"
def deprecated_property(message: str):
def decorator(f):
return property(deprecated(message)(f))
@property
def baz(self):
return self._baz
return t.cast(property, decorator)
@baz.setter
@deprecated("'baz' will be read-only in the future")
def baz(self, value):
self._baz = value
"""
return _make_warning_decorator(message, deprecation_warn)


# TODO: 6.0 - remove this class, replace usage with PreviewWarning
Expand Down
8 changes: 7 additions & 1 deletion src/neo4j/_sync/work/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
from ..._async_compat import sleep
from ..._async_compat.util import Util
from ..._conf import SessionConfig
from ..._meta import deprecated


if t.TYPE_CHECKING:
from typing_extensions import deprecated
else:
from ..._meta import deprecated

from ..._util import ContextBool
from ..._work import Query
from ...api import (
Expand Down
7 changes: 6 additions & 1 deletion src/neo4j/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
urlparse,
)

from ._meta import deprecated

if t.TYPE_CHECKING:
from typing_extensions import deprecated
else:
from ._meta import deprecated

from .exceptions import ConfigurationError


Expand Down
12 changes: 11 additions & 1 deletion src/neo4j/spatial/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

"""Spatial data types for interchange with the DBMS."""

from __future__ import annotations


__all__ = [
"CartesianPoint",
"Point",
Expand All @@ -25,10 +28,17 @@
"point_type",
]

import typing as t
from functools import wraps

from .._codec.hydration.v1 import spatial as _hydration
from .._meta import deprecated


if t.TYPE_CHECKING:
from typing_extensions import deprecated
else:
from .._meta import deprecated

from .._spatial import (
CartesianPoint,
Point,
Expand Down
25 changes: 20 additions & 5 deletions testkit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y locales && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/*
ENV LANG en_US.UTF-8
ENV LANG=en_US.UTF-8

# Using apt-get update alone in a RUN statement causes caching issues and subsequent apt-get install instructions fail.
RUN apt-get --quiet update && apt-get --quiet install -y \
Expand Down Expand Up @@ -38,11 +38,11 @@ RUN update-ca-certificates

# Install pyenv
RUN git clone https://github.com/pyenv/pyenv.git .pyenv
ENV PYENV_ROOT /.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
ENV PYENV_ROOT=/.pyenv
ENV PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"

# Setup python version
ENV PYTHON_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7
ENV PYTHON_VERSIONS="3.13 3.12 3.11 3.10 3.9 3.8 3.7"

RUN for version in $PYTHON_VERSIONS; do \
pyenv install $version; \
Expand All @@ -57,3 +57,18 @@ RUN for version in $PYTHON_VERSIONS; do \
python$version -m pip install -U pip && \
python$version -m pip install -U coverage tox; \
done

# Installing pyarrow lib until pre-built wheel for Python 3.13 exists
# https://github.com/apache/arrow/issues/43519
RUN apt update && \
apt install -y -V lsb-release cmake gcc && \
distro_name=$(lsb_release --id --short | tr 'A-Z' 'a-z') && \
code_name=$(lsb_release --codename --short) && \
wget https://apache.jfrog.io/artifactory/arrow/${distro_name}/apache-arrow-apt-source-latest-${code_name}.deb && \
apt install -y -V ./apache-arrow-apt-source-latest-${code_name}.deb && \
apt update && \
apt install -y -V libarrow-dev libarrow-dataset-dev libarrow-flight-dev libparquet-dev && \
apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV PYARROW_WITH_CUDA=off
ENV PYARROW_WITH_GANDIVA=off
ENV PYARROW_PARALLEL=8
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{37,38,39,310,311,312}-{unit,integration,performance}
envlist = py{37,38,39,310,311,312,313}-{unit,integration,performance}

[testenv]
passenv = TEST_NEO4J_*
Expand Down

0 comments on commit 1cda454

Please sign in to comment.