Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/neo4j/_codec/packstream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
# limitations under the License.


from ._common import Structure
from ._common import (
RUST_AVAILABLE,
Structure,
)


__all__ = [
"Structure",
"RUST_AVAILABLE",
]
2 changes: 2 additions & 0 deletions src/neo4j/_codec/packstream/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@

try:
from ._rust import Structure
RUST_AVAILABLE = True
except ImportError:
from ._python import Structure
RUST_AVAILABLE = False
14 changes: 10 additions & 4 deletions src/neo4j/_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from inspect import isclass
from warnings import warn

from ._codec.packstream import RUST_AVAILABLE


if t.TYPE_CHECKING:
_FuncT = t.TypeVar("_FuncT", bound=t.Callable)
Expand All @@ -40,13 +42,17 @@ def _compute_bolt_agent() -> t.Dict[str, str]:
def format_version_info(version_info):
return "{}.{}.{}-{}-{}".format(*version_info)

language = "Python"
if RUST_AVAILABLE:
language += "-Rust"

return {
"product": f"neo4j-python/{version}",
"platform":
f"{platform.system() or 'Unknown'} "
f"{platform.release() or 'unknown'}; "
f"{platform.machine() or 'unknown'}",
"language": f"Python/{format_version_info(sys.version_info)}",
"language": f"{language}/{format_version_info(sys.version_info)}",
"language_details":
f"{platform.python_implementation()}; "
f"{format_version_info(sys.implementation.version)} "
Expand All @@ -59,9 +65,9 @@ def format_version_info(version_info):


def _compute_user_agent() -> str:
template = "neo4j-python/{} Python/{}.{}.{}-{}-{} ({})"
fields = (version,) + tuple(sys.version_info) + (sys.platform,)
return template.format(*fields)
return (f'{BOLT_AGENT_DICT["product"]} '
f'{BOLT_AGENT_DICT["language"]} '
f'({sys.platform})')


USER_AGENT = _compute_user_agent()
Expand Down