Skip to content

Commit

Permalink
fix python3.10 compile bug on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwesky2010 committed Apr 22, 2022
1 parent 34ac7b7 commit 8592983
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 1 deletion.
4 changes: 4 additions & 0 deletions paddle/fluid/pybind/bind_fleet_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#pragma once

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <pybind11/pybind11.h>

namespace paddle {
Expand Down
4 changes: 4 additions & 0 deletions paddle/fluid/pybind/compatible.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#pragma once

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <pybind11/pybind11.h>

namespace paddle {
Expand Down
6 changes: 6 additions & 0 deletions paddle/fluid/pybind/eager_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
limitations under the License. */
// disable numpy compile error

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

#include <Python.h>

#include <string>
Expand Down
6 changes: 6 additions & 0 deletions paddle/fluid/pybind/eager_method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
limitations under the License. */
// disable numpy compile error

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

#include <Python.h>

#include <string>
Expand Down
5 changes: 5 additions & 0 deletions paddle/fluid/pybind/eager_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ See the License for the specific language governing permissions and
limitations under the License. */
#pragma once

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

#include <Python.h>
#include "paddle/phi/common/backend.h"
#include "paddle/phi/common/data_type.h"
Expand Down
5 changes: 5 additions & 0 deletions paddle/fluid/pybind/inference_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

#pragma once

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

#include <pybind11/pybind11.h>

namespace paddle {
Expand Down
5 changes: 5 additions & 0 deletions paddle/fluid/pybind/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ limitations under the License. */

#pragma once

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

#include <Python.h>
#include "paddle/fluid/pybind/pybind_boost_headers.h"

Expand Down
5 changes: 5 additions & 0 deletions paddle/fluid/pybind/op_function_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

#pragma once

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

#include <pybind11/chrono.h>
#include <pybind11/complex.h>
#include <pybind11/functional.h>
Expand Down
4 changes: 4 additions & 0 deletions paddle/fluid/pybind/protobuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ See the License for the specific language governing permissions and
limitations under the License. */
#pragma once

#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
#include <Python.h>

#include <fstream>
Expand Down
3 changes: 2 additions & 1 deletion python/paddle/fluid/tests/unittests/cc_imp_py_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ TEST(CC, IMPORT_PY) {
// 3. C/C++ Run Python file
std::string file_name(cwd);
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_FALSE(PyRun_SimpleFile(fp, file_name.c_str()));

Expand Down

1 comment on commit 8592983

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.