Skip to content

Commit

Permalink
Replace distutils with packaging (#2137)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jirka Borovec <[email protected]>
  • Loading branch information
3 people authored Oct 4, 2023
1 parent b12a647 commit f925113
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import re
import sys
import traceback
from distutils.version import LooseVersion
from typing import List, Optional, Tuple, Union

import fire
import requests
from packaging.version import parse
from pkg_resources import parse_requirements

_REQUEST_TIMEOUT = 10
Expand Down Expand Up @@ -80,8 +80,8 @@ def set_min_torch_by_python(fpath: str = "requirements/base.txt") -> None:
with open(fpath) as fp:
reqs = parse_requirements(fp.readlines())
pkg_ver = next(p for p in reqs if p.name == "torch")
pt_ver = min([LooseVersion(v[1]) for v in pkg_ver.specs])
pt_ver = max(LooseVersion(LUT_PYTHON_TORCH[py_ver]), pt_ver)
pt_ver = min([parse(v[1]) for v in pkg_ver.specs])
pt_ver = max(parse(LUT_PYTHON_TORCH[py_ver]), pt_ver)
with open(fpath) as fp:
requires = fp.read()
requires = re.sub(r"torch>=[\d\.]+", f"torch>={pt_ver}", requires)
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Manifest syntax https://docs.python.org/2/distutils/sourcedist.html
# Manifest syntax https://packaging.python.org/en/latest/guides/using-manifest-in/
graft wheelhouse

recursive-exclude __pycache__ *.py[cod] *.orig
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# in case you want to preserve/enforce restrictions on the latest compatible version, add "strict" as an in-line comment

numpy >1.20.0
packaging >17.1
torch >=1.8.1, <=2.0.1
typing-extensions; python_version < '3.9'
lightning-utilities >=0.8.0, <0.10.0
4 changes: 2 additions & 2 deletions src/torchmetrics/utilities/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import operator
import shutil
import sys
from distutils.version import LooseVersion
from typing import Optional

from lightning_utilities.core.imports import compare_version, package_available
from packaging.version import Version, parse

_PYTHON_VERSION = ".".join(map(str, [sys.version_info.major, sys.version_info.minor, sys.version_info.micro]))
_PYTHON_LOWER_3_8 = LooseVersion(_PYTHON_VERSION) < LooseVersion("3.8")
_PYTHON_LOWER_3_8 = parse(_PYTHON_VERSION) < Version("3.8")
_TORCH_LOWER_1_12_DEV: Optional[bool] = compare_version("torch", operator.lt, "1.12.0.dev")
_TORCH_GREATER_EQUAL_1_9: Optional[bool] = compare_version("torch", operator.ge, "1.9.0")
_TORCH_GREATER_EQUAL_1_10: Optional[bool] = compare_version("torch", operator.ge, "1.10.0")
Expand Down

0 comments on commit f925113

Please sign in to comment.