summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2022-03-25 10:17:38 +0000
committerDaniel P. Berrangé <berrange@redhat.com>2022-04-21 12:34:06 +0100
commite00e8c39c272b8675ea353e1cfd1d5393922e096 (patch)
tree995fea1569de616614896318b48f986176729c41 /setup.py
parentc230ecb483dae3d0ff4cebfeec5a9e96ef8e0e4c (diff)
downloadlibvirt-python-e00e8c39c272b8675ea353e1cfd1d5393922e096.tar.gz
setup: remove use of distutils.util.get_platform
The 'get_platform' function is used to determine the platform specific component of the build output directory containing the loadable modules and python code. There is no nice replacement for this function, but we can achieve our goal by simply scaning for the desired subdirectory, which should exist by the time 'test' runs. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/setup.py b/setup.py
index 941acf1..bfbe037 100755
--- a/setup.py
+++ b/setup.py
@@ -4,8 +4,8 @@ from distutils.core import setup, Extension, Command
from distutils.command.build_ext import build_ext
from distutils.command.build_py import build_py
from distutils.command.sdist import sdist
-from distutils.util import get_platform
+import glob
import sys
import os
import os.path
@@ -248,31 +248,40 @@ class my_test(Command):
('build-platlib=', None,
"build directory for platform-specific distributions"),
('plat-name=', 'p',
- "platform name to build for, if supported "
- "(default: %s)" % get_platform()),
+ "platform name to build for, if supported "),
]
description = "Run test suite."
+ def find_build_dir(self):
+ if self.plat_name is not None:
+ plat_specifier = ".%s-%d.%d" % (self.plat_name,
+ sys.version_info[0],
+ sys.version_info[1])
+ if hasattr(sys, 'gettotalrefcount'):
+ plat_specifier += '-pydebug'
+
+ return os.path.join(self.build_base,
+ 'lib' + plat_specifier)
+ else:
+ dirs = glob.glob(os.path.join(self.build_base,
+ "lib.*"))
+ if len(dirs) == 0:
+ print("No build directory found, run 'setup.py build'")
+ sys.exit(1)
+ if len(dirs) > 1:
+ print("Multiple build dirs found, use --plat-name option")
+ sys.exit(1)
+ return dirs[0]
+
def initialize_options(self):
self.build_base = 'build'
self.build_platlib = None
self.plat_name = None
def finalize_options(self):
- if self.plat_name is None:
- self.plat_name = get_platform()
-
- plat_specifier = ".%s-%d.%d" % (self.plat_name,
- sys.version_info[0],
- sys.version_info[1])
-
- if hasattr(sys, 'gettotalrefcount'):
- plat_specifier += '-pydebug'
-
if self.build_platlib is None:
- self.build_platlib = os.path.join(self.build_base,
- 'lib' + plat_specifier)
+ self.build_platlib = self.find_build_dir()
def find_pytest_path(self):
binaries = [