| 1 | # -*- coding: utf-8 -*- |
| 2 | # |
| 3 | # SPDX-License-Identifier: LGPL-2.1-only |
| 4 | # |
| 5 | # Copyright (C) 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> |
| 6 | |
| 7 | import os |
| 8 | import sys |
| 9 | |
| 10 | if sys.version_info < (3, 12): |
| 11 | from distutils.core import setup, Extension |
| 12 | else: |
| 13 | from setuptools import setup, Extension |
| 14 | |
| 15 | PY_PATH_WARN_MSG = """ |
| 16 | -------------------------------------WARNING------------------------------------ |
| 17 | The install directory used:\n ({0})\nis not included in your PYTHONPATH. |
| 18 | |
| 19 | To add this directory to your Python search path permanently you can add the |
| 20 | following command to your .bashrc/.zshrc: |
| 21 | export PYTHONPATH="${{PYTHONPATH}}:{0}" |
| 22 | -------------------------------------------------------------------------------- |
| 23 | """ |
| 24 | |
| 25 | def main(): |
| 26 | dist = setup(name='lttngust', |
| 27 | version='@PACKAGE_VERSION@', |
| 28 | description='LTTng-UST Python agent', |
| 29 | packages=['lttngust'], |
| 30 | package_dir={'lttngust': 'lttngust'}, |
| 31 | options={'build': {'build_base': 'build'}}, |
| 32 | url='http://lttng.org', |
| 33 | license='LGPL-2.1', |
| 34 | classifiers=[ |
| 35 | 'Development Status :: 5 - Production/Stable', |
| 36 | 'Intended Audience :: Developers', |
| 37 | 'License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)', |
| 38 | 'Programming Language :: Python :: 2.7', |
| 39 | 'Programming Language :: Python :: 3' |
| 40 | 'Topic :: System :: Logging', |
| 41 | ]) |
| 42 | |
| 43 | # After the installation, we check that the install directory is included in |
| 44 | # the Python search path and we print a warning message when it's not. We need |
| 45 | # to do this because Python search path differs depending on the distro and |
| 46 | # some distros don't include any `/usr/local/` (the default install prefix) in |
| 47 | # the search path. This is also useful for out-of-tree installs and tests. It's |
| 48 | # only relevant to make this check on the `install` command. |
| 49 | |
| 50 | if 'install' in dist.command_obj: |
| 51 | install_dir = dist.command_obj['install'].install_libbase |
| 52 | if install_dir not in sys.path: |
| 53 | # We can't consider this an error because if affects every |
| 54 | # distro differently. We only warn the user that some |
| 55 | # extra configuration is needed to use the agent |
| 56 | abs_install_dir = os.path.abspath(install_dir) |
| 57 | print(PY_PATH_WARN_MSG.format(abs_install_dir)) |
| 58 | |
| 59 | if __name__ == '__main__': |
| 60 | main() |