forked from MeVisLab/pythonqt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.prf
More file actions
97 lines (83 loc) · 3.45 KB
/
python.prf
File metadata and controls
97 lines (83 loc) · 3.45 KB
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
88
89
90
91
92
93
94
95
96
97
# profile to include and link Python
# Change this variable to your python version (3.7, 3.8, ...)
isEmpty( PYTHON_VERSION ) {
PYTHON_VERSION=$$(PYTHON_VERSION)
}
isEmpty( PYTHON_VERSION ) {
PYTHON_VERSION=3.10
}
isEmpty( PYTHON_DIR ) {
PYTHON_DIR=$$(PYTHON_DIR)
}
!isEmpty( PYTHON_DIR ) {
PYTHON_DIR=$${PYTHON_DIR}/
}
PYTHON_VERSION_MAJOR=$$section(PYTHON_VERSION, ., 0, 0)
PYTHON_VERSION_MINOR=$$section(PYTHON_VERSION, ., 1, 1)
!equals(PYTHON_VERSION, $${PYTHON_VERSION_MAJOR}.$${PYTHON_VERSION_MINOR}) {
error("Failed to parse PYTHON_VERSION:\"$$PYTHON_VERSION\"")
} else {
message(Using Python version $${PYTHON_VERSION})
}
# Python 3.x is required
equals(PYTHON_VERSION_MAJOR, 2) {
error("Python >= 3.x is required")
}
contains(PKGCONFIG, "python.*"){
# If `pkg-config` is configured, use `qmake PKGCONFIG+=python3.10-embed CONFIG+=...`
# or `PKGCONFIG+=python2.7m`-like form for older versions,
# see `pkg-config --list-all | grep python` for details.
# This can help with GNU/Linux (including macOS with Homebrew), MSYS2/MinGW environment,
# and also with OpenEmbedded and other cross-builds
CONFIG += link_pkgconfig
PYTHON_PKGCONFIG = $$member($$unique($$find(PKGCONFIG, "python.*")), 1, 1)
# add rpath
PYTHON_LIBDIR = $$system($$pkgConfigExecutable() --libs-only-L $$PYTHON_PKGCONFIG)
QMAKE_RPATHDIR += $$replace(PYTHON_LIBDIR,-L,)
} else:macx:isEmpty(PYTHON_DIR){
# for macx you need to have the Python development kit installed as framework
INCLUDEPATH += /System/Library/Frameworks/Python.framework/Headers
LIBS += -F/System/Library/Frameworks -framework Python
} else:win32 {
# for windows install a Python development kit or build Python yourself from the sources
# Make sure that you set the environment variable PYTHON_PATH to point to your
# python installation (or the python sources/header files when building from source).
#
# When using the prebuild Python installer, this will be:
# set PYTHON_PATH = c:\Python310
#
# When using the python sources, this will be something like:
# set PYTHON_PATH = c:\yourDir\Python-3.10.12\
# check if debug or release
CONFIG(debug, debug|release) {
DEBUG_EXT = _d
} else {
DEBUG_EXT =
}
isEmpty(PYTHON_PATH):PYTHON_PATH=$(PYTHON_PATH)
isEmpty(PYTHON_PATH)|!exists("$$PYTHON_PATH\\include") | !exists("$$PYTHON_PATH\\libs\\") {
error("PYTHON_PATH must be set to correct folder with \\libs and \\include subfolders ")
}
INCLUDEPATH += $$shell_path($${PYTHON_PATH}/include)
LIBS += $$shell_path(-L$${PYTHON_PATH}/libs)
LIBS += -lpython$${PYTHON_VERSION_MAJOR}$${PYTHON_VERSION_MINOR}$${DEBUG_EXT}
# Hack for "CONFIG+=testcase" and 'make check' to add python's dll to PATH
deppath += $$shell_path($${PYTHON_PATH})
} else:unix {
# on linux, python-config is used to autodetect Python.
# make sure that you have installed a matching python-dev package.
PYTHON_CONFIG = $${PYTHON_DIR}/bin/python$${PYTHON_VERSION}-config
PYTHON_CONFIG_OPTIONS_LIBS = --libs
equals(PYTHON_VERSION_MAJOR, 3):!lessThan(PYTHON_VERSION_MINOR, 8) {
# Since 3.8 `--embed` is needed
PYTHON_CONFIG_OPTIONS_LIBS += --embed
}
LIBS += $$system($${PYTHON_CONFIG} $${PYTHON_CONFIG_OPTIONS_LIBS})
QMAKE_CXXFLAGS += $$system($${PYTHON_CONFIG} --includes)
PYTHON_LFLAGS = $$system($${PYTHON_CONFIG} --ldflags)
QMAKE_LFLAGS += $${PYTHON_LFLAGS}
# add rpath
PYTHON_LIBDIR = $$find(PYTHON_LFLAGS,-L.*)
PYTHON_RPATH = $$replace(PYTHON_LIBDIR,-L,)
QMAKE_RPATHDIR += $$PYTHON_RPATH
}