c43f1540d9dbbcd0975975d78323284515188a9b
[babeltrace.git] / bindings / python / setup.py.in
1 # The MIT License (MIT)
2 #
3 # Copyright (C) 2017 - Francis Deslauriers <francis.deslauriers@efficios.com>
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 # THE SOFTWARE.
22
23 import sys
24
25 if sys.version_info < (3, 12):
26 from distutils.core import setup, Extension
27 else:
28 from setuptools import setup, Extension
29
30 PY_PATH_WARN_MSG = """
31 -------------------------------------WARNING------------------------------------
32 The install directory used:\n ({})\nis not included in your PYTHONPATH.
33
34 To add this directory to your Python search path permanently you can add the
35 following command to your .bashrc/.zshrc:
36 export PYTHONPATH="${{PYTHONPATH}}:{}"
37 --------------------------------------------------------------------------------
38 """
39
40 def main():
41 babeltrace_ext = Extension('babeltrace/_babeltrace',
42 sources=['babeltrace/babeltrace.i','babeltrace/python-complements.c'],
43 libraries=['babeltrace', 'babeltrace-ctf'],)
44
45 dist = setup(name='babeltrace',
46 version='@PACKAGE_VERSION@',
47 description='Babeltrace Python Bindings',
48 packages=['babeltrace'],
49 package_dir={'babeltrace': 'babeltrace'},
50 options={'build':
51 {
52 'build_base': 'build',
53 'build_lib': 'build/build_lib'
54 },
55 'build_ext':
56 {
57 'build_lib': 'build/build_lib'
58 }
59 },
60 url='http://diamon.org/babeltrace',
61 ext_modules=[babeltrace_ext],
62 license='MIT',
63 classifiers=[
64 'Development Status :: 5 - Production/Stable',
65 'Intended Audience :: Developers',
66 'License :: OSI Approved :: The MIT License',
67 'Programming Language :: Python :: 3'
68 'Topic :: System :: Logging',
69 ])
70
71 # After the installation, we check that the install directory is included in
72 # the Python search path and we print a warning message when it's not.
73 # We need to do this because Python search path differs depending on the distro
74 # and some distros don't include any /usr/local/ in the search path. This is
75 # also useful for out-of-tree installs and tests.
76 # It's only relevant to make this check on the `install` command.
77
78 if 'install' in dist.command_obj:
79 install_dir = dist.command_obj['install'].install_libbase
80 if install_dir not in sys.path:
81 # We can't consider this an error because if affects every
82 # distro differently. We only warn the user that some
83 # extra configuration is needed to use the bindings
84 print(PY_PATH_WARN_MSG.format(install_dir, install_dir))
85
86 if __name__ == "__main__":
87 main()
This page took 0.030405 seconds and 4 git commands to generate.