Avoid deprecated distutils for docs build (#20156)

This commit is contained in:
awaelchli 2024-08-04 09:28:47 +02:00 committed by GitHub
parent e61eafa671
commit 2638d82af8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -18,13 +18,13 @@ import re
import shutil
import tempfile
import urllib.request
from distutils.version import LooseVersion
from itertools import chain
from os.path import dirname, isfile
from pathlib import Path
from typing import Any, Dict, Iterable, Iterator, List, Optional, Sequence, Tuple
from packaging.requirements import Requirement
from packaging.version import Version
REQUIREMENT_FILES = {
"pytorch": (
@ -84,7 +84,7 @@ class _RequirementWithComment(Requirement):
if unfreeze == "major":
for operator, version in specs:
if operator in ("<", "<="):
major = LooseVersion(version).version[0]
major = Version(version).major
# replace upper bound with major version increased by one
return out.replace(f"{operator}{version}", f"<{major + 1}.0")
elif unfreeze == "all":