Skip to content

Commit 093d416

Browse files
author
Ellery Newcomer
committed
support python 3.8
1 parent 18e7390 commit 093d416

20 files changed

+314
-44
lines changed

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ sudo: required
33
services:
44
- docker
55
env:
6+
- DC=dmd
7+
PYTHON=python
8+
DUBCFG=python38
9+
RUNSPEC=runtests
10+
DOCKER=ariovistus/pyd-test-env:buster-dmd2_080-py38
611
- DC=dmd
712
PYTHON=python
813
DUBCFG=python37

dub.json

+50
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,56 @@
259259
"Python_3_7_Or_Later"
260260
]
261261
},
262+
{
263+
"name": "python38",
264+
"libs-windows-x86-dmd": [
265+
"$PYD_PACKAGE_DIR\\infrastructure\\windows\\python38_digitalmars"
266+
],
267+
"libs-windows-x86_mscoff": [
268+
"python38"
269+
],
270+
"libs-windows-x86-ldc": [
271+
"python38"
272+
],
273+
"libs-windows-x86_64": [
274+
"python38"
275+
],
276+
"libs-posix": [
277+
"python3.8m"
278+
],
279+
"lflags-windows-x86_64-ldc": [
280+
"\"\"/LIBPATH:$USERPROFILE\\AppData\\Local\\Programs\\Python\\Python38\\libs\"\"",
281+
"\"\"/LIBPATH:C:\\Program Files\\Python38\\libs\"\""
282+
],
283+
"lflags-windows-x86-ldc": [
284+
"\"\"/LIBPATH:$USERPROFILE\\AppData\\Local\\Programs\\Python\\Python38-32\\libs\"\"",
285+
"\"\"/LIBPATH:C:\\Program Files (x86)\\Python38-32\\libs\"\""
286+
],
287+
"lflags-windows-x86_64-dmd": [
288+
"\\\"/LIBPATH:$USERPROFILE\\AppData\\Local\\Programs\\Python\\Python38\\libs\\\"",
289+
"\\\"/LIBPATH:C:\\Program Files\\Python38\\libs\\\""
290+
],
291+
"lflags-windows-x86_mscoff-dmd": [
292+
"\\\"/LIBPATH:$USERPROFILE\\AppData\\Local\\Programs\\Python\\Python38-32\\libs\\\"",
293+
"\\\"/LIBPATH:C:\\Program Files (x86)\\Python38-32\\libs\\\""
294+
],
295+
296+
"versions": [
297+
"Python_2_4_Or_Later",
298+
"Python_2_5_Or_Later",
299+
"Python_2_6_Or_Later",
300+
"Python_2_7_Or_Later",
301+
"Python_3_0_Or_Later",
302+
"Python_3_1_Or_Later",
303+
"Python_3_2_Or_Later",
304+
"Python_3_3_Or_Later",
305+
"Python_3_4_Or_Later",
306+
"Python_3_5_Or_Later",
307+
"Python_3_6_Or_Later",
308+
"Python_3_7_Or_Later",
309+
"Python_3_8_Or_Later"
310+
]
311+
},
262312
{
263313
"name": "env",
264314
"versions": [

envs/buster-dmd2_080-py38/Dockerfile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from python:3.8-buster
2+
3+
ENV \
4+
COMPILER=dmd \
5+
COMPILER_VERSION=2.080.0
6+
7+
RUN apt-get update && apt-get install -y curl build-essential \
8+
&& curl -fsS -o /tmp/install.sh https://dlang.org/install.sh \
9+
&& bash /tmp/install.sh -p /dlang install "${COMPILER}-${COMPILER_VERSION}" \
10+
&& rm /tmp/install.sh \
11+
&& apt-get auto-remove -y curl build-essential \
12+
&& apt-get install -y gcc \
13+
&& rm -rf /var/cache/apt \
14+
&& rm -rf /dlang/${COMPILER}-*/linux/bin32 \
15+
&& rm -rf /dlang/${COMPILER}-*/linux/lib32 \
16+
&& rm -rf /dlang/${COMPILER}-*/html \
17+
&& rm -rf /dlang/dub-1.0.0/dub.tar.gz
18+
19+
ENV \
20+
PATH=/dlang/dub:/dlang/${COMPILER}-${COMPILER_VERSION}/linux/bin64:${PATH} \
21+
LD_LIBRARY_PATH=/dlang/${COMPILER}-${COMPILER_VERSION}/linux/lib64 \
22+
LIBRARY_PATH=/dlang/${COMPILER}-${COMPILER_VERSION}/linux/lib64 \
23+
PS1="(${COMPILER}-${COMPILER_VERSION}) \\u@\\h:\\w\$"
24+
25+
RUN cd /tmp \
26+
&& echo 'void main() {import std.stdio; stdout.writeln("it works"); }' > test.d \
27+
&& dmd test.d \
28+
&& ./test && rm test*
29+
30+
RUN pip3 install nose numpy
31+
WORKDIR /src
52 KB
Binary file not shown.

infrastructure/deimos/python/abstract_.d

+17-9
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,21 @@ Py_ssize_t PyObject_Length(PyObject* o);
5959
/// _
6060
alias PyObject_Length PyObject_Size;
6161

62-
/** The length hint function returns a non-negative value from o.__len__()
63-
or o.__length_hint__(). If those methods aren't found or return a negative
64-
value, then the defaultvalue is returned. If one of the calls fails,
65-
this function returns -1.
66-
*/
67-
version(Python_2_6_Or_Later){
62+
version(Python_3_0_Or_Later) {
63+
Py_ssize_t PyObject_LengthHint(PyObject*, Py_ssize_t);
64+
}else version(Python_2_6_Or_Later){
65+
/** The length hint function returns a non-negative value from o.__len__()
66+
or o.__length_hint__(). If those methods aren't found or return a negative
67+
value, then the defaultvalue is returned. If one of the calls fails,
68+
this function returns -1.
69+
*/
6870
Py_ssize_t _PyObject_LengthHint(PyObject*, Py_ssize_t);
6971
}else version(Python_2_5_Or_Later){
72+
/** The length hint function returns a non-negative value from o.__len__()
73+
or o.__length_hint__(). If those methods aren't found or return a negative
74+
value, then the defaultvalue is returned. If one of the calls fails,
75+
this function returns -1.
76+
*/
7077
Py_ssize_t _PyObject_LengthHint(PyObject*);
7178
}
7279

@@ -94,7 +101,7 @@ version(Python_2_6_Or_Later){
94101

95102
/** Return 1 if the getbuffer function is available, otherwise
96103
return 0 */
97-
int PyObject_CheckBuffer()(PyObject* obj){
104+
int PyObject_CheckBuffer()(PyObject* obj) {
98105
version(Python_3_0_Or_Later) {
99106
return (obj.ob_type.tp_as_buffer !is null) &&
100107
(obj.ob_type.tp_as_buffer.bf_getbuffer !is null);
@@ -414,6 +421,7 @@ PyObject** PySequence_Fast_ITEMS()(PyObject* sf) {
414421
}
415422
/// _
416423
Py_ssize_t PySequence_Count(PyObject* o, PyObject* value);
424+
417425
/// _
418426
enum PY_ITERSEARCH_COUNT = 1;
419427
/// _
@@ -492,9 +500,9 @@ int PyObject_IsInstance(PyObject* object, PyObject* typeorclass);
492500
/// _
493501
int PyObject_IsSubclass(PyObject* object, PyObject* typeorclass);
494502
version(Python_2_6_Or_Later){
495-
/// Availability: >= 2.6
503+
/// Availability: >= 2.6
496504
int _PyObject_RealIsInstance(PyObject* inst, PyObject* cls);
497-
/// Availability: >= 2.6
505+
/// Availability: >= 2.6
498506
int _PyObject_RealIsSubclass(PyObject* derived, PyObject* cls);
499507
}
500508

infrastructure/deimos/python/ceval.d

+11-6
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ void PyEval_RestoreThread(PyThreadState*);
177177
int PyEval_ThreadsInitialized();
178178
/// _
179179
void PyEval_InitThreads();
180-
version(Python_3_0_Or_Later) {
181-
/// Availability: 3.*
180+
version(Python_3_8_Or_Later) {
181+
}else version(Python_3_0_Or_Later) {
182+
/// Availability: 3.0 - 3.7
182183
void _PyEval_FiniThreads();
183184
}
184185
/// _
@@ -189,8 +190,11 @@ void PyEval_ReleaseLock();
189190
void PyEval_AcquireThread(PyThreadState* tstate);
190191
/// _
191192
void PyEval_ReleaseThread(PyThreadState* tstate);
192-
/// _
193-
void PyEval_ReInitThreads();
193+
version(Python_3_8_Or_Later) {
194+
}else {
195+
/// Availability: < 3.8
196+
void PyEval_ReInitThreads();
197+
}
194198

195199
version(Python_3_0_Or_Later) {
196200
/// Availability: 3.*
@@ -231,7 +235,8 @@ string Py_ALLOW_THREADS()(string inner_code) {
231235

232236
///_
233237
int _PyEval_SliceIndex(PyObject*, Py_ssize_t*);
234-
version(Python_3_0_Or_Later) {
235-
/// Availability: 3.*
238+
version(Python_3_8_Or_Later) {
239+
}else version(Python_3_0_Or_Later) {
240+
/// Availability: 3.0 - 3.7
236241
void _PyEval_SignalAsyncExc();
237242
}

infrastructure/deimos/python/classobject.d

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ struct PyMethodObject {
6363
}
6464
/** List of weak references */
6565
PyObject* im_weakreflist;
66+
version(Python_3_8_Or_Later) {
67+
vectorcallfunc vectorcall;
68+
}
6669
}
6770

6871
/// _

infrastructure/deimos/python/code.d

+68-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import deimos.python.object;
1313

1414
extern(C):
1515

16+
struct _PyOpcache {
17+
}
18+
1619
/** Bytecode object
1720
1821
subclass of PyObject.
@@ -22,6 +25,10 @@ struct PyCodeObject {
2225

2326
/** #arguments, except *args */
2427
int co_argcount;
28+
version(Python_3_8_Or_Later) {
29+
/** #positional only arguments */
30+
int co_posonlyargcount;
31+
}
2532
version(Python_3_4_Or_Later) {
2633
/** #keyword only arguments */
2734
int co_kwonlyargcount;
@@ -85,6 +92,23 @@ struct PyCodeObject {
8592
people to go through the proper APIs */
8693
void* co_extra;
8794
}
95+
96+
version(Python_3_8_Or_Later) {
97+
/* Per opcodes just-in-time cache
98+
*
99+
* To reduce cache size, we use indirect mapping from opcode index to
100+
* cache object:
101+
* cache = co_opcache[co_opcache_map[next_instr - first_instr] - 1]
102+
*/
103+
104+
// co_opcache_map is indexed by (next_instr - first_instr).
105+
// * 0 means there is no cache for this opcode.
106+
// * n > 0 means there is cache in co_opcache[n-1].
107+
ubyte* co_opcache_map;
108+
_PyOpcache* co_opcache;
109+
int co_opcache_flag; // used to determine when create a cache.
110+
ubyte co_opcache_size; // length of co_opcache.
111+
}
88112
}
89113

90114
/** Masks for co_flags above */
@@ -164,9 +188,49 @@ size_t PyCode_GetNumFree()(PyObject* op) {
164188
return PyObject_Length((cast(PyCodeObject *) op).co_freevars);
165189
}
166190

167-
/// _
168-
PyCodeObject* PyCode_New(
191+
version(Python_3_0_Or_Later) {
192+
/// _
193+
PyCodeObject* PyCode_New(
194+
int argcount,
195+
int kwonlyargcount,
196+
int nlocals,
197+
int stacksize,
198+
int flags,
199+
PyObject* code,
200+
PyObject* consts,
201+
PyObject* names,
202+
PyObject* varnames,
203+
PyObject* freevars,
204+
PyObject* cellvars,
205+
PyObject* filenames,
206+
PyObject* name,
207+
int firstlineno,
208+
PyObject* lnotab);
209+
}else{
210+
/// _
211+
PyCodeObject* PyCode_New(
212+
int argcount,
213+
int nlocals,
214+
int stacksize,
215+
int flags,
216+
PyObject* code,
217+
PyObject* consts,
218+
PyObject* names,
219+
PyObject* varnames,
220+
PyObject* freevars,
221+
PyObject* cellvars,
222+
PyObject* filenames,
223+
PyObject* name,
224+
int firstlineno,
225+
PyObject* lnotab);
226+
}
227+
228+
version(Python_3_8_Or_Later) {
229+
/// Availability: >= 3.8
230+
PyCodeObject* PyCode_NewWithPosOnlyArgs(
169231
int argcount,
232+
int posonlyargcount,
233+
int kwonlyargcount,
170234
int nlocals,
171235
int stacksize,
172236
int flags,
@@ -176,10 +240,11 @@ PyCodeObject* PyCode_New(
176240
PyObject* varnames,
177241
PyObject* freevars,
178242
PyObject* cellvars,
179-
PyObject* filenames,
243+
PyObject* filename,
180244
PyObject* name,
181245
int firstlineno,
182246
PyObject* lnotab);
247+
}
183248

184249
version(Python_2_7_Or_Later) {
185250
/** Creates a new empty code object with the specified source location. */

infrastructure/deimos/python/compile.d

+3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ version(Python_3_7_Or_Later) {
2626
enum PyCF_DONT_IMPLY_DEDENT = 0x200;
2727
enum PyCF_ONLY_AST = 0x400;
2828
enum PyCF_IGNORE_COOKIE = 0x800;
29+
enum PyCF_TYPE_COMMENTS = 0x1000;
30+
enum PyCF_ALLOW_TOP_LEVEL_AWAIT = 0x2000;
2931

3032
struct PyCompilerFlags {
3133
int cf_flags;
3234
}
3335
}
3436

37+
3538
/// _
3639
struct PyFutureFeatures {
3740
version(Python_2_5_Or_Later){

infrastructure/deimos/python/dictobject.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ version(Python_3_5_Or_Later) {
112112
PyDictObject* dv_dict;
113113
}
114114
}
115-
116115
/// _
117116
mixin(PyAPI_DATA!"PyTypeObject PyDict_Type");
117+
118118
version(Python_2_7_Or_Later) {
119119
/// Availability: >= 2.7
120120
mixin(PyAPI_DATA!"PyTypeObject PyDictIterKey_Type");

infrastructure/deimos/python/fileobject.d

+9-6
Original file line numberDiff line numberDiff line change
@@ -120,29 +120,32 @@ int PyFile_WriteString(const(char)*, PyObject*);
120120
/// _
121121
int PyObject_AsFileDescriptor(PyObject*);
122122

123-
/** The default encoding used by the platform file system APIs
124-
If non-NULL, this is different than the default encoding for strings
125-
*/
126-
mixin(PyAPI_DATA!"const(char)* Py_FileSystemDefaultEncoding");
123+
version(Python_3_8_Or_Later) {
124+
}else {
125+
/** The default encoding used by the platform file system APIs
126+
If non-NULL, this is different than the default encoding for strings
127+
*/
128+
mixin(PyAPI_DATA!"const(char)* Py_FileSystemDefaultEncoding");
129+
}
127130

128131
version(Python_3_6_Or_Later) {
129132
/// _
130133
mixin(PyAPI_DATA!"const(char)* Py_FileSystemDefaultEncodeError");
131134
}
132135

133136
version(Python_3_7_Or_Later) {
134-
/// _
137+
/// Availablility: >= 3.7
135138
mixin(PyAPI_DATA!"int Py_UTF8Mode");
136139
}
137140

138141
/// _
139142
enum PY_STDIOTEXTMODE = "b";
140-
141143
/// _
142144
/* Routine to replace fgets() which accept any of \r, \n
143145
or \r\n as line terminators.
144146
*/
145147
char* Py_UniversalNewlineFgets(char*, int, FILE*, PyObject*);
148+
146149
version(Python_3_0_Or_Later) {
147150
/// Availability: 3.*
148151
mixin(PyAPI_DATA!"int Py_HasFileSystemDefaultEncoding");

infrastructure/deimos/python/funcobject.d

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ struct PyFunctionObject {
5757
/** Annotations, a dict or NULL */
5858
/// Availability: 3.*
5959
PyObject* func_annotations;
60+
PyObject* func_qualname;
61+
}
62+
63+
version(Python_3_8_Or_Later) {
64+
/// Availability: >= 3.8
65+
vectorcallfunc vectorcall;
6066
}
6167
}
6268

0 commit comments

Comments
 (0)