Skip to content

Commit 542a5f2

Browse files
Replace distutils with setuptools and generic logging
1 parent 57d3d54 commit 542a5f2

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

setup.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616

1717
# pylint: disable-msg=missing-module-docstring
1818
import io
19+
import logging
1920
import os
2021
import sys
21-
from distutils import log
22-
from distutils.command.build import build
2322

24-
from setuptools import Extension, find_packages, setup
23+
from setuptools import (
24+
Extension,
25+
setup
26+
)
2527
from setuptools.command.build_ext import build_ext
28+
from setuptools.command.build_py import build_py
29+
2630

2731
BASE_DIR = os.path.dirname(__file__)
2832
VERSION_FILENAME = os.path.join(
@@ -32,6 +36,9 @@
3236
with open(VERSION_FILENAME, encoding="utf-8") as f:
3337
exec(f.read(), PACKAGE_INFO)
3438

39+
40+
logger = logging.getLogger(__name__)
41+
3542
def is_alpine_distro():
3643
"""Checks if current system is Alpine Linux."""
3744
if os.path.exists("/etc/alpine-release"):
@@ -64,7 +71,7 @@ def link_oboe_lib(src_lib):
6471
The src_lib parameter is the name of the library file under solarwinds_apm/extension the above mentioned symlinks will
6572
point to. If a file with the provided name does not exist, no symlinks will be created."""
6673

67-
log.info("Create links to platform specific liboboe library file")
74+
logger.info("Create links to platform specific liboboe library file")
6875
link_dst = ('liboboe-1.0.so', 'liboboe-1.0.so.0')
6976
cwd = os.getcwd()
7077
try:
@@ -75,11 +82,11 @@ def link_oboe_lib(src_lib):
7582
if os.path.exists(dst):
7683
# if the destination library files exist already, they need to be deleted, otherwise linking will fail
7784
os.remove(dst)
78-
log.info("Removed %s" % dst)
85+
logger.info("Removed %s" % dst)
7986
os.symlink(src_lib, dst)
80-
log.info("Created new link at {} to {}".format(dst, src_lib))
87+
logger.info("Created new link at {} to {}".format(dst, src_lib))
8188
except Exception as ecp:
82-
log.info("[SETUP] failed to set up links to C-extension library: {e}".format(e=ecp))
89+
logger.info("[SETUP] failed to set up links to C-extension library: {e}".format(e=ecp))
8390
finally:
8491
os.chdir(cwd)
8592

@@ -89,7 +96,7 @@ def os_supported():
8996

9097

9198
if not (python_version_supported() and os_supported()):
92-
log.warn(
99+
logger.warn(
93100
"[SETUP] This package supports only Python 3.5 and above on Linux. "
94101
"Other platform or python versions may not work as expected.")
95102

@@ -112,10 +119,10 @@ def os_supported():
112119
runtime_library_dirs=['$ORIGIN']),
113120
]
114121

115-
class CustomBuild(build):
122+
class CustomBuild(build_py):
116123
def run(self):
117124
self.run_command('build_ext')
118-
build.run(self)
125+
build_py.run(self)
119126

120127

121128
class CustomBuildExt(build_ext):
@@ -143,7 +150,7 @@ def run(self):
143150
cmdclass={
144151
'build_ext': CustomBuildExt,
145152
'build_ext_lambda': CustomBuildExtLambda,
146-
'build': CustomBuild,
153+
'build_py': CustomBuild,
147154
},
148155
version=PACKAGE_INFO["__version__"],
149156
author='SolarWinds, LLC',

0 commit comments

Comments
 (0)