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