Skip to content

python 3.5 support #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c945022
Append python 3.5 where needed.
sdpython Jan 16, 2016
95958bb
Logical changes from sdpython/pythonnet3
vmuriart Feb 4, 2016
d6a782b
Merge pull request #1 from pythonnet/develop
Feb 14, 2016
9745dcd
Update .travis.yml
Feb 14, 2016
343238c
Update appveyor.yml
Feb 14, 2016
94107e4
Update .travis.yml
Feb 14, 2016
ef43a0e
Merge pull request #2 from denfromufa/py35
Feb 14, 2016
3447b9a
Update README.md
Feb 14, 2016
ba6c09a
Update assemblymanager.cs
Feb 14, 2016
0cbab89
Update interop.cs
Feb 14, 2016
e43b21a
Update interop.cs
Feb 14, 2016
b869178
Update setup.py
Feb 16, 2016
0a4fa48
Update interop.cs
Feb 16, 2016
ff86811
Update test_array.py
Feb 16, 2016
bebe07f
Merge pull request #3 from pythonnet/develop
Feb 16, 2016
611eb08
Update appveyor.yml
Feb 16, 2016
f2c932b
Update appveyor.yml
Feb 16, 2016
d2a605a
Update appveyor.yml
Feb 16, 2016
66a3d9f
Update appveyor.yml
Feb 16, 2016
369849e
Update appveyor.yml
Feb 16, 2016
fdd3478
Update appveyor.yml
Feb 16, 2016
41b1971
Update appveyor.yml
Feb 16, 2016
d04f470
Update appveyor.yml
Feb 16, 2016
4118ec6
Update appveyor.yml
Feb 16, 2016
7f10493
Update appveyor.yml
Feb 16, 2016
933f208
Update appveyor.yml
Feb 16, 2016
da58cb8
Update appveyor.yml
Feb 16, 2016
08881f6
Update appveyor.yml
Feb 16, 2016
8e21ea1
Update appveyor.yml
Feb 16, 2016
0b7e3f1
Update appveyor.yml
Feb 16, 2016
32859d4
Update appveyor.yml
Feb 16, 2016
e3cca0b
Update appveyor.yml
Feb 16, 2016
593afab
Update appveyor.yml
Feb 17, 2016
a0d59b7
Update appveyor.yml
Feb 17, 2016
0d2b846
Update appveyor.yml
Feb 17, 2016
1fe46b6
Update appveyor.yml
Feb 17, 2016
537a315
Update appveyor.yml
Feb 17, 2016
52fcbbb
Update appveyor.yml
Feb 17, 2016
756aaa0
Update appveyor.yml
Feb 17, 2016
5986077
Update appveyor.yml
Feb 17, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python:
- 2.7
- 3.2
- 3.4
- 3.5
before_install:
- sudo apt-get install software-properties-common
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pythonnet

Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers. It allows Python code to interact with the CLR, and may also be used to embed Python into a .NET application.

[![Build Status](https://travis-ci.org/pythonnet/pythonnet.png?branch=master)](https://travis-ci.org/pythonnet/pythonnet)
[![Build Status](https://travis-ci.org/denfromufa/pythonnet.png?branch=develop)](https://travis-ci.org/denfromufa/pythonnet)

[![Build status](https://ci.appveyor.com/api/projects/status/c8k0miljb3n1c7be/branch/master)](https://ci.appveyor.com/project/TonyRoberts/pythonnet-480xs)
[![Build status](https://ci.appveyor.com/api/projects/status/c8k0miljb3n1c7be/branch/master)](https://ci.appveyor.com/project/denfromufa/pythonnet)

**Calling .NET code from Python**

Expand Down
44 changes: 25 additions & 19 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,37 @@ environment:
global:
PYTHONPATH: c:\testdir
PYTHONWARNINGS: 'ignore:::pip.pep425tags:'
PIPURL: https://bootstrap.pypa.io/get-pip.py

matrix:
- pythonurl: http://www.python.org/ftp/python/2.7.6/python-2.7.6.amd64.msi
- pythonurl: http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi
- pythonurl: http://www.python.org/ftp/python/3.3.5/python-3.3.5.msi
- pythonurl: http://www.python.org/ftp/python/3.3.5/python-3.3.5.amd64.msi
- pythonurl: http://www.python.org/ftp/python/3.4.2/python-3.4.2.msi
- pythonurl: http://www.python.org/ftp/python/3.4.2/python-3.4.2.amd64.msi

# For Python versions available on Appveyor, see
# http://www.appveyor.com/docs/installed-software#python
# The list here is complete (excluding Python 2.6, which
# isn't covered by this document) at the time of writing.

- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python33"
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python33-x64"
DISTUTILS_USE_SDK: "1"
- PYTHON: "C:\\Python34-x64"
DISTUTILS_USE_SDK: "1"
- PYTHON: "C:\\Python35-x64"

install:
- ps: (new-object net.webclient).DownloadFile($env:pythonurl, 'C:\python.msi')
- ps: start-process -wait -FilePath msiexec.exe -ArgumentList '/qn /x C:\python.msi TARGETDIR=C:\Python'
- ps: start-process -wait -FilePath msiexec.exe -ArgumentList '/qn /i C:\python.msi TARGETDIR=C:\Python'
- ps: (new-object net.webclient).DownloadFile($env:PIPURL, 'C:\get-pip.py')
- C:\Python\python.exe --version
- C:\Python\python.exe c:\get-pip.py
- C:\Python\Scripts\pip.exe install wheel
- C:\Python\Scripts\pip.exe install six
# We need wheel installed to build wheels
- "%PYTHON%\\python -m pip install --upgrade pip"
- "%PYTHON%\\python.exe -m pip install wheel"
- "%PYTHON%\\python.exe -m pip install six"

build_script:
- C:\python\python.exe setup.py bdist_wheel
- "%PYTHON%\\python.exe setup.py bdist_wheel"

test_script:
- ps: C:\Python\Scripts\pip.exe install --no-cache-dir --force-reinstall --ignore-installed ('dist\' + (gci dist)[0].Name)
- cd "%PYTHON%"
- ps: Scripts\pip.exe install --no-cache-dir --force-reinstall --ignore-installed ('C:\\projects\\pythonnet\\dist\\' + (gci C:\projects\pythonnet\dist)[0].Name)
- cd C:\projects\pythonnet
- mkdir c:\testdir
- ps: copy-item (gci -path build -re -include Python.Test.dll)[0].FullName c:\testdir
- c:\python\python.exe src\tests\runtests.py
- "%PYTHON%\\python.exe src\\tests\\runtests.py"
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ def _find_msbuild_tool(tool="msbuild.exe", use_windows_sdk=False):
locappdir, vcpy27, r"x64\mt.exe")
if os.path.exists(mtpath):
return mtpath
if sys.version_info[:2] == (3,5):
vcpy35 = (r"C:\Program Files (x86)\Windows Kits\8.1\bin")
if PLATFORM == "x86":
mtpath = os.path.join(
vcpy35, r"x86\mt.exe")
elif PLATFORM == "x64":
mtpath = os.path.join(
vcpy35, r"x64\mt.exe")
if os.path.exists(mtpath):
return mtpath
else:
print (mtpath)
value_name = "InstallationFolder"
sdk_name = "Windows SDK"
keys_to_check = [
Expand Down Expand Up @@ -304,6 +316,7 @@ def _check_output(*popenargs, **kwargs):
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: C#',
'License :: OSI Approved :: Zope Public License',
'Development Status :: 5 - Production/Stable',
Expand Down
6 changes: 3 additions & 3 deletions src/clrmodule/ClrModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class clrModule
// ReSharper restore CheckNamespace
{
// ReSharper disable InconsistentNaming
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
[RGiesecke.DllExport.DllExport("PyInit_clr", System.Runtime.InteropServices.CallingConvention.StdCall)]
public static IntPtr PyInit_clr()
#else
Expand Down Expand Up @@ -107,7 +107,7 @@ public static void initclr()
#if DEBUG_PRINT
System.Console.WriteLine("Could not load Python.Runtime, so sad.");
#endif
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
return IntPtr.Zero;
#else
return;
Expand All @@ -119,7 +119,7 @@ public static void initclr()
// So now we get the PythonEngine and execute the InitExt method on it.
var pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine");

#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
return (IntPtr)pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
#else
pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/classbase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public virtual IntPtr type_subscript(IntPtr idx) {
//====================================================================
// Standard comparison implementation for instances of reflected types.
//====================================================================
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) {
if (op != Runtime.Py_EQ && op != Runtime.Py_NE)
{
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.Int32:
#if !(PYTHON32 || PYTHON33 || PYTHON34)
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
// Trickery to support 64-bit platforms.
if (IntPtr.Size == 4) {
op = Runtime.PyNumber_Int(value);
Expand Down Expand Up @@ -456,7 +456,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.Byte:
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType))
{
if (Runtime.PyBytes_Size(value) == 1)
Expand Down Expand Up @@ -496,7 +496,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.SByte:
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) {
if (Runtime.PyBytes_Size(value) == 1) {
op = Runtime.PyBytes_AS_STRING(value);
Expand Down Expand Up @@ -534,7 +534,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.Char:
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) {
if (Runtime.PyBytes_Size(value) == 1) {
op = Runtime.PyBytes_AS_STRING(value);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/delegateobject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) {
//====================================================================
// Implements __cmp__ for reflected delegate types.
//====================================================================
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static new IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) {
if (op != Runtime.Py_EQ && op != Runtime.Py_NE)
{
Expand Down
14 changes: 7 additions & 7 deletions src/runtime/exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class ExceptionClassObject : ClassObject {
internal ExceptionClassObject(Type tp) : base(tp) {
}

#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
internal static Exception ToException(IntPtr ob) {
CLRObject co = GetManagedObject(ob) as CLRObject;
if (co == null) {
Expand Down Expand Up @@ -114,7 +114,7 @@ public static IntPtr tp_getattro(IntPtr ob, IntPtr key)

return Runtime.PyObject_GenericGetAttr(ob, key);
}
#endif // (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#endif // (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
}

/// <summary>
Expand All @@ -136,7 +136,7 @@ private Exceptions() {}
//===================================================================

internal static void Initialize() {
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
exceptions_module = Runtime.PyImport_ImportModule("builtins");
#else
exceptions_module = Runtime.PyImport_ImportModule("exceptions");
Expand Down Expand Up @@ -572,15 +572,15 @@ internal static IntPtr RaiseTypeError(string message) {
puplic static variables on the Exceptions class filled in from
the python class using reflection in Initialize() looked up by
name, not posistion. */
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr BaseException;
#endif
public static IntPtr Exception;
public static IntPtr StopIteration;
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr GeneratorExit;
#endif
#if !(PYTHON32 || PYTHON33 || PYTHON34)
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr StandardError;
#endif
public static IntPtr ArithmeticError;
Expand Down Expand Up @@ -637,7 +637,7 @@ puplic static variables on the Exceptions class filled in from
public static IntPtr SyntaxWarning;
public static IntPtr RuntimeWarning;
public static IntPtr FutureWarning;
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr ImportWarning;
public static IntPtr UnicodeWarning;
//PyAPI_DATA(PyObject *) PyExc_BytesWarning;
Expand Down
15 changes: 10 additions & 5 deletions src/runtime/importhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class ImportHook {
static CLRModule root;
static MethodWrapper hook;

#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
static IntPtr py_clr_module;
static IntPtr module_def;
#endif
Expand All @@ -38,7 +38,7 @@ internal static void Initialize() {
// but it provides the most "Pythonic" way of dealing with CLR
// modules (Python doesn't provide a way to emulate packages).
IntPtr dict = Runtime.PyImport_GetModuleDict();
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
IntPtr mod = Runtime.PyImport_ImportModule("builtins");
py_import = Runtime.PyObject_GetAttrString(mod, "__import__");
#else
Expand All @@ -51,10 +51,15 @@ internal static void Initialize() {

root = new CLRModule();

#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
// create a python module with the same methods as the clr module-like object
module_def = ModuleDefOffset.AllocModuleDef("clr");

#if (Py_TRACE_REFS && PYTHON35)
py_clr_module = Runtime.PyModule_FromDefAndSpec2(module_def, (IntPtr)null, 3);
#else
py_clr_module = Runtime.PyModule_Create2(module_def, 3);
#endif

// both dicts are borrowed references
IntPtr mod_dict = Runtime.PyModule_GetDict(py_clr_module);
Expand All @@ -78,7 +83,7 @@ internal static void Initialize() {
//===================================================================

internal static void Shutdown() {
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
if (0 != Runtime.Py_IsInitialized()) {
Runtime.Decref(py_clr_module);
Runtime.Decref(root.pyHandle);
Expand All @@ -100,7 +105,7 @@ internal static void Shutdown() {
//===================================================================
public static IntPtr GetCLRModule(IntPtr? fromList=null) {
root.InitializePreload();
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
// update the module dictionary with the contents of the root dictionary
root.LoadNames();
IntPtr py_mod_dict = Runtime.PyModule_GetDict(py_clr_module);
Expand Down
Loading