misc: replace deprecated distutils features by setuptols or stdlib (#72515)

This commit is contained in:
Benjamin Dauvergne 2022-12-15 17:34:08 +01:00
parent df10f0f640
commit 4cc772dcda
1 changed files with 14 additions and 8 deletions

View File

@ -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')