Skip to content

Commit 383fb8e

Browse files
Allow setting PYTHON_VERSION and PYTHON_DIR when including python.prf, add rpath
1 parent 295a9ce commit 383fb8e

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

build/python.prf

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22

33

44
# Change this variable to your python version (2.6, 2.7, 3.3, ...)
5-
PYTHON_VERSION=$$(PYTHON_VERSION)
5+
isEmpty( PYTHON_VERSION ) {
6+
PYTHON_VERSION=$$(PYTHON_VERSION)
7+
}
68
isEmpty( PYTHON_VERSION ) {
79
win32:PYTHON_VERSION=27
810
unix:PYTHON_VERSION=2.7
911
}
1012

13+
isEmpty( PYTHON_DIR ) {
14+
PYTHON_DIR=$$(PYTHON_DIR)
15+
}
16+
!isEmpty( PYTHON_DIR ) {
17+
PYTHON_DIR=$${PYTHON_DIR}/
18+
}
19+
1120
message(Using Python version $${PYTHON_VERSION})
1221

1322
macx {
@@ -42,9 +51,16 @@ macx {
4251
# on linux, python-config is used to autodetect Python.
4352
# make sure that you have installed a matching python-dev package.
4453

45-
system(python$${PYTHON_VERSION}-config --embed --libs) {
46-
unix:LIBS += $$system(python$${PYTHON_VERSION}-config --embed --libs)
47-
} else: unix:LIBS += $$system(python$${PYTHON_VERSION}-config --libs)
48-
unix:QMAKE_CXXFLAGS += $$system(python$${PYTHON_VERSION}-config --includes)
49-
unix:QMAKE_LFLAGS += $$system(python$${PYTHON_VERSION}-config --ldflags)
54+
PYTHON_CONFIG = $${PYTHON_DIR}/bin/python$${PYTHON_VERSION}-config
55+
system($${PYTHON_CONFIG} --embed --libs) {
56+
unix:LIBS += $$system($${PYTHON_CONFIG} --embed --libs)
57+
} else: unix:LIBS += $$system($${PYTHON_CONFIG} --libs)
58+
unix:QMAKE_CXXFLAGS += $$system($${PYTHON_CONFIG} --includes)
59+
PYTHON_LFLAGS = $$system($${PYTHON_CONFIG} --ldflags)
60+
unix:QMAKE_LFLAGS += $${PYTHON_LFLAGS}
61+
# add rpath
62+
PYTHON_LIBDIR = $$find(PYTHON_LFLAGS,-L.*)
63+
RPATH = -Wl,-rpath,
64+
PYTHON_RPATH = $$replace(PYTHON_LIBDIR,-L,$${RPATH})
65+
unix:QMAKE_LFLAGS += $${PYTHON_RPATH}
5066
}

0 commit comments

Comments
 (0)