Skip to content

Commit

Permalink
Fix windows supports
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Aug 21, 2024
1 parent 06bbd20 commit c0ed728
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 5 additions & 4 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ ARG_ENABLE("phpy", "enable phpy extension", "yes");
if (PHP_PHPY != "no") {
PYTHONHOME = WshShell.Environment("Process").Item("PYTHONHOME")
if (PYTHONHOME) {
ADD_SOURCES("ext/phpy/src/bridge", "core.cc", "phpy")
ADD_SOURCES("ext/phpy/src/php", "object.cc type.cc error.cc iter.cc dict.cc core.cc fn.cc str.cc sequence.cc list.cc set.cc tuple.cc module.cc", "phpy")
ADD_SOURCES("ext/phpy/src/python", "class.cc module.cc object.cc reference.cc resource.cc callable.cc string.cc array.cc", "phpy")
var ext_dir = configure_module_dirname
ADD_SOURCES(ext_dir + "/src/bridge", "core.cc", "phpy")
ADD_SOURCES(ext_dir + "/src/php", "object.cc type.cc error.cc iter.cc dict.cc core.cc fn.cc str.cc sequence.cc list.cc set.cc tuple.cc module.cc", "phpy")
ADD_SOURCES(ext_dir + "/src/python", "class.cc module.cc object.cc reference.cc resource.cc callable.cc string.cc array.cc", "phpy")

EXTENSION("phpy", "phpy.cc", null, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Iext/phpy/include -Iext/phpy /I ' + PYTHONHOME + '/include')
EXTENSION("phpy", "phpy.cc", null, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I ' + ext_dir + '/include -I ' + ext_dir + ' /I ' + PYTHONHOME + '/include')

ADD_FLAG("CFLAGS", "/D PHP_PHPY_EXPORTS ")
ADD_FLAG("LDFLAGS_PHPY", '/libpath:' + PYTHONHOME + '/libs')
Expand Down
8 changes: 8 additions & 0 deletions include/phpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>

#ifdef HAVE_PUTENV
#undef HAVE_PUTENV
#endif

#ifdef HAVE_GETPID
#undef HAVE_GETPID
#endif

#include <main/php.h>
#include <main/SAPI.h>
#include <main/php_main.h>
Expand Down
5 changes: 4 additions & 1 deletion src/php/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,13 @@ ZEND_METHOD(PyCore, fileno) {
RETURN_FALSE;
}

#ifndef PHP_WIN32
if (php_stream_is(stream, PHP_STREAM_IS_MEMORY) || php_stream_is(stream, PHP_STREAM_IS_TEMP)) {
zend_throw_exception(zend_ce_exception, "Memory and temporary file stream is not supported", 0);
RETURN_FALSE;
} else if (php_stream_can_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL) == SUCCESS) {
} else
#endif
if (php_stream_can_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL) == SUCCESS) {
if (php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void **) &fd, 1) !=
SUCCESS ||
fd < 0) {
Expand Down

0 comments on commit c0ed728

Please sign in to comment.