diff --git a/doc/changelog.md b/doc/changelog.md index f0acfab77..9ae63ee69 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -9,6 +9,18 @@ Jump to: ## SmartSim +### Development branch + +To be released at some future point in time + +Description + +- Update packaging dependency + +Detailed Notes + +- Fix packaging failures due to deprecated `pkg_resources`. ([SmartSim-PR598](https://github.com/CrayLabs/SmartSim/pull/598)) + ### 0.7.0 Released on 14 May, 2024 diff --git a/doc/installation_instructions/platform/olcf-summit.rst b/doc/installation_instructions/platform/olcf-summit.rst index 236d15054..7e2ba513d 100644 --- a/doc/installation_instructions/platform/olcf-summit.rst +++ b/doc/installation_instructions/platform/olcf-summit.rst @@ -6,10 +6,10 @@ Since SmartSim does not have a built PowerPC build, the build steps for an IBM system are slightly different than other systems. Luckily for us, a conda channel with all relevant packages is maintained as part -of the `OpenCE `_ initiative. Users can follow these -instructions to get a working SmartSim build with PyTorch and TensorFlow for GPU -on Summit. Note that SmartSim and SmartRedis will be downloaded to the working -directory from which these instructions are executed. +of the `OpenCE `_ +initiative. Users can follow these instructions to get a working SmartSim build +with PyTorch and TensorFlow for GPU on Summit. Note that SmartSim and SmartRedis +will be downloaded to the working directory from which these instructions are executed. Note that the available PyTorch version (1.10.2) does not match the one expected by RedisAI 1.2.7 (1.11): it is still compatible and should diff --git a/doc/tutorials/ml_training/surrogate/train_surrogate.ipynb b/doc/tutorials/ml_training/surrogate/train_surrogate.ipynb index ded9df5c6..5625b86b9 100644 --- a/doc/tutorials/ml_training/surrogate/train_surrogate.ipynb +++ b/doc/tutorials/ml_training/surrogate/train_surrogate.ipynb @@ -25,7 +25,7 @@ "\n", "The problem can be solved using a finite difference scheme. To this end, a modified version of the code\n", "written by John Burkardt will be used. Its original version is licensed under LGPL, and so is this example.\n", - "The code was downloaded from [this page](https://people.sc.fsu.edu/~jburkardt/py_src/fd2d_heat_steady/fd2d_heat_steady.html),\n", + "The code was downloaded from [this page](https://github.com/johannesgerer/jburkardt-m/tree/master/fd2d_heat_steady),\n", "which explains how the problem is discretized and solved.\n", "\n", "In the modified version of the code which will be used, a random number (between 1 and 5) of heat sources is placed.\n", diff --git a/pyproject.toml b/pyproject.toml index 91164a68b..62df92f0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ [build-system] -requires = ["setuptools", "wheel", "cmake>=3.13"] +requires = ["packaging>=24.0", "setuptools>=70.0", "wheel", "cmake>=3.13"] build-backend = "setuptools.build_meta" [tool.black] diff --git a/setup.cfg b/setup.cfg index 742386d2c..1ea8d2518 100644 --- a/setup.cfg +++ b/setup.cfg @@ -51,9 +51,6 @@ classifiers = [options] packages = find: -setup_requires = - setuptools>=39.2 - cmake>=3.13 include_package_data = True python_requires = >=3.9,<3.12 diff --git a/setup.py b/setup.py index 6e46ddef9..96f98bc2c 100644 --- a/setup.py +++ b/setup.py @@ -166,6 +166,7 @@ def has_ext_modules(_placeholder): # Define needed dependencies for the installation deps = [ + "packaging>=24.0", "psutil>=5.7.2", "coloredlogs>=10.0", "tabulate>=0.8.9", diff --git a/smartsim/_core/_install/buildenv.py b/smartsim/_core/_install/buildenv.py index e0cf5a522..edb1ff116 100644 --- a/smartsim/_core/_install/buildenv.py +++ b/smartsim/_core/_install/buildenv.py @@ -35,25 +35,8 @@ from pathlib import Path from typing import Iterable -# NOTE: This will be imported by setup.py and hence no -# smartsim related items or non-standand library -# items should be imported here. +from packaging.version import InvalidVersion, Version, parse -# TODO: pkg_resources has been deprecated by PyPA. Currently we use it for its -# packaging implementation, as we cannot assume a user will have `packaging` -# prior to `pip install` time. We really only use pkg_resources for their -# vendored version of `packaging.version.Version` so we should probably try -# to remove -# https://setuptools.pypa.io/en/latest/pkg_resources.html - -# isort: off -import pkg_resources -from pkg_resources import packaging # type: ignore - -# isort: on - -Version = packaging.version.Version -InvalidVersion = packaging.version.InvalidVersion DbEngine = t.Literal["REDIS", "KEYDB"] @@ -105,9 +88,7 @@ class Version_(str): @staticmethod def _convert_to_version( - vers: t.Union[ - str, Iterable[packaging.version.Version], packaging.version.Version - ], + vers: t.Union[str, Iterable[Version], Version], ) -> t.Any: if isinstance(vers, Version): return vers @@ -122,20 +103,20 @@ def _convert_to_version( def major(self) -> int: # Version(self).major doesn't work for all Python distributions # see https://github.com/lebedov/python-pdfbox/issues/28 - return int(pkg_resources.parse_version(self).base_version.split(".")[0]) + return int(parse(self).base_version.split(".", maxsplit=1)[0]) @property def minor(self) -> int: - return int(pkg_resources.parse_version(self).base_version.split(".")[1]) + return int(parse(self).base_version.split(".", maxsplit=2)[1]) @property def micro(self) -> int: - return int(pkg_resources.parse_version(self).base_version.split(".")[2]) + return int(parse(self).base_version.split(".", maxsplit=3)[2]) @property def patch(self) -> str: # return micro with string modifier i.e. 1.2.3+cpu -> 3+cpu - return str(pkg_resources.parse_version(self)).split(".")[2] + return str(parse(self)).split(".")[2] def __gt__(self, cmp: t.Any) -> bool: try: diff --git a/tests/install/test_buildenv.py b/tests/install/test_buildenv.py index 21b9a49b8..a3964d413 100644 --- a/tests/install/test_buildenv.py +++ b/tests/install/test_buildenv.py @@ -25,8 +25,8 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +import packaging import pytest -from pkg_resources import packaging # type: ignore from smartsim._core._install.buildenv import Version_ @@ -71,19 +71,32 @@ def test_version_equality_ne(): assert v1 != v2 - -def test_version_bad_input(): + # def test_version_bad_input(): """Test behavior when passing an invalid version string""" - v1 = Version_("abcdefg") + version = Version_("1") + assert version.major == 1 + with pytest.raises((IndexError, packaging.version.InvalidVersion)) as ex: + version.minor - # todo: fix behavior to ensure versions are valid. - assert v1 + version = Version_("2.") + with pytest.raises((IndexError, packaging.version.InvalidVersion)) as ex: + version.major + + version = Version_("3.0.") + + with pytest.raises((IndexError, packaging.version.InvalidVersion)) as ex: + version.major + + version = Version_("3.1.a") + assert version.major == 3 + assert version.minor == 1 + with pytest.raises((IndexError, packaging.version.InvalidVersion)) as ex: + version.patch def test_version_bad_parse_fail(): """Test behavior when trying to parse with an invalid input string""" - v1 = Version_("abcdefg") - # todo: ensure we can't take invalid input and have this IndexError occur. + version = Version_("abcdefg") with pytest.raises((IndexError, packaging.version.InvalidVersion)) as ex: - _ = v1.minor + version.major