Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Rebased #154

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 19 commits into from
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting branch to develop might make sense, but if you're pushing to the main repo you should keep the reference as it is ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I think we should merge into master and do a 2.1 release as soon as
the 3.5 stuff is all working and tested, so the CI build statuses should be
left as they were.

On Mon, Feb 22, 2016 at 10:43 AM Benedikt Reinartz [email protected]
wrote:

In README.md
#154 (comment):

@@ -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
+Build Status

Setting branch to develop might make sense, but if you're pushing to the
main repo you should keep the reference as it is ...


Reply to this email directly or view it on GitHub
https://github.com/pythonnet/pythonnet/pull/154/files#r53608999.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonyroberts you can see on my branch that py35 is working and tested

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is merged the same will hold for the original links :)


[![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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be any need for hardcoded paths. Not everyone will have installed the windows SDK on the C drive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonyroberts I agree, but I did not find in registry this path. also not sure if windows sdk can be installed to non-default paths?! maybe @zooba can point how this path can be mapped in more generalized way? (r"C:\Program Files (x86)\Windows Kits\8.1\bin")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing from rebase. agree with @tonyroberts
@denfromufa may need to add it to the registry.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots is where you'll find the install directories of the Windows dev kits. (In 64-bit processes on 64-bit systems it'll be HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots - easiest to try the other one first and then fall back to the longer path.)

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