X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fsetup.py.in;h=9b4294c7e0c9712cea32350342f14fa4744b44eb;hb=927263e4ea62877af7240cfdb1514ae949dbfc2e;hp=acb645096d8b2cc80c40515cb8fe1b8ddc5b7233;hpb=afdd1f8201f579d81959ce85759dcc62fcc0a85d;p=babeltrace.git diff --git a/src/bindings/python/bt2/setup.py.in b/src/bindings/python/bt2/setup.py.in index acb64509..9b4294c7 100644 --- a/src/bindings/python/bt2/setup.py.in +++ b/src/bindings/python/bt2/setup.py.in @@ -1,31 +1,17 @@ -# The MIT License (MIT) +# SPDX-License-Identifier: MIT # -# Copyright (C) 2017 - Francis Deslauriers -# Copyright (C) 2020 - Jérémie Galarneau -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# Copyright (C) 2017 Francis Deslauriers +# Copyright (C) 2020 Jérémie Galarneau import sys import os -import distutils.sysconfig -from distutils.core import setup, Extension +if sys.version_info < (3, 12): + from distutils.core import setup, Extension + import distutils.sysconfig as sysconfig +else: + from setuptools import setup, Extension + import sysconfig PY_PATH_WARN_MSG = """ -------------------------------------WARNING------------------------------------ @@ -37,14 +23,14 @@ following command to your .bashrc/.zshrc: -------------------------------------------------------------------------------- """ -original_get_config_vars = distutils.sysconfig.get_config_vars +original_get_config_vars = sysconfig.get_config_vars def get_cflags(): - cflags = os.environ.get('CFLAGS') + cflags = os.environ.get("CFLAGS") if cflags is None: - [cflags] = original_get_config_vars('CFLAGS') + [cflags] = original_get_config_vars("CFLAGS") return cflags @@ -58,16 +44,16 @@ def get_cflags(): # by either the Python interprter's CC or the overriden CC don't cause a # build failure. def get_ldshared(): - cc = os.environ.get('CC') - ldflags = os.environ.get('LDFLAGS') - [py_cc] = original_get_config_vars('CC') - [py_ldshared] = original_get_config_vars('LDSHARED') + cc = os.environ.get("CC") + ldflags = os.environ.get("LDFLAGS") + [py_cc] = original_get_config_vars("CC") + [py_ldshared] = original_get_config_vars("LDSHARED") if not py_ldshared.startswith(py_cc): return py_ldshared if cc and ldflags: - return '{} -shared {}'.format(cc, ldflags) + return "{} -shared {}".format(cc, ldflags) elif cc: return cc + py_ldshared[len(py_cc) :] elif ldflags: @@ -78,8 +64,8 @@ def get_ldshared(): def our_get_config_vars(*args): overridden_config_vars = { - 'CFLAGS': get_cflags(), - 'LDSHARED': get_ldshared(), + "CFLAGS": get_cflags(), + "LDSHARED": get_ldshared(), } if len(args) == 0: @@ -100,41 +86,41 @@ def our_get_config_vars(*args): return subset_config_vars -distutils.sysconfig.get_config_vars = our_get_config_vars +sysconfig.get_config_vars = our_get_config_vars def main(): babeltrace_ext = Extension( - 'bt2._native_bt', - sources=['bt2/native_bt.c', '@srcdir@/bt2/logging.c'], - libraries=['babeltrace2', 'glib-2.0'], + "bt2._native_bt", + sources=["bt2/native_bt.c", "@srcdir@/bt2/logging.c"], + libraries=["babeltrace2", "glib-2.0"], extra_objects=[ - '@top_builddir@/src/autodisc/.libs/libbabeltrace2-autodisc.a', - '@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a', - '@top_builddir@/src/common/.libs/libbabeltrace2-common.a', - '@top_builddir@/src/py-common/.libs/libbabeltrace2-py-common.a', - '@top_builddir@/src/string-format/.libs/libbabeltrace2-string-format.a', + "@top_builddir@/src/autodisc/.libs/libbabeltrace2-autodisc.a", + "@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a", + "@top_builddir@/src/common/.libs/libbabeltrace2-common.a", + "@top_builddir@/src/py-common/.libs/libbabeltrace2-py-common.a", + "@top_builddir@/src/string-format/.libs/libbabeltrace2-string-format.a", ], ) dist = setup( - name='bt2', - version='@PACKAGE_VERSION@', - description='Babeltrace 2 Python Bindings', - packages=['bt2'], - package_dir={'bt2': 'bt2'}, + name="bt2", + version="@PACKAGE_VERSION@", + description="Babeltrace 2 Python Bindings", + packages=["bt2"], + package_dir={"bt2": "bt2"}, options={ - 'build': {'build_base': 'build', 'build_lib': 'build/build_lib'}, - 'build_ext': {'build_lib': 'build/build_lib'}, + "build": {"build_base": "build", "build_lib": "build/build_lib"}, + "build_ext": {"build_lib": "build/build_lib"}, }, - url='https://babeltrace.org/', + url="https://babeltrace.org/", ext_modules=[babeltrace_ext], - license='MIT', + license="MIT", classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: The MIT License', - 'Programming Language :: Python :: 3' 'Topic :: System :: Logging', + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: The MIT License", + "Programming Language :: Python :: 3" "Topic :: System :: Logging", ], ) @@ -145,8 +131,8 @@ def main(): # also useful for out-of-tree installs and tests. # It's only relevant to make this check on the `install` command. - if 'install' in dist.command_obj: - install_dir = dist.command_obj['install'].install_libbase + if "install" in dist.command_obj: + install_dir = dist.command_obj["install"].install_libbase if install_dir not in sys.path: # We can't consider this an error because if affects every # distro differently. We only warn the user that some