/usr/lib/python3/dist-packages/stsci/distutils/tests/util.py is in python3-stsci.distutils 0.3.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | import contextlib
import os
import shutil
import stat
try:
reload = reload
except NameError:
from imp import reload
from configparser import ConfigParser
from distutils.ccompiler import new_compiler
from distutils.msvccompiler import MSVCCompiler
from distutils.sysconfig import customize_compiler
@contextlib.contextmanager
def open_config(filename):
cfg = ConfigParser()
cfg.read(filename)
yield cfg
with open(filename, 'w') as fp:
cfg.write(fp)
def get_compiler_command():
"""
Returns the name of the executable used by the default compiler on the
system used by distutils to build C extensions.
"""
compiler = new_compiler()
customize_compiler(compiler)
if isinstance(compiler, MSVCCompiler):
compiler.initialize()
# Normally the compiler path will be quoted as it contains spaces
return '"%s"' % compiler.cc
return compiler.compiler[0]
def rmtree(path):
"""
shutil.rmtree() with error handler for 'access denied' from trying to
delete read-only files.
"""
def onerror(func, path, exc_info):
if not os.access(path, os.W_OK):
os.chmod(path, stat.S_IWUSR)
func(path)
else:
raise
return shutil.rmtree(path, onerror=onerror)
|