[PATCH 09 of 10] setup: fall back to setuptools setup if distutils isn't available

Mads Kiilerich mads at kiilerich.com
Wed Jun 28 00:06:54 UTC 2023


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1687860557 -7200
#      Tue Jun 27 12:09:17 2023 +0200
# Branch stable
# Node ID 5a32d6ab784657d51dc02c9e86ad92d4efd21ee8
# Parent  7d0800b9c059349f6ad373215e718ddc7455ee91
setup: fall back to setuptools setup if distutils isn't available

The setuptools comments around this seems slightly outdated. Setuptools is
improving and distutils is being deprecated, so it should perhaps be the
default. But at least, it is a fair fallback.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -112,7 +112,10 @@ issetuptools = os.name == 'nt' or 'FORCE
 if issetuptools:
     from setuptools import setup
 else:
-    from distutils.core import setup
+    try:
+        from distutils.core import setup
+    except ModuleNotFoundError:
+        from setuptools import setup
 from distutils.ccompiler import new_compiler
 from distutils.core import Command, Extension
 from distutils.dist import Distribution



More information about the Mercurial-devel mailing list