未验证 提交 13190707 编写于 作者: zhouweiwei2014's avatar zhouweiwei2014 提交者: GitHub

fix python3.10 compile bug on windows (#42140)

上级 2bcec75a
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#pragma once #pragma once
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
namespace paddle { namespace paddle {
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#pragma once #pragma once
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
namespace paddle { namespace paddle {
......
...@@ -9,6 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -9,6 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
// disable numpy compile error // disable numpy compile error
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <Python.h> #include <Python.h>
#include <string> #include <string>
......
...@@ -9,6 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -9,6 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
// disable numpy compile error // disable numpy compile error
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <Python.h> #include <Python.h>
#include <string> #include <string>
......
...@@ -10,6 +10,11 @@ See the License for the specific language governing permissions and ...@@ -10,6 +10,11 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#pragma once #pragma once
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <Python.h> #include <Python.h>
#include "paddle/phi/common/backend.h" #include "paddle/phi/common/backend.h"
#include "paddle/phi/common/data_type.h" #include "paddle/phi/common/data_type.h"
......
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
#pragma once #pragma once
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
namespace paddle { namespace paddle {
......
...@@ -14,6 +14,11 @@ limitations under the License. */ ...@@ -14,6 +14,11 @@ limitations under the License. */
#pragma once #pragma once
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <Python.h> #include <Python.h>
#include "paddle/fluid/pybind/pybind_boost_headers.h" #include "paddle/fluid/pybind/pybind_boost_headers.h"
......
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
#pragma once #pragma once
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <pybind11/chrono.h> #include <pybind11/chrono.h>
#include <pybind11/complex.h> #include <pybind11/complex.h>
#include <pybind11/functional.h> #include <pybind11/functional.h>
......
...@@ -13,6 +13,10 @@ See the License for the specific language governing permissions and ...@@ -13,6 +13,10 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#pragma once #pragma once
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <Python.h> #include <Python.h>
#include <fstream> #include <fstream>
......
...@@ -50,7 +50,8 @@ TEST(CC, IMPORT_PY) { ...@@ -50,7 +50,8 @@ TEST(CC, IMPORT_PY) {
// 3. C/C++ Run Python file // 3. C/C++ Run Python file
std::string file_name(cwd); std::string file_name(cwd);
file_name.append("/test_install_check.py"); file_name.append("/test_install_check.py");
FILE* fp = _Py_fopen(file_name.c_str(), "r+"); PyObject* obj = Py_BuildValue("s", file_name.c_str());
FILE* fp = _Py_fopen_obj(obj, "r+");
ASSERT_TRUE(fp != NULL); ASSERT_TRUE(fp != NULL);
ASSERT_FALSE(PyRun_SimpleFile(fp, file_name.c_str())); ASSERT_FALSE(PyRun_SimpleFile(fp, file_name.c_str()));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册