From 01be4bd93048339f9bc8d162be03c0868ea0d6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Fri, 19 Jul 2024 17:30:31 +0200 Subject: [PATCH] DEP: refactored out runtime dependency on setuptools --- CHANGES.rst | 2 ++ astroquery/alma/core.py | 9 ++++----- .../tests/test_nasa_exoplanet_archive.py | 4 +--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2953d907f5..5f5dfe8ea5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -136,6 +136,8 @@ Infrastructure, Utility and Other Changes and Additions - Versions of PyVO <1.5 are no longer supported. [#3002] +- Dropped ``setuptools`` as a runtime dependency. [#3071] + utils.tap ^^^^^^^^^ diff --git a/astroquery/alma/core.py b/astroquery/alma/core.py index 99b060f9b5..ce9509cee8 100644 --- a/astroquery/alma/core.py +++ b/astroquery/alma/core.py @@ -8,8 +8,8 @@ import string import requests import warnings +import importlib.resources as importlib_resources -from pkg_resources import resource_filename from bs4 import BeautifulSoup import pyvo from urllib.parse import urljoin @@ -1183,10 +1183,9 @@ def cycle0_table(self): Stoehr. """ if not hasattr(self, '_cycle0_table'): - filename = resource_filename( - 'astroquery.alma', 'data/cycle0_delivery_asdm_mapping.txt') - - self._cycle0_table = Table.read(filename, format='ascii.no_header') + ref = importlib_resources.files('astroquery.alma') / 'data' / 'cycle0_delivery_asdm_mapping.txt' + with importlib_resources.as_file(ref) as path: + self._cycle0_table = Table.read(path, format='ascii.no_header') self._cycle0_table.rename_column('col1', 'ID') self._cycle0_table.rename_column('col2', 'uid') return self._cycle0_table diff --git a/astroquery/ipac/nexsci/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py b/astroquery/ipac/nexsci/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py index 4cc23e66db..273d6f4855 100644 --- a/astroquery/ipac/nexsci/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py +++ b/astroquery/ipac/nexsci/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py @@ -5,7 +5,6 @@ from urllib.parse import urlencode import astropy.units as u -import pkg_resources import pytest import requests @@ -17,8 +16,7 @@ except ImportError: pytest.skip("Install mock for the nasa_exoplanet_archive tests.", allow_module_level=True) -MAIN_DATA = pkg_resources.resource_filename("astroquery.ipac.nexsci.nasa_exoplanet_archive", "data") -TEST_DATA = pkg_resources.resource_filename(__name__, "data") +TEST_DATA = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) RESPONSE_FILE = os.path.join(TEST_DATA, "responses.json") # API accessible tables will gradually transition to TAP service