Skip to content

Commit fe6138d

Browse files
committed
ENH: Using dPython.h to wrap around Python.h. It provides the ability to link against release python with a debug build of your project.
Copied from file "VTK/Common/vtkPython.h" available on http://vtk.org/gitweb
1 parent ef5d52c commit fe6138d

9 files changed

+69
-8
lines changed

src/PythonQtClassWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343
//----------------------------------------------------------------------------------
4444

45-
#include <Python.h>
45+
#include <dPython.h>
4646

4747
#include "PythonQtSystem.h"
4848

src/PythonQtImporter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343
//----------------------------------------------------------------------------------
4444

45-
#include "Python.h"
45+
#include "dPython.h"
4646
#include "structmember.h"
4747
#include "osdefs.h"
4848
#include "marshal.h"

src/PythonQtInstanceWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343
//----------------------------------------------------------------------------------
4444

45-
#include <Python.h>
45+
#include <dPython.h>
4646

4747
#include "PythonQtSystem.h"
4848
#include <QPointer>

src/PythonQtObjectPtr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343
//----------------------------------------------------------------------------------
4444

45-
#include <Python.h>
45+
#include <dPython.h>
4646
#include "PythonQtSystem.h"
4747
#include <QVariant>
4848
#include <QVariantList>

src/PythonQtSignalReceiver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343
//----------------------------------------------------------------------------------
4444

45-
#include <Python.h>
45+
#include <dPython.h>
4646
#include "PythonQtSystem.h"
4747
#include "PythonQtObjectPtr.h"
4848

src/PythonQtSlot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343
//----------------------------------------------------------------------------------
4444

45-
#include "Python.h"
45+
#include "dPython.h"
4646
#include "PythonQtSystem.h"
4747
#include "structmember.h"
4848

src/PythonQtStdDecorators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
//----------------------------------------------------------------------------------
4444

4545
#include "PythonQtSystem.h"
46-
#include <Python.h>
46+
#include <dPython.h>
4747
#include <QObject>
4848
#include <QVariantList>
4949
#include <QTextDocument>

src/PythonQtStdOut.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
//----------------------------------------------------------------------------------
4444

4545

46-
#include <Python.h>
46+
#include <dPython.h>
4747
#include "structmember.h"
4848
#include <QString>
4949

src/dPython.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*=========================================================================
2+
3+
Library: CTK
4+
5+
Copyright (c) 2010 Kitware Inc.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.commontk.org/LICENSE
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
=========================================================================*/
20+
/*=========================================================================
21+
22+
Program: Visualization Toolkit
23+
Module: vtkPython.h
24+
25+
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
26+
All rights reserved.
27+
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
28+
29+
This software is distributed WITHOUT ANY WARRANTY; without even
30+
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31+
PURPOSE. See the above copyright notice for more information.
32+
33+
=========================================================================*/
34+
35+
#ifndef __dPython_h
36+
#define __dPython_h
37+
38+
/*
39+
Use the real python debugging library if it is provided.
40+
Otherwise use the "documented" trick involving checking for _DEBUG
41+
and undefined that symbol while we include Python headers.
42+
Update: this method does not fool Microsoft Visual C++ 8 anymore; two
43+
of its header files (crtdefs.h and use_ansi.h) check if _DEBUG was set
44+
or not, and set flags accordingly (_CRT_MANIFEST_RETAIL,
45+
_CRT_MANIFEST_DEBUG, _CRT_MANIFEST_INCONSISTENT). The next time the
46+
check is performed in the same compilation unit, and the flags are found,
47+
and error is triggered. Let's prevent that by setting _CRT_NOFORCE_MANIFEST.
48+
*/
49+
50+
#ifdef _DEBUG
51+
# undef _DEBUG
52+
# if defined(_MSC_VER) && _MSC_VER >= 1400
53+
# define _CRT_NOFORCE_MANIFEST 1
54+
# endif
55+
# include <Python.h>
56+
# define _DEBUG
57+
#else
58+
# include <Python.h>
59+
#endif
60+
61+
#endif

0 commit comments

Comments
 (0)