|
2 | 2 |
|
3 | 3 |
|
4 | 4 | # 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 | +} |
6 | 8 | isEmpty( PYTHON_VERSION ) {
|
7 | 9 | win32:PYTHON_VERSION=27
|
8 | 10 | unix:PYTHON_VERSION=2.7
|
9 | 11 | }
|
10 | 12 |
|
11 |
| - |
12 |
| -macx { |
13 |
| - # for macx you need to have the Python development kit installed as framework |
14 |
| - INCLUDEPATH += /System/Library/Frameworks/Python.framework/Headers |
15 |
| - LIBS += -F/System/Library/Frameworks -framework Python |
16 |
| -} else:win32 { |
17 |
| - # for windows install a Python development kit or build Python yourself from the sources |
18 |
| - # Make sure that you set the environment variable PYTHON_PATH to point to your |
19 |
| - # python installation (or the python sources/header files when building from source). |
20 |
| - # Make sure that you set the environment variable PYTHON_LIB to point to |
21 |
| - # the directory where the python libs are located. |
22 |
| - # |
23 |
| - # When using the prebuild Python installer, this will be: |
24 |
| - # set PYTHON_PATH = c:\Python26 |
25 |
| - # set PYTHON_LIB = c:\Python26\libs |
26 |
| - # |
27 |
| - # When using the python sources, this will be something like: |
28 |
| - # set PYTHON_PATH = c:\yourDir\Python-2.6.1\ |
29 |
| - # set PYTHON_LIB = c:\yourDir\Python-2.6.1\PCbuild8\Win32 |
30 |
| - |
31 |
| - # check if debug or release |
32 |
| - CONFIG(debug, debug|release) { |
33 |
| - DEBUG_EXT = _d |
34 |
| - } else { |
35 |
| - DEBUG_EXT = |
36 |
| - } |
37 |
| - |
38 |
| - win32:INCLUDEPATH += $$(PYTHON_PATH)/PC $$(PYTHON_PATH)/include |
39 |
| - win32:LIBS += $$(PYTHON_LIB)/python$${PYTHON_VERSION}$${DEBUG_EXT}.lib |
40 |
| -} else:unix { |
41 |
| - # on linux, python-config is used to autodetect Python. |
42 |
| - # make sure that you have installed a matching python-dev package. |
| 13 | +isEmpty( PYTHON_DIR ) { |
| 14 | + PYTHON_DIR=$$(PYTHON_DIR) |
| 15 | +} |
| 16 | +!isEmpty( PYTHON_DIR ) { |
| 17 | + PYTHON_DIR=$${PYTHON_DIR}/ |
| 18 | +} |
| 19 | + |
| 20 | +message(Using Python version $${PYTHON_VERSION}) |
| 21 | + |
| 22 | +macx { |
| 23 | + # for macx you need to have the Python development kit installed as framework |
| 24 | + INCLUDEPATH += /System/Library/Frameworks/Python.framework/Headers |
| 25 | + LIBS += -F/System/Library/Frameworks -framework Python |
| 26 | +} else:win32 { |
| 27 | + # for windows install a Python development kit or build Python yourself from the sources |
| 28 | + # Make sure that you set the environment variable PYTHON_PATH to point to your |
| 29 | + # python installation (or the python sources/header files when building from source). |
| 30 | + # Make sure that you set the environment variable PYTHON_LIB to point to |
| 31 | + # the directory where the python libs are located. |
| 32 | + # |
| 33 | + # When using the prebuild Python installer, this will be: |
| 34 | + # set PYTHON_PATH = c:\Python26 |
| 35 | + # set PYTHON_LIB = c:\Python26\libs |
| 36 | + # |
| 37 | + # When using the python sources, this will be something like: |
| 38 | + # set PYTHON_PATH = c:\yourDir\Python-2.6.1\ |
| 39 | + # set PYTHON_LIB = c:\yourDir\Python-2.6.1\PCbuild8\Win32 |
| 40 | + |
| 41 | + # check if debug or release |
| 42 | + CONFIG(debug, debug|release) { |
| 43 | + DEBUG_EXT = _d |
| 44 | + } else { |
| 45 | + DEBUG_EXT = |
| 46 | + } |
| 47 | + |
| 48 | + win32:INCLUDEPATH += $$(PYTHON_PATH)/PC $$(PYTHON_PATH)/include |
| 49 | + win32:LIBS += $$(PYTHON_LIB)/python$${PYTHON_VERSION}$${DEBUG_EXT}.lib |
| 50 | +} else:unix { |
| 51 | + # on linux, python-config is used to autodetect Python. |
| 52 | + # make sure that you have installed a matching python-dev package. |
43 | 53 |
|
44 |
| - system(python$${PYTHON_VERSION}-config --embed --libs) { |
45 |
| - unix:LIBS += $$system(python$${PYTHON_VERSION}-config --embed --libs) |
46 |
| - } else: unix:LIBS += $$system(python$${PYTHON_VERSION}-config --libs) |
47 |
| - unix:QMAKE_CXXFLAGS += $$system(python$${PYTHON_VERSION}-config --includes) |
48 |
| -} |
| 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} |
| 66 | +} |
0 commit comments