Skip to content

Commit 4aebb04

Browse files
committed
[GR-42006] Support for C extensions via pythonjni on Windows
PullRequest: graalpython/2864
2 parents fc1d5bd + 54bc9e3 commit 4aebb04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+409
-166
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ language runtime. The main focus is on user-observable behavior of the engine.
55

66
## Version 23.1.0
77
* Oracle GraalPy standalones (also known as GraalPy Enterprise) are now available under GFTC. The community builds published on Github have been renamed to `graalpy-community-<version>-<os>-<arch>.tar.gz`.
8+
* Support compilation and execution of C extensions using the native MSVC toolchain on Windows.
89

910
## Version 23.0.0
1011
* Update `numpy` and `pandas` versions, add support for `scipy` and `scikit_learn` with `ginstall`. This automatically applies some fixes that make it possible to use these new versions with GraalPy.

graalpython/com.oracle.graal.python.cext/CAPIFunctions.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ _Py_FatalErrorFunc;void;const char*|const char*
4141
_Py_FdIsInteractive;int;FILE*|PyObject*
4242
_Py_fopen_obj;FILE*;PyObject*|const char*
4343
_Py_FreeCharPArray;void;char*const []
44-
_Py_fstat_noraise;int;int|struct stat*
45-
_Py_fstat;int;int|struct stat*
44+
_Py_fstat_noraise;int;int|struct _Py_stat_struct*
45+
_Py_fstat;int;int|struct _Py_stat_struct*
4646
_Py_get_blocking;int;int
4747
_Py_get_inheritable;int;int
4848
_Py_GetAllocatedBlocks;Py_ssize_t;void

graalpython/com.oracle.graal.python.cext/include/Python.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2022, Oracle and/or its affiliates.
1+
/* Copyright (c) 2022, 2023, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2022 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -42,6 +42,8 @@
4242
#include <stdlib.h>
4343
#ifndef MS_WINDOWS
4444
#include <unistd.h>
45+
#else
46+
#include <winsock.h>
4547
#endif
4648

4749
/* For size_t? */

graalpython/com.oracle.graal.python.cext/include/cpython/code.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ PyAPI_FUNC(int) _PyCode_SetExtra(PyObject *code, Py_ssize_t index,
181181
void *extra);
182182

183183
/** API for initializing the line number table. */
184-
int _PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds);
184+
PyAPI_FUNC(int) _PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds);
185185

186186
/** Out of process API for initializing the line number table. */
187-
void PyLineTable_InitAddressRange(const char *linetable, Py_ssize_t length, int firstlineno, PyCodeAddressRange *range);
187+
PyAPI_FUNC(void) PyLineTable_InitAddressRange(const char *linetable, Py_ssize_t length, int firstlineno, PyCodeAddressRange *range);
188188

189189
/** API for traversing the line number table. */
190-
int PyLineTable_NextAddressRange(PyCodeAddressRange *range);
191-
int PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
190+
PyAPI_FUNC(int) PyLineTable_NextAddressRange(PyCodeAddressRange *range);
191+
PyAPI_FUNC(int) PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
192192

193193

graalpython/com.oracle.graal.python.cext/include/cpython/dictobject.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
/* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -45,7 +45,7 @@ PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
4545
Py_hash_t hash);
4646
PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
4747
int (*predicate)(PyObject *value));
48-
PyDictKeysObject *_PyDict_NewKeysForClass(void);
48+
PyAPI_FUNC(PyDictKeysObject *) _PyDict_NewKeysForClass(void);
4949
PyAPI_FUNC(int) _PyDict_Next(
5050
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
5151

@@ -56,11 +56,11 @@ PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, struct _Py_Identifier *);
5656
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
5757
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
5858
PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
59-
Py_ssize_t _PyDict_KeysSize(PyDictKeysObject *keys);
59+
PyAPI_FUNC(Py_ssize_t) _PyDict_KeysSize(PyDictKeysObject *keys);
6060
PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *);
6161
PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *, PyObject *, PyObject *);
62-
PyObject *_PyDict_Pop_KnownHash(PyObject *, PyObject *, Py_hash_t, PyObject *);
63-
PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *);
62+
PyAPI_FUNC(PyObject *) _PyDict_Pop_KnownHash(PyObject *, PyObject *, Py_hash_t, PyObject *);
63+
PyAPI_FUNC(PyObject *) _PyDict_FromKeys(PyObject *, PyObject *, PyObject *);
6464
#define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL)
6565

6666
/* Like PyDict_Merge, but override can be 0, 1 or 2. If override is 0,
@@ -74,9 +74,9 @@ PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyOb
7474
PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
7575
PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
7676

77-
int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
78-
PyObject *_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *);
79-
Py_ssize_t _PyDict_GetItemHint(PyDictObject *, PyObject *, Py_ssize_t, PyObject **);
77+
PyAPI_FUNC(int) _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
78+
PyAPI_FUNC(PyObject *) _PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *);
79+
PyAPI_FUNC(Py_ssize_t) _PyDict_GetItemHint(PyDictObject *, PyObject *, Py_ssize_t, PyObject **);
8080

8181
/* _PyDictView */
8282

graalpython/com.oracle.graal.python.cext/include/cpython/frameobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2022, Oracle and/or its affiliates.
1+
/* Copyright (c) 2022, 2023, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2022 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -76,7 +76,7 @@ PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
7676
PyObject *, PyObject *);
7777

7878
/* only internal use */
79-
PyFrameObject*
79+
PyAPI_FUNC(PyFrameObject*)
8080
_PyFrame_New_NoTrack(PyThreadState *, PyFrameConstructor *, PyObject *);
8181

8282

graalpython/com.oracle.graal.python.cext/include/cpython/pyerrors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
/* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -145,7 +145,7 @@ PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
145145

146146
/* In signalmodule.c */
147147

148-
int PySignal_SetWakeupFd(int fd);
148+
PyAPI_FUNC(int) PySignal_SetWakeupFd(int fd);
149149
PyAPI_FUNC(int) _PyErr_CheckSignals(void);
150150

151151
/* Support for adding program text to SyntaxErrors */

graalpython/com.oracle.graal.python.cext/include/datetime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ typedef struct
119119
} PyDateTime_DateTime; /* hastzinfo true */
120120

121121

122-
PyObject* PyTruffle_PyDateTime_GET_TZINFO(PyObject*);
122+
PyAPI_FUNC(PyObject*) PyTruffle_PyDateTime_GET_TZINFO(PyObject*);
123123

124124
/* Apply for date and datetime instances. */
125125

graalpython/com.oracle.graal.python.cext/include/genobject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *,
4747
PyObject *name, PyObject *qualname);
4848
PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
4949
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
50-
PyObject *_PyGen_yf(PyGenObject *);
50+
PyAPI_FUNC(PyObject *) _PyGen_yf(PyGenObject *);
5151
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
5252

5353
#ifndef Py_LIMITED_API
@@ -60,7 +60,7 @@ PyAPI_DATA(PyTypeObject) PyCoro_Type;
6060
PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type;
6161

6262
#define PyCoro_CheckExact(op) Py_IS_TYPE(op, &PyCoro_Type)
63-
PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
63+
PyAPI_FUNC(PyObject *) _PyCoro_GetAwaitableIter(PyObject *o);
6464
PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
6565
PyObject *name, PyObject *qualname);
6666

@@ -92,7 +92,7 @@ PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
9292

9393
#define PyAsyncGen_CheckExact(op) Py_IS_TYPE(op, &PyAsyncGen_Type)
9494

95-
PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
95+
PyAPI_FUNC(PyObject *) _PyAsyncGenValueWrapperNew(PyObject *);
9696

9797
#endif
9898

graalpython/com.oracle.graal.python.cext/include/modsupport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2023, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -138,7 +138,7 @@ PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
138138
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
139139
(minpos), (maxpos), (minkw), (buf)))
140140

141-
void _PyArg_Fini(void);
141+
PyAPI_FUNC(void) _PyArg_Fini(void);
142142
#endif /* Py_LIMITED_API */
143143

144144
// Add an attribute with name 'name' and value 'obj' to the module 'mod.

0 commit comments

Comments
 (0)