Skip to content

Commit 58504e4

Browse files
committed
Python 3.9 (#1264)
* Add Python 3.9 to CI * Update AppVeyor image and always install all requirements * Add Python 3.9 interop file * Fix geninterop script and regenerate interop39.cs - Only record structs when they are defined, not when they are declared - If a struct was only declared when a typedef was created, it won't contain its member declarations. Those have to be drawn from the recorded structs instead. - Rename internal members of AstParser to make it easier to debug
1 parent 1861bee commit 58504e4

File tree

7 files changed

+381
-75
lines changed

7 files changed

+381
-75
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ dist: xenial
22
sudo: false
33
language: python
44
python:
5+
- 3.9
56
- 3.8
67
- 3.7
78
- 3.6

appveyor.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ environment:
1515
CODECOV_ENV: PYTHON_VERSION, PLATFORM
1616

1717
matrix:
18+
- PYTHON_VERSION: 3.9
19+
BUILD_OPTS: --xplat
1820
- PYTHON_VERSION: 3.8
1921
BUILD_OPTS: --xplat
2022
- PYTHON_VERSION: 3.7
@@ -25,12 +27,12 @@ environment:
2527
BUILD_OPTS: --xplat
2628
- PYTHON_VERSION: 2.7
2729
BUILD_OPTS: --xplat
30+
- PYTHON_VERSION: 3.9
2831
- PYTHON_VERSION: 3.8
2932
- PYTHON_VERSION: 3.7
3033
- PYTHON_VERSION: 3.6
3134
- PYTHON_VERSION: 3.5
3235
- PYTHON_VERSION: 2.7
33-
3436
init:
3537
# Update Environment Variables based on matrix/platform
3638
- set PY_VER=%PYTHON_VERSION:.=%

requirements.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# Requirements for both Travis and AppVeyor
2-
pytest==3.2.5
2+
pytest
33
coverage
44
psutil
55

66
# Coverage upload
77
codecov
88

99
# Platform specific requirements
10-
# pip; sys_platform == 'win32'
11-
wheel; sys_platform == 'win32'
12-
pycparser; sys_platform != 'win32'
10+
wheel
11+
pycparser

src/runtime/Python.Runtime.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -165,6 +165,7 @@
165165
<Compile Include="interop36.cs" />
166166
<Compile Include="interop37.cs" />
167167
<Compile Include="interop38.cs" />
168+
<Compile Include="interop39.cs" />
168169
</ItemGroup>
169170
<ItemGroup>
170171
<None Include="..\pythonnet.snk" />

src/runtime/interop39.cs

+227
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
2+
// Auto-generated by geninterop.py.
3+
// DO NOT MODIFY BY HAND.
4+
5+
6+
#if PYTHON39
7+
using System;
8+
using System.Collections;
9+
using System.Collections.Specialized;
10+
using System.Runtime.InteropServices;
11+
using System.Reflection;
12+
using System.Text;
13+
14+
namespace Python.Runtime
15+
{
16+
17+
[StructLayout(LayoutKind.Sequential)]
18+
internal static partial class TypeOffset
19+
{
20+
// Auto-generated from PyHeapTypeObject in Python.h
21+
public static int ob_refcnt = 0;
22+
public static int ob_type = 0;
23+
public static int ob_size = 0;
24+
public static int tp_name = 0;
25+
public static int tp_basicsize = 0;
26+
public static int tp_itemsize = 0;
27+
public static int tp_dealloc = 0;
28+
public static int tp_vectorcall_offset = 0;
29+
public static int tp_getattr = 0;
30+
public static int tp_setattr = 0;
31+
public static int tp_as_async = 0;
32+
public static int tp_repr = 0;
33+
public static int tp_as_number = 0;
34+
public static int tp_as_sequence = 0;
35+
public static int tp_as_mapping = 0;
36+
public static int tp_hash = 0;
37+
public static int tp_call = 0;
38+
public static int tp_str = 0;
39+
public static int tp_getattro = 0;
40+
public static int tp_setattro = 0;
41+
public static int tp_as_buffer = 0;
42+
public static int tp_flags = 0;
43+
public static int tp_doc = 0;
44+
public static int tp_traverse = 0;
45+
public static int tp_clear = 0;
46+
public static int tp_richcompare = 0;
47+
public static int tp_weaklistoffset = 0;
48+
public static int tp_iter = 0;
49+
public static int tp_iternext = 0;
50+
public static int tp_methods = 0;
51+
public static int tp_members = 0;
52+
public static int tp_getset = 0;
53+
public static int tp_base = 0;
54+
public static int tp_dict = 0;
55+
public static int tp_descr_get = 0;
56+
public static int tp_descr_set = 0;
57+
public static int tp_dictoffset = 0;
58+
public static int tp_init = 0;
59+
public static int tp_alloc = 0;
60+
public static int tp_new = 0;
61+
public static int tp_free = 0;
62+
public static int tp_is_gc = 0;
63+
public static int tp_bases = 0;
64+
public static int tp_mro = 0;
65+
public static int tp_cache = 0;
66+
public static int tp_subclasses = 0;
67+
public static int tp_weaklist = 0;
68+
public static int tp_del = 0;
69+
public static int tp_version_tag = 0;
70+
public static int tp_finalize = 0;
71+
public static int tp_vectorcall = 0;
72+
public static int am_await = 0;
73+
public static int am_aiter = 0;
74+
public static int am_anext = 0;
75+
public static int nb_add = 0;
76+
public static int nb_subtract = 0;
77+
public static int nb_multiply = 0;
78+
public static int nb_remainder = 0;
79+
public static int nb_divmod = 0;
80+
public static int nb_power = 0;
81+
public static int nb_negative = 0;
82+
public static int nb_positive = 0;
83+
public static int nb_absolute = 0;
84+
public static int nb_bool = 0;
85+
public static int nb_invert = 0;
86+
public static int nb_lshift = 0;
87+
public static int nb_rshift = 0;
88+
public static int nb_and = 0;
89+
public static int nb_xor = 0;
90+
public static int nb_or = 0;
91+
public static int nb_int = 0;
92+
public static int nb_reserved = 0;
93+
public static int nb_float = 0;
94+
public static int nb_inplace_add = 0;
95+
public static int nb_inplace_subtract = 0;
96+
public static int nb_inplace_multiply = 0;
97+
public static int nb_inplace_remainder = 0;
98+
public static int nb_inplace_power = 0;
99+
public static int nb_inplace_lshift = 0;
100+
public static int nb_inplace_rshift = 0;
101+
public static int nb_inplace_and = 0;
102+
public static int nb_inplace_xor = 0;
103+
public static int nb_inplace_or = 0;
104+
public static int nb_floor_divide = 0;
105+
public static int nb_true_divide = 0;
106+
public static int nb_inplace_floor_divide = 0;
107+
public static int nb_inplace_true_divide = 0;
108+
public static int nb_index = 0;
109+
public static int nb_matrix_multiply = 0;
110+
public static int nb_inplace_matrix_multiply = 0;
111+
public static int mp_length = 0;
112+
public static int mp_subscript = 0;
113+
public static int mp_ass_subscript = 0;
114+
public static int sq_length = 0;
115+
public static int sq_concat = 0;
116+
public static int sq_repeat = 0;
117+
public static int sq_item = 0;
118+
public static int was_sq_slice = 0;
119+
public static int sq_ass_item = 0;
120+
public static int was_sq_ass_slice = 0;
121+
public static int sq_contains = 0;
122+
public static int sq_inplace_concat = 0;
123+
public static int sq_inplace_repeat = 0;
124+
public static int bf_getbuffer = 0;
125+
public static int bf_releasebuffer = 0;
126+
public static int name = 0;
127+
public static int ht_slots = 0;
128+
public static int qualname = 0;
129+
public static int ht_cached_keys = 0;
130+
public static int ht_module = 0;
131+
132+
/* here are optional user slots, followed by the members. */
133+
public static int members = 0;
134+
}
135+
136+
[StructLayout(LayoutKind.Sequential)]
137+
internal struct PyNumberMethods
138+
{
139+
public IntPtr nb_add;
140+
public IntPtr nb_subtract;
141+
public IntPtr nb_multiply;
142+
public IntPtr nb_remainder;
143+
public IntPtr nb_divmod;
144+
public IntPtr nb_power;
145+
public IntPtr nb_negative;
146+
public IntPtr nb_positive;
147+
public IntPtr nb_absolute;
148+
public IntPtr nb_bool;
149+
public IntPtr nb_invert;
150+
public IntPtr nb_lshift;
151+
public IntPtr nb_rshift;
152+
public IntPtr nb_and;
153+
public IntPtr nb_xor;
154+
public IntPtr nb_or;
155+
public IntPtr nb_int;
156+
public IntPtr nb_reserved;
157+
public IntPtr nb_float;
158+
public IntPtr nb_inplace_add;
159+
public IntPtr nb_inplace_subtract;
160+
public IntPtr nb_inplace_multiply;
161+
public IntPtr nb_inplace_remainder;
162+
public IntPtr nb_inplace_power;
163+
public IntPtr nb_inplace_lshift;
164+
public IntPtr nb_inplace_rshift;
165+
public IntPtr nb_inplace_and;
166+
public IntPtr nb_inplace_xor;
167+
public IntPtr nb_inplace_or;
168+
public IntPtr nb_floor_divide;
169+
public IntPtr nb_true_divide;
170+
public IntPtr nb_inplace_floor_divide;
171+
public IntPtr nb_inplace_true_divide;
172+
public IntPtr nb_index;
173+
public IntPtr nb_matrix_multiply;
174+
public IntPtr nb_inplace_matrix_multiply;
175+
}
176+
177+
[StructLayout(LayoutKind.Sequential)]
178+
internal struct PySequenceMethods
179+
{
180+
public IntPtr sq_length;
181+
public IntPtr sq_concat;
182+
public IntPtr sq_repeat;
183+
public IntPtr sq_item;
184+
public IntPtr was_sq_slice;
185+
public IntPtr sq_ass_item;
186+
public IntPtr was_sq_ass_slice;
187+
public IntPtr sq_contains;
188+
public IntPtr sq_inplace_concat;
189+
public IntPtr sq_inplace_repeat;
190+
}
191+
192+
[StructLayout(LayoutKind.Sequential)]
193+
internal struct PyMappingMethods
194+
{
195+
public IntPtr mp_length;
196+
public IntPtr mp_subscript;
197+
public IntPtr mp_ass_subscript;
198+
}
199+
200+
[StructLayout(LayoutKind.Sequential)]
201+
internal struct PyAsyncMethods
202+
{
203+
public IntPtr am_await;
204+
public IntPtr am_aiter;
205+
public IntPtr am_anext;
206+
}
207+
208+
[StructLayout(LayoutKind.Sequential)]
209+
internal struct PyBufferProcs
210+
{
211+
public IntPtr bf_getbuffer;
212+
public IntPtr bf_releasebuffer;
213+
}
214+
215+
internal static partial class SlotTypes
216+
{
217+
public static readonly Type[] Types = {
218+
typeof(PyNumberMethods),
219+
typeof(PySequenceMethods),
220+
typeof(PyMappingMethods),
221+
typeof(PyAsyncMethods),
222+
typeof(PyBufferProcs),
223+
};
224+
}
225+
226+
}
227+
#endif

src/runtime/runtime.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ public class Runtime
6868
#elif PYTHON38
6969
internal const string _pyversion = "3.8";
7070
internal const string _pyver = "38";
71+
#elif PYTHON39
72+
internal const string _pyversion = "3.9";
73+
internal const string _pyver = "39";
7174
#else
72-
#error You must define one of PYTHON34 to PYTHON38 or PYTHON27
75+
#error You must define one of PYTHON34 to PYTHON39 or PYTHON27
7376
#endif
7477

7578
#if MONO_LINUX || MONO_OSX // Linux/macOS use dotted version string

0 commit comments

Comments
 (0)