From 59a9c2a069b7c20c7c07f8ab7f317daa5b07bfab Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Fri, 14 Jan 2022 14:33:29 +0000 Subject: [PATCH 1/2] setup.py: neaten version check There's no need to override the build command to execute code and catch an exception to see if the Python being ran is 3.5. Add a python_requires statement so that Pip checks the version, and check sys.version_info before running setup(). --- setup.py | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index 4b9411e..07847e6 100644 --- a/setup.py +++ b/setup.py @@ -10,28 +10,10 @@ import sys import distutils.core -from distutils.command.build import \ - build as std_build -class my_build(std_build) : - "customization of build to perform additional validation." - - def run(self) : - try : - exec \ - ( - "async def dummy() :\n" - " pass\n" - "#end dummy\n" - ) - except SyntaxError : - sys.stderr.write("This module requires Python 3.5 or later.\n") - sys.exit(-1) - #end try - super().run() - #end run - -#end my_build +if sys.version_info < (3, 5): + sys.stderr.write("This module requires Python 3.5 or later.\n") + sys.exit(-1) distutils.core.setup \ ( @@ -43,9 +25,6 @@ def run(self) : author_email = "ldo@geek-central.gen.nz", url = "https://github.com/ldo/dbussy", license = "LGPL v2.1+", + python_requires='>=3.5', py_modules = ["dbussy", "ravel"], - cmdclass = - { - "build" : my_build, - }, ) From 8853fd733d3f7a569de93a6ac8981ea0470167e2 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Fri, 14 Jan 2022 14:35:23 +0000 Subject: [PATCH 2/2] setup.py: use setuptools As per [1] distutils is now deprecated in Python 3.10, and will be entirely removed in Python 3.12. Setuptools has an almost identical API, so simply switch to that. [1] https://docs.python.org/3/whatsnew/3.10.html#distutils-deprecated Closes #52 --- setup.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 07847e6..744baa2 100644 --- a/setup.py +++ b/setup.py @@ -9,14 +9,13 @@ #- import sys -import distutils.core +import setuptools if sys.version_info < (3, 5): sys.stderr.write("This module requires Python 3.5 or later.\n") sys.exit(-1) -distutils.core.setup \ - ( +setuptools.setup( name = "DBussy", version = "1.3", description = "language bindings for libdbus, for Python 3.5 or later", @@ -27,4 +26,4 @@ license = "LGPL v2.1+", python_requires='>=3.5', py_modules = ["dbussy", "ravel"], - ) +)