From 4dbe69fe44468a2a47e9a543d2924e849ee06118 Mon Sep 17 00:00:00 2001 From: Dacheng Xu Date: Mon, 3 Feb 2025 08:58:53 -0500 Subject: [PATCH] Use `importlib.resources.files` and support python 3.11 (#199) * Use `importlib.resources.files` and py3.11 * Still support py3.8/3.9 * Simplify --- .github/workflows/pypi_install.yml | 2 +- .github/workflows/pytest.yml | 2 +- .pre-commit-config.yaml | 2 +- .readthedocs.yml | 2 +- appletree/utils.py | 4 ++-- pyproject.toml | 2 ++ 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pypi_install.yml b/.github/workflows/pypi_install.yml index 5a15339..60939ae 100644 --- a/.github/workflows/pypi_install.yml +++ b/.github/workflows/pypi_install.yml @@ -17,7 +17,7 @@ jobs: - name: Setup python uses: actions/setup-python@v4.2.0 with: - python-version: '3.9' + python-version: '3.10' - name: Checkout repo uses: actions/checkout@v3 diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 4f687de..1176889 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: os: [ "ubuntu-latest" ] - python-version: [ 3.8, 3.9 ] + python-version: [ '3.10', '3.11' ] test: [ 'coveralls', 'pytest' ] steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60e572d..029badd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: args: [--safe, --line-length=100] - id: black-jupyter args: [--safe, --line-length=100] - language_version: python3.9 + language_version: python3.11 - repo: https://github.com/pycqa/docformatter rev: master diff --git a/.readthedocs.yml b/.readthedocs.yml index a178cba..775ead4 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -9,7 +9,7 @@ sphinx: build: os: ubuntu-22.04 tools: - python: "3.9" + python: "3.10" python: install: diff --git a/appletree/utils.py b/appletree/utils.py index ee37837..e04f599 100644 --- a/appletree/utils.py +++ b/appletree/utils.py @@ -2,8 +2,8 @@ import json from warnings import warn import hashlib -import importlib_resources from time import time +from importlib.resources import files as _files from jax.lib import xla_bridge import numpy as np @@ -140,7 +140,7 @@ def _get_abspath(file_name): def _package_path(sub_directory): """Get the abs path of the requested sub folder.""" - return importlib_resources.files("appletree") / sub_directory + return _files("appletree") / sub_directory @export diff --git a/pyproject.toml b/pyproject.toml index 2422e4f..cadc607 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,8 @@ classifiers = [ "Natural Language :: English", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Intended Audience :: Science/Research", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Scientific/Engineering :: Physics",