From 78d55da71b8cf91c055b36f9c41d2544380c8118 Mon Sep 17 00:00:00 2001 From: Dan Bungert Date: Wed, 14 Dec 2022 09:37:50 -0700 Subject: [PATCH] setup.py: start migration away from distutils Follow guidance from PEP 632 and move some of this over to setuputils. build.build lacks a straightforward answer, use the vendored copy of distutils found in setuptools but delaying the import until after setuptools. --- setup.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 94354426..23436dcd 100644 --- a/setup.py +++ b/setup.py @@ -22,17 +22,29 @@ subiquity Ubuntu Server Installer """ -import distutils.cmd -import distutils.command.build -import distutils.spawn import glob import os +import subprocess import sys -from setuptools import setup, find_packages +from setuptools import ( + Command, + find_packages, + setup, +) + +# any remaining distutils must be imported after setuptools +# https://github.com/pypa/setuptools/issues/2591 discusses build.build and +# alternatives +import distutils.command.build -class build_i18n(distutils.cmd.Command): +def spawn(cmd): + print(' '.join(cmd)) + subprocess.run(cmd, check=True) + + +class build_i18n(Command): user_options = [] @@ -53,7 +65,7 @@ class build_i18n(distutils.cmd.Command): out_fp.write('../' + line) os.chdir('po') - distutils.spawn.spawn([ + spawn([ 'xgettext', '--directory=.', '--add-comments',