1 # -*- coding: utf-8 -*-
3 # SPDX-License-Identifier: LGPL-2.1-only
5 # Copyright (C) 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
10 if sys
.version_info
< (3, 12):
11 from distutils
.core
import setup
, Extension
13 from setuptools
import setup
, Extension
15 # Starting with Debian's Python 3.10, the default install scheme is
16 # 'posix_local' which is a Debian specific scheme based on 'posix_prefix' but
17 # with an added 'local' prefix. This is the default so users doing system wide
18 # manual installations of python modules end up in '/usr/local'. This
19 # interferes with our autotools based install which already defaults to
20 # '/usr/local' and expect a provided prefix to be used verbatim.
22 # Monkeypatch sysconfig to override this scheme and use 'posix_prefix' instead.
23 if sys
.version_info
>= (3, 10):
26 original_get_preferred_scheme
= sysconfig
.get_preferred_scheme
28 def our_get_preferred_scheme(key
):
29 scheme
= original_get_preferred_scheme(key
)
30 if scheme
== "posix_local":
35 sysconfig
.get_preferred_scheme
= our_get_preferred_scheme
37 PY_PATH_WARN_MSG
= """
38 -------------------------------------WARNING------------------------------------
39 The install directory used:\n ({0})\nis not included in your PYTHONPATH.
41 To add this directory to your Python search path permanently you can add the
42 following command to your .bashrc/.zshrc:
43 export PYTHONPATH="${{PYTHONPATH}}:{0}"
44 --------------------------------------------------------------------------------
48 dist
= setup(name
='lttngust',
49 version
='@PACKAGE_VERSION@',
50 description
='LTTng-UST Python agent',
51 packages
=['lttngust'],
52 package_dir
={'lttngust': 'lttngust'},
53 options
={'build': {'build_base': 'build'}},
54 url
='http://lttng.org',
57 'Development Status :: 5 - Production/Stable',
58 'Intended Audience :: Developers',
59 'License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)',
60 'Programming Language :: Python :: 2.7',
61 'Programming Language :: Python :: 3'
62 'Topic :: System :: Logging',
65 # After the installation, we check that the install directory is included in
66 # the Python search path and we print a warning message when it's not. We need
67 # to do this because Python search path differs depending on the distro and
68 # some distros don't include any `/usr/local/` (the default install prefix) in
69 # the search path. This is also useful for out-of-tree installs and tests. It's
70 # only relevant to make this check on the `install` command.
72 if 'install' in dist
.command_obj
:
73 install_dir
= dist
.command_obj
['install'].install_libbase
74 if install_dir
not in sys
.path
:
75 # We can't consider this an error because if affects every
76 # distro differently. We only warn the user that some
77 # extra configuration is needed to use the agent
78 abs_install_dir
= os
.path
.abspath(install_dir
)
79 print(PY_PATH_WARN_MSG
.format(abs_install_dir
))
81 if __name__
== '__main__':