Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Port package version comparison from distutils [deprecated] to packaging #39

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Switch from `distutils` (deprecated) to `packaging`
[[PR](https://github.com/f-dangel/unfoldNd/pull/39)]

## [0.2.2] - 2024-06-14

- Switch from `pkg_resources` (deprecated) to `importlib`+`distutils`, deprecate
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ zip_safe = False
packages = find:
include_package_data = True
setup_requires =
packaging
setuptools>=38.3
setuptools_scm
# Dependencies of the project (semicolon/line-separated):
install_requires =
packaging
torch
numpy
# The usage of test_requires is discouraged, see `Dependency Management` docs
Expand Down Expand Up @@ -106,4 +109,4 @@ match = .*\.py
[darglint]
docstring_style = google
# short, long, full
strictness = short
strictness = short
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"""

import sys
from distutils.version import LooseVersion
from packaging.version import Version
from importlib.metadata import PackageNotFoundError, version

from setuptools import setup

try:
setuptools_version = LooseVersion(version("setuptools"))
required_version = LooseVersion("38.3")
setuptools_version = Version(version("setuptools"))
required_version = Version("38.3")
if setuptools_version < required_version:
print("Error: version of setuptools is too old (<38.3)!")
sys.exit(1)
Expand Down
6 changes: 3 additions & 3 deletions unfoldNd/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Shared utility functions."""

from distutils.version import LooseVersion
from packaging.version import Version
from importlib.metadata import version
from typing import Callable

Expand All @@ -15,8 +15,8 @@
)
from torch.nn.modules.utils import _pair, _single, _triple

TORCH_VERSION = LooseVersion(version("torch"))
TORCH_VERSION_AT_LEAST_1_12_0 = TORCH_VERSION >= LooseVersion("1.12.0")
TORCH_VERSION = Version(version("torch"))
TORCH_VERSION_AT_LEAST_1_12_0 = TORCH_VERSION >= Version("1.12.0")


def _get_kernel_size_numel(kernel_size):
Expand Down
Loading