Closed fdanny closed 8 years ago
I'd like this as well.
I just submitted a pull request with initial Python 3.5 support.
Did the pull request https://github.com/pythonnet/pythonnet/pull/104 go thru? Can we close this issue?
The pull request seems to have been closed without merging.
Any news on the python 3.5 support? I would love to use Python.NET with the current Python version.
Very weird - that pull request points to an unknown branch
There is a blog post about 3.5: http://www.xavierdupre.fr/app/pymyinstall/helpsphinx/blog/2016/2016-01-03_pythonnet.html
Looks like this branch can be merged:
From reading the blog it seems that it still has a few issues to resolve
On Wednesday, January 27, 2016, denfromufa notifications@github.com wrote:
Looks like this branch can be merged:
https://github.com/sdpython/pythonnet3
— Reply to this email directly or view it on GitHub https://github.com/pythonnet/pythonnet/issues/103#issuecomment-175723460 .
@denfromufa I'd like to withdraw my earlier statement, I reread the blog and looks like I misunderstood the issue. He had a built issue that he mentioned.
I took a look at the src and compared it to the earlier pr that was submitted. sdpython's looks alot more complete as it integrates the new 3.5 features.
@tonyroberts any reason this can't be merged (other than no existing pull request :smile_cat: )
@vmuriart would be great if you could test and create a PR. Please make sure you add 3.5 builds to the travis and appveyor CI builds.
@fdanny @mahibra @BrisingrAerowing try this branch until it is merged:
https://github.com/denfromufa/pythonnet/tree/develop
only one very weird test case is failing on travis ci, hence I commented out it for now.
appveyor needs some updates for python 3.5, but I tested locally on my windows 7 machine.
Hi, I just tried to install pythonnet from your develop branch. I used Anaconda 2.5 (Python 3.5.1) in combintation with Visual Studio Express 2015 and ran
python setup.py install
To get pythonnet running I had to manually copy all files from the build/lib.win-amd64-3.5 folder to the anaconda install path. Afterwards I was able to import clr.
The two demo files helloform.py and splitter.py seem to run correctly. However, the file wordpad.py exits with the following error:
[Anaconda35] c:\JLINK_64\software\pythonnet-develop\demo>python wordpad.py
Traceback (most recent call last):
File "wordpad.py", line 430, in
Additionally I connected to the proprietary .NET API I used successfully with python 3.4 and pythonnet. Here I get an error when running a function which uses output variables. According to the C# API documentation the function takes the following arguments:
bool ReadNextResult( out int rayNumber, out int errorCode, out int vignetteCode, out double X, out double Y, out double Z, out double L, out double M, out double N, out double opd, out double l2, out double m2, out double n2, out double intensity )
With Python 3.4 and the pythonnet package from pypi, I was able to call this function in the following way:
out = BatchRayTrace.ReadNextResult(0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
with Python 3.5 and the pythonnet version built from your develop branch I get the following error:
Traceback (most recent call last):
File "
File "C:\JLINK_64\software\Anaconda35\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile execfile(filename, namespace)
File "C:\JLINK_64\software\Anaconda35\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 88, in execfile exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "C:/JLINK_64/workspace/ZOS/PythonNet_ZOS_Raytrace.py", line 94, in
@mahibra can you edit your comment with code blocks according to github markdown:
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
python setup.py install
is not supported, instead first you need to build a wheel
and then install it e.g. usingpip
.
all 3 demos work on python 3.5, 32bit, perhaps this is specific to 64bit python or your installation. The appveyor CI is not failing on 64bit python 3.5 for the tests. the demos are not setup for testing on appveyor.
Here is python 3.5 I tested this on locally:
Python 3.5.1 |Continuum Analytics, Inc.| (default, Jan 29 2016, 15:46:01) [MSC v
.1900 32 bit (Intel)] on win32
once you build the wheel and install it, copy Python.Test.dll
to your ..\lib\site-packages
folder and then run the tests from pythonnet source folder: python src\tests\runtests.py
i got the same error if I use wrong python version (2.7) to run wordpad.py
, which suggests that you may have similar problem with activated conda environment, so try building debug version of pythonnet from VS2015 and see where pythonnet is loading from:
[py35] C:\pythonnet\pythonnet35\demo>python helloform.py
Attempting to load Python.Runtime using standard binding rules...
Attempting to load Python.Runtime from: 'C:\Python\Python27\envs\py35\lib\site-p
ackages\Python.Runtime.dll'...
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b7
7a5c561934e089\System.Windows.Forms.dll
form created
app referenced
and failing case due to my stupid mistake:
[py35] C:\pythonnet\pythonnet35\demo>wordpad.py
Attempting to load Python.Runtime using standard binding rules...
Attempting to load Python.Runtime from: 'C:\Python\Python27\lib\site-packages\Py
thon.Runtime.dll'...
Traceback (most recent call last):
File "C:\pythonnet\pythonnet35\demo\wordpad.py", line 430, in <module>
main()
File "C:\pythonnet\pythonnet35\demo\wordpad.py", line 425, in main
app = Wordpad()
File "C:\pythonnet\pythonnet35\demo\wordpad.py", line 25, in __init__
self.InitializeComponent()
File "C:\pythonnet\pythonnet35\demo\wordpad.py", line 208, in InitializeCompon
ent
self.richTextBox.Font = System.Drawing.Font("Tahoma", 10)
TypeError: no constructor matches given arguments
[py35] C:\pythonnet\pythonnet35\demo>python splitter.py
Attempting to load Python.Runtime using standard binding rules...
Attempting to load Python.Runtime from: 'C:\Python\Python27\envs\py35\lib\site-p
ackages\Python.Runtime.dll'...
regarding your overloading failure, this is most likely due to this commit, so try the develop branch before that merge:
I could not reproduce your overloading problem with both static and instance methods:
C:\Python\Python27_64b>Scripts\activate.bat py35
Activating environment "C:\Python\Python27_64b\envs\py35"...
[py35] C:\Python\Python27_64b>cd env
The system cannot find the path specified.
[py35] C:\Python\Python27_64b>cd envs
[py35] C:\Python\Python27_64b\envs>cd py35
[py35] C:\Python\Python27_64b\envs\py35>python
Python 3.5.1 |Continuum Analytics, Inc.| (default, Jan 29 2016, 15:01:46) [MSC v
.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference(r"C:\Users\denis.akhiyarov\Documents\visual studio 2015\Pro
jects\ClassLibrary2\ClassLibrary2\bin\Debug\ClassLibrary2.dll")
<System.Reflection.RuntimeAssembly object at 0x0000000002DD5390>
>>> import ClassLibrary2
>>> import ClassLibrary2 as cl2
>>> dir(cl2)
['Class1', '__class__', '__delattr__', '__delete__', '__dir__', '__doc__', '__eq
__', '__file__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__
', '__init__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__'
, '__reduce__', '__reduce_ex__', '__repr__', '__set__', '__setattr__', '__sizeof
__', '__str__', '__subclasshook__']
>>> dir(cl2.Class1)
['Equals', 'Finalize', 'GetHashCode', 'GetType', 'MemberwiseClone', 'Overloads',
'ReadNextResult', 'ReferenceEquals', 'ToString', '__call__', '__class__', '__de
lattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__',
'__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__'
, '__le__', '__lt__', '__module__', '__ne__', '__new__', '__overloads__', '__red
uce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__',
'__str__', '__subclasshook__']
>>> cl2.Class1.Overloads
ClassLibrary2.Class1()
>>> cl2.Class1.ReadNextResult
<unbound method 'ReadNextResult'>
>>> cl2.Class1.ReadNextResult(0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
... 0.0, 0.0, 0.0, 0.0, 0.0)
14
[py35] C:\Python\Python27_64b\envs\py35>python
Python 3.5.1 |Continuum Analytics, Inc.| (default, Jan 29 2016, 15:01:46) [MSC v
.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference(r"C:\Users\denis.akhiyarov\Documents\visual studio 2015\Pro
jects\ClassLibrary2\ClassLibrary1\bin\Debug\ClassLibrary1.dll")
<System.Reflection.RuntimeAssembly object at 0x0000000002CA5390>
>>> import ClassLibrary1 as cl1
>>> dir(cl2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cl2' is not defined
>>> dir(cl1)
['Class1', '__class__', '__delattr__', '__delete__', '__dir__', '__doc__', '__eq
__', '__file__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__
', '__init__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__'
, '__reduce__', '__reduce_ex__', '__repr__', '__set__', '__setattr__', '__sizeof
__', '__str__', '__subclasshook__']
>>> dir(cl1.Class1)
['Equals', 'Finalize', 'GetHashCode', 'GetType', 'MemberwiseClone', 'Overloads',
'ReadNextResult', 'ReferenceEquals', 'ToString', '__call__', '__class__', '__de
lattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__',
'__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__'
, '__le__', '__lt__', '__module__', '__ne__', '__new__', '__overloads__', '__red
uce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__',
'__str__', '__subclasshook__']
>>> cl2.Class1.ReadNextResult
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cl2' is not defined
>>> cl1.Class1.ReadNextResult
<unbound method 'ReadNextResult'>
>>> cl1inst = cl1.Class1()
>>> cl1inst.ReadNextResult
<bound method 'ReadNextResult'>
>>> cl1inst.ReadNextResult(0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
... 0.0, 0.0, 0.0, 0.0, 0.0)
14
C# code for both classes:
using System;
namespace ClassLibrary1
{
public class Class1
{
public Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Int32 ByRef3, Int32 ByRef4)
{
return 4;
}
public Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Double ByRef3, Double
ByRef4, Double ByRef5, Double ByRef6, Double ByRef7, Double ByRef8, Double ByRef9)
{
return 9;
}
public Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Int32 ByRef3, Double ByRef4,
Double ByRef5, Double ByRef6, Double ByRef7, Double ByRef8, Double ByRef9,
Double ByRef10)
{
return 10;
}
public Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Int32 ByRef3, Double ByRef4,
Double ByRef5, Double ByRef6, Double ByRef7, Double ByRef8, Double ByRef9,
Double ByRef10, Double ByRef11, Double ByRef12, Double ByRef13)
{
return 13;
}
public Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Int32 ByRef3, Double ByRef4,
Double ByRef5, Double ByRef6, Double ByRef7, Double ByRef8, Double ByRef9,
Double ByRef10, Double ByRef11, Double ByRef12, Double ByRef13, Double ByRef14)
{
return 14;
}
}
}
using System;
namespace ClassLibrary2
{
public class Class1
{
public static Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Int32 ByRef3, Int32 ByRef4)
{
return 4;
}
public static Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Double ByRef3, Double
ByRef4, Double ByRef5, Double ByRef6, Double ByRef7, Double ByRef8, Double ByRef9)
{
return 9;
}
public static Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Int32 ByRef3, Double ByRef4,
Double ByRef5, Double ByRef6, Double ByRef7, Double ByRef8, Double ByRef9,
Double ByRef10)
{
return 10;
}
public static Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Int32 ByRef3, Double ByRef4,
Double ByRef5, Double ByRef6, Double ByRef7, Double ByRef8, Double ByRef9,
Double ByRef10, Double ByRef11, Double ByRef12, Double ByRef13)
{
return 13;
}
public static Int32 ReadNextResult(Int32 ByRef1, Int32 ByRef2, Int32 ByRef3, Double ByRef4,
Double ByRef5, Double ByRef6, Double ByRef7, Double ByRef8, Double ByRef9,
Double ByRef10, Double ByRef11, Double ByRef12, Double ByRef13, Double ByRef14)
{
return 14;
}
}
}
@denfromufa Thank you very much for the instantaneous help!
Replacing methodbinder.cs with the state before commit #151 fixed both my issues with the third party API and with the wordpad.py demo file.
I tried to build a wheel by running
python setup.py bdist_wheel
which gives the following output in the last line:
creating build\bdist.win-amd64\wheel\pythonnet-2.1.0.dev1.dist-info\WHEEL
However, the folder build\bdist.win-amd64\
is empty.
I also tried to use code blocks in yesterday's messge which does not work while this comment is formatted correctly.
@mahibra I'm glad that your overloading problem is resolved, although temporarily. Can you share the complete code that can be reproduced to fix this overloading exception? As you can see above - my c# snippet does not reproduce this problem.
wordpad.py should not be affected by my commit #151 at all. I could NOT reproduce this problem with both python 3.5 32bit & 64bit on my latest develop branch.
@mahibra once you build the wheel, its location is .\dist
folder, not the .\build
folder.
@denfromufa You are correct, I found the wheel in the .\dist folder. From my perspective, it does not make sense to share the code which caused the overload error. It can only be used with the commercial program ZEMAX OpticStudio. This software requires a hardware dongle and the source code of the API is not publicly available.
Interesingly, I found a similar overloaded method in the same API which works with the newer version of methodbinder.cs.
This is now done. @denfromufa @vmuriart see PR 163 for details. Note that unlike the previous attempts this builds the TypeOffset class from the python headers, and so the order of the struct members is now correct (in the previous PRs there seemed to be a lot of confusion and errors in that area). For the most usual Python configurations I've checked in the auto generated code, but if you are using something else (e.g. Python built with Py_DEBUG) then setup.py will attempt to generate the correct class, which requires clang to be installed. All tests are passing without modification.
@tonyroberts sweet. Thanks for getting this closed. Just looked over the code, I didn't see where you are specifying which Interop to be used.
Were you still planning on releasing 2.1 and updating the master branch?
Python 3.5 support pythonnet. It supports up to 3.4.