From 27366509486f207c8913ee4db7f22c9c5e6cea94 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 15 Dec 2022 17:34:08 +0100 Subject: [PATCH 1/5] misc: replace deprecated distutils features by setuptols or stdlib (#69991) --- setup.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 1a9a01983..6f72fa64a 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,22 @@ #! /usr/bin/env python3 import os +import shutil import subprocess import sys -from distutils.cmd import Command -from distutils.command.build import build as _build -from distutils.command.sdist import sdist -from distutils.errors import CompileError -from distutils.spawn import find_executable + +try: + from setuptools import Command + from setuptools.command.build import build as _build + from setuptools.errors import CompileError +except ImportError: + from distutils.cmd import Command + from distutils.command.build import build as _build + from distutils.errors import CompileError from setuptools import find_packages, setup from setuptools.command.install_lib import install_lib as _install_lib +from setuptools.command.sdist import sdist as _sdist local_cfg = None if os.path.exists('wcs/wcs_cfg.py'): @@ -55,7 +61,7 @@ class compile_scss(Command): pass def run(self): - sass_bin = find_executable('sassc') + sass_bin = shutil.which('sassc') if not sass_bin: raise CompileError('sassc is required but was not found.') @@ -85,7 +91,7 @@ class install_lib(_install_lib): _install_lib.run(self) -class eo_sdist(sdist): +class eo_sdist(_sdist): def run(self): if os.path.exists('VERSION'): os.remove('VERSION') @@ -93,7 +99,7 @@ class eo_sdist(sdist): version_file = open('VERSION', 'w') version_file.write(version) version_file.close() - sdist.run(self) + _sdist.run(self) if os.path.exists('VERSION'): os.remove('VERSION') -- 2.37.2