Skip to content

Commit

Permalink
Remove use of pkg_resources package (#3069)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano authored Jul 18, 2024
1 parent fd47df4 commit 32440ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions openmc/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
"""

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':
Expand All @@ -27,9 +26,8 @@

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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions tests/regression_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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"


Expand Down

0 comments on commit 32440ad

Please sign in to comment.