]> xenbits.xensource.com Git - xen.git/commitdiff
tools/python: convert setup.py to use setuptools if available
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Tue, 19 Sep 2023 06:30:27 +0000 (07:30 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 20 Sep 2023 19:53:58 +0000 (20:53 +0100)
Python distutils is deprecated and is going to be removed in Python
3.12. Add support for setuptools.

Setuptools in Python 3.11 complains:

  SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

Keep using setup.py anyway to build the C extension.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Javi Merino <javi.merino@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/pygrub/setup.py
tools/python/setup.py

index 502aa4df2dae8eb43c3c5e478ae7a508f20d897d..c9cac47eee1a5f94e6dc49e42ab3f75b5732c8ab 100644 (file)
@@ -1,5 +1,8 @@
-from distutils.core import setup, Extension
-from distutils.ccompiler import new_compiler
+# Prefer setuptools, fall back to distutils
+try:
+    from setuptools import setup, Extension
+except ImportError:
+    from distutils.core import setup, Extension
 import os
 import sys
 
index 721a3141d7b75137f34b00fb1f6fbd87ecbbe734..02354f698653e6fe46f027c4f31464022a7cb427 100644 (file)
@@ -1,5 +1,8 @@
-
-from distutils.core import setup, Extension
+# Prefer setuptools, fall back to distutils
+try:
+    from setuptools import setup, Extension
+except ImportError:
+    from distutils.core import setup, Extension
 import os, sys
 
 XEN_ROOT = "../.."