Skip to content

Commit

Permalink
Merge pull request #1851 from dlakaplan/importlib
Browse files Browse the repository at this point in the history
WIP: move from pkg_resources -> importlib
  • Loading branch information
abhisrkckl authored Nov 4, 2024
2 parents 9b37999 + 5813090 commit c78e6ec
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 40 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ jobs:
matrix:
include:
- os: ubuntu-latest
python: '3.12'
python: '3.13'
tox_env: 'ephemeris_connection'
- os: ubuntu-latest
python: '3.12'
python: '3.13'
tox_env: 'black'
- os: ubuntu-latest
python: '3.12'
tox_env: 'py312-test-cov'
python: '3.13'
tox_env: 'py313-test-cov'
- os: ubuntu-latest
python: '3.12'
python: '3.13'
tox_env: 'notebooks'
# - os: ubuntu-latest
# python: '3.8'
Expand All @@ -42,13 +42,13 @@ jobs:
# python: '3.10'
# tox_env: 'py310-test-alldeps-cov'
- os: macos-12
python: '3.12'
tox_env: 'py312-test'
python: '3.13'
tox_env: 'py313-test'
# - os: windows-latest
# python: '3.8'
# tox_env: 'py38-test'
- os: ubuntu-latest
python: '3.8'
python: '3.9'
tox_env: 'oldestdeps'
# - os: ubuntu-latest
# python: '3.8'
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ the released changes.

## Unreleased
### Changed
* Bump oldest python to 3.9
* Change oldest dependencies: `numpy` 1.18.5 to 1.23.0; `astropy` 4.0 to 5.0.5; `scipy` 1.4.1 to 1.9.0; `matplotlib` 3.2.0 to 3.4.3
* Update CI testing to use python 3.13
### Added
### Fixed
### Removed
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ is more complicated (but not too much).
Prerequisites
-------------

PINT requires Python 3.8+ [1]_
PINT requires Python 3.9+ [1]_

Your Python must have the package installation tool pip_ installed. Also make sure your ``setuptools`` are up to date (e.g. ``pip install -U setuptools``).

Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = [
"numpy>=1.18.5",
"astropy>=4.0,!=4.0.1,!=4.0.1.post1",
"numpy>=1.23.0",
"astropy>=5.0.5",
"pyerfa",
"scipy>=1.4.1",
"scipy>=1.9.0",
"jplephem>=2.6",
"matplotlib>=3.2.0",
"matplotlib>=3.4.3",
"emcee>=3.0.1",
"corner>=2.0.1",
"uncertainties",
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
numpy>=1.18.5
astropy>=4.0,!=4.0.1,!=4.0.1.post1
numpy>=1.23.0
astropy>=5.0.5
pyerfa
scipy>=1.4.1
scipy>=1.9.0
jplephem>=2.6
matplotlib>=3.2.0
matplotlib>=3.4.3
emcee>=3.0.1
corner>=2.0.1
uncertainties
Expand Down
3 changes: 1 addition & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
attrs>=19.2
pip>=9.0.1
setuptools>=41.0
setuptools>=61.2
coverage>=4.3.4
traitlets
Sphinx==6.2.1
astropy>=4.0,!=4.0.1,!=4.0.1.post1
#astropy-helpers>=1.3
sphinx-rtd-theme==1.2.2
coveralls>=1.1
Expand Down
1 change: 0 additions & 1 deletion src/pint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import astropy.time as time
import astropy.units as u
import numpy as np
import pkg_resources
from astropy.units import si
from pathlib import Path

Expand Down
12 changes: 4 additions & 8 deletions src/pint/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Functions related to PINT configuration."""

import os
import pkg_resources
import importlib.resources

__all__ = ["datadir", "examplefile", "runtimefile"]

Expand All @@ -15,7 +15,7 @@ def datadir() -> str:
str
Directory of PINT data files
"""
return pkg_resources.resource_filename(__name__, "data/")
return os.path.join(importlib.resources.files("pint"), "data/")


def examplefile(filename: str) -> str:
Expand All @@ -35,9 +35,7 @@ def examplefile(filename: str) -> str:
This is **not** for files needed at runtime. Those are located by :func:`pint.config.runtimefile`.
This is for files needed for the example notebooks.
"""
return pkg_resources.resource_filename(
__name__, os.path.join("data/examples/", filename)
)
return os.path.join(importlib.resources.files("pint"), f"data/examples/{filename}")


def runtimefile(filename: str) -> str:
Expand All @@ -57,6 +55,4 @@ def runtimefile(filename: str) -> str:
This **is** for files needed at runtime. Files needed for the example notebooks
are found via :func:`pint.config.examplefile`.
"""
return pkg_resources.resource_filename(
__name__, os.path.join("data/runtime/", filename)
)
return os.path.join(importlib.resources.files("pint"), f"data/runtime/{filename}")
20 changes: 10 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ envlist =
codestyle
black
singletest
py{38,39,310,311,312}-test{,-alldeps,-devdeps}{,-cov}
py{38,39,310,311,312,313}-test{,-alldeps,-devdeps}{,-cov}

skip_missing_interpreters = True

Expand Down Expand Up @@ -48,8 +48,8 @@ commands =
cov: coverage xml -o {toxinidir}/coverage.xml

depends =
{py38,py39,py310,py311,py312}: clean
report: py38,py39,py310,py312
{py39,py310,py311,py312,313}: clean
report: py39,py310,py312,py313
docs: notebooks

[testenv:singletest]
Expand Down Expand Up @@ -80,13 +80,13 @@ deps =
[testenv:oldestdeps]
description =
Run tests on Python 3 with minimum supported versions of astropy, numpy
basepython = python3.8
basepython = python3.9
deps =
numpy==1.18.5
numpy==1.23.0
numdifftools==0.9.39
astropy==4.0
matplotlib==3.2.0
scipy==1.4.1
astropy==5.0.5
matplotlib==3.4.3
scipy==1.9.0
pytest
coverage
hypothesis<=6.72.0
Expand All @@ -102,7 +102,7 @@ commands =

[testenv:notebooks]
description = update the notebooks
basepython = python3.12
basepython = python3.13
deps =
traitlets
sphinx >= 2.2, != 5.1.0
Expand Down Expand Up @@ -130,7 +130,7 @@ commands = coverage erase
[testenv:docs]
changedir = {toxinidir}/docs
description = invoke sphinx-build to build the HTML docs
basepython = python3.12
basepython = python3.13
deps =
traitlets
sphinx >= 2.2, != 5.1.0
Expand Down

0 comments on commit c78e6ec

Please sign in to comment.