Skip to content

Commit 08344b7

Browse files
authored
Official python 3.7 support (#698)
* Create interop37.cs * try faking minimal crypt.h * Update appveyor.yml * Update test_exceptions.py * official python 3.7 on travis CI, but xenial with sudo * xenial support for mono and .netcore * Update .travis.yml * passing pthread support to clang based on: https://stackoverflow.com/questions/2391194/what-is-gs-pthread-equiv-in-clang * Update geninterop.py
2 parents 784190a + 222874c commit 08344b7

File tree

10 files changed

+196
-21
lines changed

10 files changed

+196
-21
lines changed

.travis.yml

+29-10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ matrix:
2222
- dotnet-hostfxr-2.0.0
2323
- dotnet-runtime-2.0.0
2424
- dotnet-sdk-2.0.0
25+
2526
- python: 3.4
2627
env: *xplat-env
2728
addons: *xplat-addons
@@ -33,9 +34,24 @@ matrix:
3334
- python: 3.6
3435
env: *xplat-env
3536
addons: *xplat-addons
36-
- python: "3.7-dev"
37+
38+
- python: 3.7
3739
env: *xplat-env
38-
addons: *xplat-addons
40+
dist: xenial
41+
sudo: true
42+
addons: &xplat-addons-xenial
43+
apt:
44+
sources:
45+
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main
46+
key_url: https://packages.microsoft.com/keys/microsoft.asc
47+
- sourceline: deb https://download.mono-project.com/repo/ubuntu stable-xenial main
48+
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
49+
packages:
50+
- mono-devel
51+
- ca-certificates-mono
52+
- dotnet-hostfxr-2.0.0
53+
- dotnet-runtime-2.0.0
54+
- dotnet-sdk-2.0.0
3955

4056
# --------------------- Classic builds ------------------------
4157
- python: 2.7
@@ -52,15 +68,18 @@ matrix:
5268
- python: 3.6
5369
env: *classic-env
5470

55-
- python: "3.7-dev"
56-
env: *classic-env
57-
58-
allow_failures:
59-
- python: "3.7-dev"
60-
env: *xplat-env
61-
62-
- python: "3.7-dev"
71+
- python: 3.7
6372
env: *classic-env
73+
dist: xenial
74+
sudo: true
75+
addons:
76+
apt:
77+
sources:
78+
- sourceline: deb http://download.mono-project.com/repo/ubuntu xenial main
79+
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
80+
packages:
81+
- mono-devel
82+
- ca-certificates-mono
6483

6584
env:
6685
global:

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
2020
- Implemented GetDynamicMemberNames() for PyObject to allow dynamic object members to be visible in the debugger ([#443][i443])([#690][p690])
2121
- Incorporated reference-style links to issues and pull requests in the CHANGELOG ([#608][i608])
2222
- Added detailed comments about aproaches and dangers to handle multi-app-domains ([#625][p625])
23+
- Python 3.7 support, builds and testing added. Defaults changed from Python 3.6 to 3.7 ([#698][p698])
2324

2425
### Changed
2526

appveyor.yml

+3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ environment:
2323
BUILD_OPTS: --xplat
2424
- PYTHON_VERSION: 3.6
2525
BUILD_OPTS: --xplat
26+
- PYTHON_VERSION: 3.7
27+
BUILD_OPTS: --xplat
2628
- PYTHON_VERSION: 2.7
2729
- PYTHON_VERSION: 3.4
2830
- PYTHON_VERSION: 3.5
2931
- PYTHON_VERSION: 3.6
32+
- PYTHON_VERSION: 3.7
3033

3134
matrix:
3235
allow_failures:

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Allow config/verbosity to be set from cli
2323
# http://stackoverflow.com/a/4792601/5208670
2424
CONFIG = "Release" # Release or Debug
25-
VERBOSITY = "minimal" # quiet, minimal, normal, detailed, diagnostic
25+
VERBOSITY = "normal" # quiet, minimal, normal, detailed, diagnostic
2626

2727
is_64bits = sys.maxsize > 2**32
2828
DEVTOOLS = "MsDev" if sys.platform == "win32" else "Mono"
@@ -516,10 +516,10 @@ def run(self):
516516
'Programming Language :: Python :: 2',
517517
'Programming Language :: Python :: 2.7',
518518
'Programming Language :: Python :: 3',
519-
'Programming Language :: Python :: 3.3',
520519
'Programming Language :: Python :: 3.4',
521520
'Programming Language :: Python :: 3.5',
522521
'Programming Language :: Python :: 3.6',
522+
'Programming Language :: Python :: 3.7',
523523
'Operating System :: Microsoft :: Windows',
524524
'Operating System :: POSIX :: Linux',
525525
'Operating System :: MacOS :: MacOS X',

src/runtime/Python.Runtime.15.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<Python2Version>$(PYTHONNET_PY2_VERSION)</Python2Version>
3636
<Python2Version Condition="'$(Python2Version)'==''">PYTHON27</Python2Version>
3737
<Python3Version>$(PYTHONNET_PY3_VERSION)</Python3Version>
38-
<Python3Version Condition="'$(Python3Version)'==''">PYTHON36</Python3Version>
38+
<Python3Version Condition="'$(Python3Version)'==''">PYTHON37</Python3Version>
3939
<PythonWinDefineConstants>$(PYTHONNET_WIN_DEFINE_CONSTANTS)</PythonWinDefineConstants>
4040
<PythonWinDefineConstants Condition="'$(PythonWinDefineConstants)'==''">UCS2</PythonWinDefineConstants>
4141
<PythonMonoDefineConstants>$(PYTHONNET_MONO_DEFINE_CONSTANTS)</PythonMonoDefineConstants>

src/runtime/Python.Runtime.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<DebugType>pdbonly</DebugType>
3535
</PropertyGroup>
3636
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMonoPY3'">
37-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON36;UCS4</DefineConstants>
37+
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON37;UCS4</DefineConstants>
3838
<Optimize>true</Optimize>
3939
<DebugType>pdbonly</DebugType>
4040
</PropertyGroup>
@@ -46,7 +46,7 @@
4646
</PropertyGroup>
4747
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMonoPY3'">
4848
<DebugSymbols>true</DebugSymbols>
49-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON36;UCS4;TRACE;DEBUG</DefineConstants>
49+
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON37;UCS4;TRACE;DEBUG</DefineConstants>
5050
<Optimize>false</Optimize>
5151
<DebugType>full</DebugType>
5252
</PropertyGroup>
@@ -56,7 +56,7 @@
5656
<DebugType>pdbonly</DebugType>
5757
</PropertyGroup>
5858
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWinPY3'">
59-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON36;UCS2</DefineConstants>
59+
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON37;UCS2</DefineConstants>
6060
<Optimize>true</Optimize>
6161
<DebugType>pdbonly</DebugType>
6262
</PropertyGroup>
@@ -68,7 +68,7 @@
6868
</PropertyGroup>
6969
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWinPY3'">
7070
<DebugSymbols>true</DebugSymbols>
71-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON36;UCS2;TRACE;DEBUG</DefineConstants>
71+
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON37;UCS2;TRACE;DEBUG</DefineConstants>
7272
<Optimize>false</Optimize>
7373
<DebugType>full</DebugType>
7474
</PropertyGroup>
@@ -166,4 +166,4 @@
166166
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
167167
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
168168
</Target>
169-
</Project>
169+
</Project>

src/runtime/interop37.cs

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// Auto-generated by geninterop.py.
2+
// DO NOT MODIFIY BY HAND.
3+
4+
5+
#if PYTHON37
6+
using System;
7+
using System.Collections;
8+
using System.Collections.Specialized;
9+
using System.Runtime.InteropServices;
10+
using System.Reflection;
11+
using System.Text;
12+
13+
namespace Python.Runtime
14+
{
15+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
16+
internal class TypeOffset
17+
{
18+
static TypeOffset()
19+
{
20+
Type type = typeof(TypeOffset);
21+
FieldInfo[] fi = type.GetFields();
22+
int size = IntPtr.Size;
23+
for (int i = 0; i < fi.Length; i++)
24+
{
25+
fi[i].SetValue(null, i * size);
26+
}
27+
}
28+
29+
public static int magic()
30+
{
31+
return ob_size;
32+
}
33+
34+
// Auto-generated from PyHeapTypeObject in Python.h
35+
public static int ob_refcnt = 0;
36+
public static int ob_type = 0;
37+
public static int ob_size = 0;
38+
public static int tp_name = 0;
39+
public static int tp_basicsize = 0;
40+
public static int tp_itemsize = 0;
41+
public static int tp_dealloc = 0;
42+
public static int tp_print = 0;
43+
public static int tp_getattr = 0;
44+
public static int tp_setattr = 0;
45+
public static int tp_as_async = 0;
46+
public static int tp_repr = 0;
47+
public static int tp_as_number = 0;
48+
public static int tp_as_sequence = 0;
49+
public static int tp_as_mapping = 0;
50+
public static int tp_hash = 0;
51+
public static int tp_call = 0;
52+
public static int tp_str = 0;
53+
public static int tp_getattro = 0;
54+
public static int tp_setattro = 0;
55+
public static int tp_as_buffer = 0;
56+
public static int tp_flags = 0;
57+
public static int tp_doc = 0;
58+
public static int tp_traverse = 0;
59+
public static int tp_clear = 0;
60+
public static int tp_richcompare = 0;
61+
public static int tp_weaklistoffset = 0;
62+
public static int tp_iter = 0;
63+
public static int tp_iternext = 0;
64+
public static int tp_methods = 0;
65+
public static int tp_members = 0;
66+
public static int tp_getset = 0;
67+
public static int tp_base = 0;
68+
public static int tp_dict = 0;
69+
public static int tp_descr_get = 0;
70+
public static int tp_descr_set = 0;
71+
public static int tp_dictoffset = 0;
72+
public static int tp_init = 0;
73+
public static int tp_alloc = 0;
74+
public static int tp_new = 0;
75+
public static int tp_free = 0;
76+
public static int tp_is_gc = 0;
77+
public static int tp_bases = 0;
78+
public static int tp_mro = 0;
79+
public static int tp_cache = 0;
80+
public static int tp_subclasses = 0;
81+
public static int tp_weaklist = 0;
82+
public static int tp_del = 0;
83+
public static int tp_version_tag = 0;
84+
public static int tp_finalize = 0;
85+
public static int am_await = 0;
86+
public static int am_aiter = 0;
87+
public static int am_anext = 0;
88+
public static int nb_add = 0;
89+
public static int nb_subtract = 0;
90+
public static int nb_multiply = 0;
91+
public static int nb_remainder = 0;
92+
public static int nb_divmod = 0;
93+
public static int nb_power = 0;
94+
public static int nb_negative = 0;
95+
public static int nb_positive = 0;
96+
public static int nb_absolute = 0;
97+
public static int nb_bool = 0;
98+
public static int nb_invert = 0;
99+
public static int nb_lshift = 0;
100+
public static int nb_rshift = 0;
101+
public static int nb_and = 0;
102+
public static int nb_xor = 0;
103+
public static int nb_or = 0;
104+
public static int nb_int = 0;
105+
public static int nb_reserved = 0;
106+
public static int nb_float = 0;
107+
public static int nb_inplace_add = 0;
108+
public static int nb_inplace_subtract = 0;
109+
public static int nb_inplace_multiply = 0;
110+
public static int nb_inplace_remainder = 0;
111+
public static int nb_inplace_power = 0;
112+
public static int nb_inplace_lshift = 0;
113+
public static int nb_inplace_rshift = 0;
114+
public static int nb_inplace_and = 0;
115+
public static int nb_inplace_xor = 0;
116+
public static int nb_inplace_or = 0;
117+
public static int nb_floor_divide = 0;
118+
public static int nb_true_divide = 0;
119+
public static int nb_inplace_floor_divide = 0;
120+
public static int nb_inplace_true_divide = 0;
121+
public static int nb_index = 0;
122+
public static int nb_matrix_multiply = 0;
123+
public static int nb_inplace_matrix_multiply = 0;
124+
public static int mp_length = 0;
125+
public static int mp_subscript = 0;
126+
public static int mp_ass_subscript = 0;
127+
public static int sq_length = 0;
128+
public static int sq_concat = 0;
129+
public static int sq_repeat = 0;
130+
public static int sq_item = 0;
131+
public static int was_sq_slice = 0;
132+
public static int sq_ass_item = 0;
133+
public static int was_sq_ass_slice = 0;
134+
public static int sq_contains = 0;
135+
public static int sq_inplace_concat = 0;
136+
public static int sq_inplace_repeat = 0;
137+
public static int bf_getbuffer = 0;
138+
public static int bf_releasebuffer = 0;
139+
public static int name = 0;
140+
public static int ht_slots = 0;
141+
public static int qualname = 0;
142+
public static int ht_cached_keys = 0;
143+
144+
/* here are optional user slots, followed by the members. */
145+
public static int members = 0;
146+
}
147+
}
148+
149+
#endif

src/tests/test_exceptions.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ def test_python_compat_of_managed_exceptions():
289289
assert e.args == (msg,)
290290
assert isinstance(e.args, tuple)
291291
if PY3:
292-
assert repr(e) == "OverflowException('Simple message',)"
292+
strexp = "OverflowException('Simple message"
293+
assert repr(e)[:len(strexp)] == strexp
293294
elif PY2:
294295
assert repr(e) == "OverflowException(u'Simple message',)"
295296

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "features.h"

tools/geninterop/geninterop.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ def preprocess_python_headers():
173173
"-D", "__attribute__(x)=",
174174
"-D", "__inline__=inline",
175175
"-D", "__asm__=;#pragma asm",
176-
"-D", "__int64=long long"
176+
"-D", "__int64=long long",
177+
"-D", "_POSIX_THREADS"
177178
]
178179

179180
if hasattr(sys, "abiflags"):
@@ -185,7 +186,7 @@ def preprocess_python_headers():
185186
defines.extend(("-D", "PYTHON_WITH_WIDE_UNICODE"))
186187

187188
python_h = os.path.join(include_py, "Python.h")
188-
cmd = ["clang", "-I"] + include_dirs + defines + ["-E", python_h]
189+
cmd = ["clang", "-pthread", "-I"] + include_dirs + defines + ["-E", python_h]
189190

190191
# normalize as the parser doesn't like windows line endings.
191192
lines = []

0 commit comments

Comments
 (0)