1 # SPDX-License-Identifier: MIT
3 # Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
4 # Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 import distutils
.sysconfig
10 from distutils
.core
import setup
, Extension
12 PY_PATH_WARN_MSG
= """
13 -------------------------------------WARNING------------------------------------
14 The install directory used:\n ({})\nis not included in your PYTHONPATH.
16 To add this directory to your Python search path permanently you can add the
17 following command to your .bashrc/.zshrc:
18 export PYTHONPATH="${{PYTHONPATH}}:{}"
19 --------------------------------------------------------------------------------
22 original_get_config_vars
= distutils
.sysconfig
.get_config_vars
26 cflags
= os
.environ
.get('CFLAGS')
29 [cflags
] = original_get_config_vars('CFLAGS')
34 # distutils performs a similar transformation step on LDSHARED on
35 # darwin to use the overriden CC as the default command for LDSHARED
36 # (see distutils' customize_compiler() step in the sysconfig module).
38 # This takes it a step further by using our own LDFLAGS (when available)
39 # along with the overriden compiler and ensure that flags that are unsupported
40 # by either the Python interprter's CC or the overriden CC don't cause a
43 cc
= os
.environ
.get('CC')
44 ldflags
= os
.environ
.get('LDFLAGS')
45 [py_cc
] = original_get_config_vars('CC')
46 [py_ldshared
] = original_get_config_vars('LDSHARED')
48 if not py_ldshared
.startswith(py_cc
):
52 return '{} -shared {}'.format(cc
, ldflags
)
54 return cc
+ py_ldshared
[len(py_cc
) :]
56 return py_cc
+ py_ldshared
[len(py_cc
) :]
61 def our_get_config_vars(*args
):
62 overridden_config_vars
= {
63 'CFLAGS': get_cflags(),
64 'LDSHARED': get_ldshared(),
68 all_config_vars
= original_get_config_vars()
69 for name
in overridden_config_vars
:
70 all_config_vars
[name
] = overridden_config_vars
[name
]
71 return all_config_vars
73 subset_config_vars
= []
75 if name
not in overridden_config_vars
:
76 [var
] = original_get_config_vars(name
)
77 subset_config_vars
.append(var
)
80 subset_config_vars
.append(overridden_config_vars
[name
])
82 return subset_config_vars
85 distutils
.sysconfig
.get_config_vars
= our_get_config_vars
89 babeltrace_ext
= Extension(
91 sources
=['bt2/native_bt.c', '@srcdir@/bt2/logging.c'],
92 libraries
=['babeltrace2', 'glib-2.0'],
94 '@top_builddir@/src/autodisc/.libs/libbabeltrace2-autodisc.a',
95 '@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a',
96 '@top_builddir@/src/common/.libs/libbabeltrace2-common.a',
97 '@top_builddir@/src/py-common/.libs/libbabeltrace2-py-common.a',
98 '@top_builddir@/src/string-format/.libs/libbabeltrace2-string-format.a',
104 version
='@PACKAGE_VERSION@',
105 description
='Babeltrace 2 Python Bindings',
107 package_dir
={'bt2': 'bt2'},
109 'build': {'build_base': 'build', 'build_lib': 'build/build_lib'},
110 'build_ext': {'build_lib': 'build/build_lib'},
112 url
='https://babeltrace.org/',
113 ext_modules
=[babeltrace_ext
],
116 'Development Status :: 5 - Production/Stable',
117 'Intended Audience :: Developers',
118 'License :: OSI Approved :: The MIT License',
119 'Programming Language :: Python :: 3' 'Topic :: System :: Logging',
123 # After the installation, we check that the install directory is included in
124 # the Python search path and we print a warning message when it's not.
125 # We need to do this because Python search path differs depending on the distro
126 # and some distros don't include any /usr/local/ in the search path. This is
127 # also useful for out-of-tree installs and tests.
128 # It's only relevant to make this check on the `install` command.
130 if 'install' in dist
.command_obj
:
131 install_dir
= dist
.command_obj
['install'].install_libbase
132 if install_dir
not in sys
.path
:
133 # We can't consider this an error because if affects every
134 # distro differently. We only warn the user that some
135 # extra configuration is needed to use the bindings
136 print(PY_PATH_WARN_MSG
.format(install_dir
, install_dir
))
139 if __name__
== "__main__":
This page took 0.032562 seconds and 4 git commands to generate.