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

Replace distutils which is removed in Python3.12 #925

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
19 changes: 18 additions & 1 deletion hug/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,24 @@
import asyncio
import sys
from collections import OrderedDict, namedtuple
from distutils.util import strtobool

# Own implementation of distutils.util.strtobool
# See PEP632 for more info.
def strtobool(val) -> bool:
"""Convert a string representation of truth to True or False.

True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
val = val.lower()
if val in ("y", "yes", "t", "true", "on", "1"):
return True
elif val in ("n", "no", "f", "false", "off", "0"):
return False
else:
raise ValueError("invalid truth value %r" % (val,))

from functools import partial
from itertools import chain
from types import ModuleType
Expand Down
4 changes: 2 additions & 2 deletions hug/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import uuid as native_uuid
from decimal import Decimal
from distutils.version import LooseVersion
from packaging.version import Version

import hug._empty as empty
from hug import introspect
Expand All @@ -36,7 +36,7 @@
from marshmallow import ValidationError

MARSHMALLOW_MAJOR_VERSION = getattr(
marshmallow, "__version_info__", LooseVersion(marshmallow.__version__).version
marshmallow, "__version_info__", Version(marshmallow.__version__).release
)[0]
except ImportError:
# Just define the error that is never raised so that Python does not complain.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def list_modules(dirname):
entry_points={"console_scripts": ["hug = hug:development_runner.hug.interface.cli"]},
packages=["hug"],
requires=["falcon", "requests"],
install_requires=["falcon==2.0.0", "requests"],
install_requires=["falcon==2.0.0", "requests", "packaging"],
tests_require=["pytest", "marshmallow"],
ext_modules=ext_modules,
cmdclass=cmdclass,
Expand Down