Remove use of pkg_resources package (#3069)

This commit is contained in:
Paul Romano 2024-07-18 11:54:06 -05:00 committed by GitHub
parent fd47df4bb2
commit 32440ad203
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 8 deletions

View file

@ -13,11 +13,10 @@ functions or objects in :mod:`openmc.lib`, for example:
"""
from ctypes import CDLL, c_bool, c_int
import importlib.resources
import os
import sys
import pkg_resources
# Determine shared-library suffix
if sys.platform == 'darwin':
@ -27,9 +26,8 @@ else:
if os.environ.get('READTHEDOCS', None) != 'True':
# Open shared library
_filename = pkg_resources.resource_filename(
__name__, f'libopenmc.{_suffix}')
_dll = CDLL(_filename)
_filename = importlib.resources.files(__name__) / f'libopenmc.{_suffix}'
_dll = CDLL(str(_filename)) # TODO: Remove str() when Python 3.12+
else:
# For documentation builds, we don't actually have the shared library
# available. Instead, we create a mock object so that when the modules

View file

@ -46,7 +46,7 @@ docs = [
"sphinxcontrib-svg2pdfconverter",
"sphinx-rtd-theme==1.0.0"
]
test = ["pytest", "pytest-cov", "colorama", "openpyxl"]
test = ["packaging", "pytest", "pytest-cov", "colorama", "openpyxl"]
vtk = ["vtk"]
[project.urls]

View file

@ -1,12 +1,12 @@
import numpy as np
import openmc
from pkg_resources import parse_version
from packaging.version import parse
import pytest
@pytest.fixture(scope='module', autouse=True)
def numpy_version_requirement():
assert parse_version(np.__version__) >= parse_version("1.14"), \
assert parse(np.__version__) >= parse("1.14"), \
"Regression tests require NumPy 1.14 or greater"