Commit | Line | Data |
---|---|---|
de4dee04 PP |
1 | # -*- coding: utf-8 -*- |
2 | # | |
bf261856 | 3 | # Copyright (C) 2015 - Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> |
de4dee04 PP |
4 | # |
5 | # This library is free software; you can redistribute it and/or modify it under | |
6 | # the terms of the GNU Lesser General Public License as published by the Free | |
7 | # Software Foundation; version 2.1 of the License. | |
8 | # | |
9 | # This library is distributed in the hope that it will be useful, but WITHOUT | |
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
11 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
12 | # details. | |
13 | # | |
14 | # You should have received a copy of the GNU Lesser General Public License | |
15 | # along with this library; if not, write to the Free Software Foundation, Inc., | |
16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | ||
a49a7e68 FD |
18 | import os |
19 | import sys | |
20 | ||
f8cee41d MJ |
21 | if sys.version_info < (3, 12): |
22 | from distutils.core import setup, Extension | |
23 | else: | |
24 | from setuptools import setup, Extension | |
de4dee04 | 25 | |
02f8da13 MJ |
26 | # Starting with Debian's Python 3.10, the default install scheme is |
27 | # 'posix_local' which is a Debian specific scheme based on 'posix_prefix' but | |
28 | # with an added 'local' prefix. This is the default so users doing system wide | |
29 | # manual installations of python modules end up in '/usr/local'. This | |
30 | # interferes with our autotools based install which already defaults to | |
31 | # '/usr/local' and expect a provided prefix to be used verbatim. | |
32 | # | |
33 | # Monkeypatch sysconfig to override this scheme and use 'posix_prefix' instead. | |
34 | if sys.version_info >= (3, 10): | |
35 | import sysconfig | |
36 | ||
37 | original_get_preferred_scheme = sysconfig.get_preferred_scheme | |
38 | ||
39 | def our_get_preferred_scheme(key): | |
40 | scheme = original_get_preferred_scheme(key) | |
41 | if scheme == "posix_local": | |
42 | return "posix_prefix" | |
43 | else: | |
44 | return scheme | |
45 | ||
46 | sysconfig.get_preferred_scheme = our_get_preferred_scheme | |
47 | ||
a49a7e68 FD |
48 | PY_PATH_WARN_MSG = """ |
49 | -------------------------------------WARNING------------------------------------ | |
50 | The install directory used:\n ({0})\nis not included in your PYTHONPATH. | |
51 | ||
52 | To add this directory to your Python search path permanently you can add the | |
53 | following command to your .bashrc/.zshrc: | |
54 | export PYTHONPATH="${{PYTHONPATH}}:{0}" | |
55 | -------------------------------------------------------------------------------- | |
56 | """ | |
57 | ||
58 | def main(): | |
59 | dist = setup(name='lttngust', | |
60 | version='@PACKAGE_VERSION@', | |
61 | description='LTTng-UST Python agent', | |
62 | packages=['lttngust'], | |
63 | package_dir={'lttngust': 'lttngust'}, | |
64 | options={'build': {'build_base': 'build'}}, | |
65 | url='http://lttng.org', | |
66 | license='LGPL-2.1', | |
67 | classifiers=[ | |
68 | 'Development Status :: 5 - Production/Stable', | |
69 | 'Intended Audience :: Developers', | |
70 | 'License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)', | |
71 | 'Programming Language :: Python :: 2.7', | |
72 | 'Programming Language :: Python :: 3' | |
73 | 'Topic :: System :: Logging', | |
74 | ]) | |
75 | ||
76 | # After the installation, we check that the install directory is included in | |
77 | # the Python search path and we print a warning message when it's not. We need | |
78 | # to do this because Python search path differs depending on the distro and | |
79 | # some distros don't include any `/usr/local/` (the default install prefix) in | |
80 | # the search path. This is also useful for out-of-tree installs and tests. It's | |
81 | # only relevant to make this check on the `install` command. | |
82 | ||
83 | if 'install' in dist.command_obj: | |
84 | install_dir = dist.command_obj['install'].install_libbase | |
85 | if install_dir not in sys.path: | |
86 | # We can't consider this an error because if affects every | |
87 | # distro differently. We only warn the user that some | |
88 | # extra configuration is needed to use the agent | |
89 | abs_install_dir = os.path.abspath(install_dir) | |
90 | print(PY_PATH_WARN_MSG.format(abs_install_dir)) | |
f92d03ee | 91 | |
a49a7e68 FD |
92 | if __name__ == '__main__': |
93 | main() |