Welcome to mirror list, hosted at ThFree Co, Russian Federation.

python.pri « qmake - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 061d67e5658d8797dc177242e16b6dccd772ab30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Copyright 2005-2019 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file at the root of the
# Mumble source tree or at <https://www.mumble.info/LICENSE>.

# This .pri files finds a suitable Python binary on the system.
#
# It exposes the found Python binary as the 'PYTHON' qmake variable.
# This variable contains the absolute path to a working Python binary.
#
# Why do we need to do this?
#
# Some systems (for example, OpenBSD's Python port), are not
# PEP 394 (https://www.python.org/dev/peps/pep-0394/) compliant.
#
# This means that there is no 'python', 'python2' or 'python3'
# binaries in the $PATH.
#
# On those systems, we can't rely on a '#!/usr/bin/env python2'
# or similar shebang. We have to query the system for versioned
# Python binaries like "python2.7" instead.
#
# This file does that, by searching in $PATH using the 'which'
# tool.
#
# If no binary is found, an error is shown to the user.
#
# This script also supports setting a MUMBLE_PYTHON environment
# variable to specify an absolute path to a Python binary to use.
# Setting this environment variable overrides any querying.

include(qt.pri)

PYTHON = $$(MUMBLE_PYTHON)

# If the MUMBLE_PYTHON environment variable isn't set
isEmpty(PYTHON) {
	# If we're on Qt 4 on win32, or we're building from Windows, use "python"
	equals(QMAKE_HOST.os, "Windows")|equals(QMAKE_VERSION_INT_MAJOR, 4):win32 {
		PYTHON=python
	} else {
		# Determine if the 'which' tool is available. We need it
		# to determine which python binary on the system to use.
		# If 'which' isn't available, error out.
		# Calling 'which which' is intentional.
		# If which is available, it will print the path to it.
		# If it isn't available, it will not print anything.
		WHICH=$$system(which which 2>/dev/null)
		isEmpty(WHICH) {
			message("The 'which' command is not available on the system. Unable to search for Python installations. Assuming 'python'... If this is not correct, please point the MUMBLE_PYTHON environment variable at a working Python 2 or Python 3 binary.")
			PYTHON=python
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python 2>/dev/null)
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python2 2>/dev/null)
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python2.7 2>/dev/null)
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python3 2>/dev/null)
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python3.0 2>/dev/null)
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python3.1 2>/dev/null)
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python3.2 2>/dev/null)
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python3.3 2>/dev/null)
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python3.4 2>/dev/null)
		}
		isEmpty(PYTHON) {
			PYTHON=$$system(which python3.5 2>/dev/null)
		}
		isEmpty(PYTHON) {
			error("Unable to find the system's Python binary. Some scripts invoked during the Mumble build use Python. You can manually specify it via the MUMBLE_PYTHON environment variable (either 2 or 3).")
		}
	}
}