From 19eee8bfb2bd6faf7d932733942a4391fb338b2d Mon Sep 17 00:00:00 2001 From: Stephen Sadowski Date: Tue, 1 Feb 2022 15:07:12 -0600 Subject: [PATCH] fix: replace strtobool inside setup.py; including from sanic.utils is a no-go --- setup.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 42b9dd6e..dfd8d605 100644 --- a/setup.py +++ b/setup.py @@ -9,8 +9,6 @@ import sys from setuptools import find_packages, setup from setuptools.command.test import test as TestCommand -from sanic.utils import str_to_bool as strtobool - class PyTest(TestCommand): """ @@ -59,7 +57,7 @@ setup_kwargs = { "Build fast. Run fast." ), "long_description": long_description, - "packages": find_packages(), + "packages": find_packages(include=[]), "package_data": {"sanic": ["py.typed"]}, "platforms": "any", "python_requires": ">=3.7", @@ -128,6 +126,24 @@ dev_require = tests_require + [ all_require = list(set(dev_require + docs_require)) +# trying to self-refernce this from within sanic prior to install is +# problematic +def strtobool(val: str) -> bool: + """ + reimplement strtobool per PEP 632 and python 3.12 deprecation + + 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. + """ + if val.lower() in ["y", "yes", "t", "true", "on", "1"]: + return True + elif val.lower() in ["n", "no", "f", "false", "off", "0"]: + return False + else: + raise ValueError(f'String value {val} cannot be converted to bool') + + + if strtobool(os.environ.get("SANIC_NO_UJSON", "no")): print("Installing without uJSON") requirements.remove(ujson)