From 82e5f9313ebc05ad5b85c42b6454bf804fa18fdf Mon Sep 17 00:00:00 2001 From: John Kerl Date: Tue, 13 Feb 2024 15:47:13 -0500 Subject: [PATCH] [python] Support Python 3.12 (#2108) * [python] Probe Python 3.12 * more * google search * 3.7 too --- .github/workflows/python-ci-minimal.yml | 3 ++- apis/python/setup.py | 1 + .../src/tiledbsoma/_general_utilities.py | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-ci-minimal.yml b/.github/workflows/python-ci-minimal.yml index 1a9ad2b8cc..0da49a76a2 100644 --- a/.github/workflows/python-ci-minimal.yml +++ b/.github/workflows/python-ci-minimal.yml @@ -22,7 +22,8 @@ jobs: fail-fast: true matrix: os: [ubuntu-22.04, macos-12] - python-version: ['3.10', '3.7'] + # Just testing this out for https://github.com/single-cell-data/TileDB-SOMA/issues/1849 + python-version: ['3.7, '3.12'] include: - os: ubuntu-22.04 cc: gcc-11 diff --git a/apis/python/setup.py b/apis/python/setup.py index e21a4f9a69..4a07e6d8b8 100644 --- a/apis/python/setup.py +++ b/apis/python/setup.py @@ -248,6 +248,7 @@ def run(self): "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], package_dir={"": "src"}, packages=setuptools.find_packages("src"), diff --git a/apis/python/src/tiledbsoma/_general_utilities.py b/apis/python/src/tiledbsoma/_general_utilities.py index 5ed168acab..ff5d8124e9 100644 --- a/apis/python/src/tiledbsoma/_general_utilities.py +++ b/apis/python/src/tiledbsoma/_general_utilities.py @@ -10,7 +10,6 @@ import sys import tiledb -from pkg_resources import DistributionNotFound, get_distribution from .pytiledbsoma import version as libtiledbsoma_version @@ -36,10 +35,20 @@ def get_implementation_version() -> str: Lifecycle: maturing """ - try: - return get_distribution("tiledbsoma").version - except DistributionNotFound: - return "unknown" + if sys.version_info < (3, 8, 0): + from pkg_resources import DistributionNotFound, get_distribution + + try: + return get_distribution("tiledbsoma").version + except DistributionNotFound: + return "unknown" + else: + import importlib.metadata + + try: + return importlib.metadata.version("tiledbsoma") + except importlib.metadata.PackageNotFoundError: + return "unknown" def get_storage_engine() -> str: