Re: [Python.NET] C# components for script

2008-11-12 Thread Tribble, Brett
Yes, they can be anywhere, you just need to write some code to add them to the 
SYSTEM path for the current running code. Optionally, you can also tell .NET 
where to look for the assembly's config file.

import sys
import clr
import System

loadDir = 'C:/myAssemblyPath/'
assemblyName = 'myDLL.dll'
configfileName = 'myDLL.ini'

# add to system path
if not loadDir in sys.path:
sys.path.insert(0, loadDir)

# tell .NET where to look for the applications config file
System.AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", (loadDir + 
configfileName))

# load it up
clr.AddReference(assemblyName)


Cheers,

Brett


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Singh, Mandeep
Sent: Monday, November 10, 2008 7:56 PM
To: pythondotnet@python.org
Subject: [Python.NET] C# components for script


Hi,
I have written c# components to be used by Python. I note that those 
components need to be placed in the Pythonnet installation directory because 
its like private assemblies being loaded. Is there a way I can place them in 
separate location?

Thanks & regards,
Mandeep Singh
Equity IT
Credit Suisse
Tel: (+65) 6212 8755


==

Please access the attached hyperlink for an important electronic communications 
disclaimer:



http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html

==
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] ipython

2009-04-13 Thread Tribble, Brett
In theory it should work, but I haven't tried it myself. It certainly works 
from the interactive Python "shell" in Maya. Copy clr.pyd and 
python.runtime.dll into a directory that is part of IPython's %pythonpath% and 
also part of the system path %path%. Load the clr with the "import clr" 
statement, and you should be good to go. I have noticed that when invoked this 
way, Maya's native version of Python "forgets" how to load subsequent .pyd 
modules. It appears that the clr intercepts these import statements and fails 
to handle them correctly. I have resolved this by simply loading all .pyd 
modules I think I'll need before loading the clr.

From: pythondotnet-bounces+btribble=maxis@python.org 
[mailto:pythondotnet-bounces+btribble=maxis@python.org] On Behalf Of Kapil 
fadnis
Sent: Monday, April 13, 2009 10:05 AM
To: Michael Foord
Cc: pythondotnet@python.org
Subject: Re: [Python.NET] ipython

I dont know how to ? I run the Python.net console from the Python.net directory 
and it invokes the Python.exe console which calls the regular python mode. Is 
there a another way to run Python.net?
Thanks for the quick response.
On Mon, Apr 13, 2009 at 1:00 PM, Michael Foord 
mailto:fuzzy...@voidspace.org.uk>> wrote:
Kapil fadnis wrote:
Hi,
Is is possible to use ipython shell with python.net 
> ? please let me know how to do so ?
Have you tried it? What happens?

Michael
Thanks for your help.


_
Python.NET mailing list - 
PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] System.IO.FileNotFoundException: Unable to find assembly 'MbtCom.dll'.

2009-04-14 Thread Tribble, Brett
1.   Is it a managed assembly or an unmanaged .dll?

2.   If it is a managed assembly, is it registered in the GAC?

See: http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=713

also try:

clr.AddReference('nameOfAssembly'). Note that you do not need to include '.dll' 
This assumes the assembly is in the system path which can be accomplished using 
 sys.path.insert(0, 'mypath')



From: pythondotnet-bounces+btribble=maxis@python.org 
[mailto:pythondotnet-bounces+btribble=maxis@python.org] On Behalf Of kfadnis
Sent: Monday, April 13, 2009 6:10 PM
To: pythondotnet@python.org
Subject: [Python.NET] System.IO.FileNotFoundException: Unable to find assembly 
'MbtCom.dll'.

Hi All,
I know this is a very basic question, but despite all my efforts I haven't been 
able to load a third-party dll into python. I can find the dll using 
clr.FindAssembly("MbtCom"). I also append the required path to the sys.path, 
but it refuses to show up. Is there something obvious I am missing ?

Thank you for your time.
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] tuple not recognized as a type ?

2009-05-01 Thread Tribble, Brett
If  you have your .net assembly put up a modal dialog (messagebox), you can 
attach to the process from DevStudio, set breakpoints, etc.

From: pythondotnet-bounces+btribble=maxis@python.org 
[mailto:pythondotnet-bounces+btribble=maxis@python.org] On Behalf Of 
Grégoire Dooms
Sent: Friday, May 01, 2009 8:50 AM
To: pythondotnet@python.org
Subject: [Python.NET] tuple not recognized as a type ?

Hello,

I have been trying to use tuple as a generic type argument:
In [4]: from System.Collections.Generic import List
In [5]:
In [6]: x = List[int](range(4))
In [7]: x = List[tuple]([() for t in range(4)])
---
TypeError Traceback (most recent call last)

h:\python\testPyNet.py in ()
> 1
  2
  3
  4
  5

TypeError: type(s) expected

I had a similar problem in a generic method of a non-generic class.

I have two questions:
* Is there a work around ?
* How do you debug python for .NET ?
  I tried to attach a Visual Studio 2005 debugger to the python process and 
break in ClassObject.type_subscript but VS does not load the symbols.

Thanks for this project, I would love to use it.
--
Greg





_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Python.Net and DataRow

2009-08-14 Thread Tribble, Brett
Can you use this instead?

from System.Data import DataTable, DataRow
ttable = DataTable()
mydatar = ttable.NewRow()




-Original Message-
From: pythondotnet-bounces+btribble=maxis@python.org 
[mailto:pythondotnet-bounces+btribble=maxis@python.org] On Behalf Of 
Alexander Mail
Sent: Thursday, August 13, 2009 6:15 AM
To: pythondotnet@python.org
Subject: [Python.NET] Python.Net and DataRow

Hi,
I'm new in Python.Net programming. I try to build a simple project  
that use DataSet/DataTable/DataRow.
But when I add a DataRow with this code:

mydatar = DataRow()

I get this error:

no constructor matches given arguments.

Any ideas?

Thanks

Marco


_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


[Python.NET] Problem importing .pyd modules after 'import clr'

2009-08-14 Thread Tribble, Brett
Just what it says. If I import the clr first, I can't import other pyd files. I 
assume this is because of the way that pythonnet intercepts the import 
statement to do it's magic. Now here is where it gets "fun": This problem 
occurs when running from the version of Python 2.5 that is native to Maya, but 
does not occur when running from the ActiveState version of 2.5. In other 
words, the problem is specific to Maya.

For instance, if I import the Perforce API module first I get this:
>>>import P4API
>>>dir(P4API)
# Result: ['P4Adapter', 'P4Map', 'P4MergeData', '__doc__', '__file__', 
'__name__', 'identify'] #

However if I do it second to the clr, I get:
# Result: ['__doc__', '__file__', '__name__'] #


Any ideas?

Brett Tribble
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] using c# method from python

2010-02-18 Thread Tribble, Brett
Depending on how you're code works in C#, the way you access it from Python may 
vary, but the basic approach is:

Compile your code as a .dll assembly, then from Python do:

import clr  # Imports the pythonnet clr stuff
clr.AddReference("myAssembly.dll")
myObjectHandle = myAssembly.myClass()
myObjectHandle.bar()



From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of 
munawwarah Chamroo
Sent: Thursday, February 18, 2010 1:34 AM
To: pythondotnet@python.org
Subject: [Python.NET] using c# method from python

Hi,
I am currently developing an application where i need to call some c# methods 
from my python code.
I want to know if this is possible to do using pythonnet and how to do it.

for example i have a c# class foo and in foo i have a method bar()
Now i need to call method bar() in my python code.
How should i do this.

Please help

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] building on linux, mono 2.8.1

2010-12-08 Thread Tribble, Brett
Your long self-conversation is the most interesting thing to happen to this 
list in a long time...

From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Laszlo 
Sebo
Sent: Wednesday, December 08, 2010 5:45 PM
To: pythondotnet@python.org
Subject: Re: [Python.NET] building on linux, mono 2.8.1

At the risk of having a long conversation here with myself... :)

It appears that the crash happens in intobject.c of python, at the PyObject 
*PyInt_FromLong(long ival) function, when it tries to increment the reference 
counter: Py_INCREF(v);
When python.net calls this function first, it calls it with the value of 0, 
which falls into a special handled range of integers that are dealt with in a 
small_ints[] array. However, that array never go initialized, so the reference 
counter crashes.

The array would normally be initialized by calling _PyInt_Init(void). Sooo... 
just to test my theory, i exposed that function and called it explicitly from
Python.Runtime.Initialize() and low and behold, import clr now works just fine!

So i'll now go on a hunt, and make sure everything is initialized properly, i'm 
guessing some main init function isn't being called somewhere when using 
python.net from an embedded python.


cheers,
laszlo


On 08/12/2010 1:35 PM, Laszlo Sebo wrote:
Made a little bit of progress, but am now back to square one.. :)

Basically, seems that the python embedded in nuke uses UCS4 instead of UCS2 
which is the default when building python. So the python so's i had were using 
UCS2 while Nuke's internal python was using UCS4. I rebuilt python using the 
--enable-unicode=ucs4 flag, then rebuilt python.net.

I hit another wall fairly soon, the mono config (dll remap) file wasn't being 
initialized, so i would be getting missing msvcrt dll errors on import clr.
To fix that, i had to uncomment this line in pynetinit.c:
//mono_config_parse(NULL);

However, now i am back to the previous error i had:

Stacktrace:

  at (wrapper managed-to-native) Python.Runtime.Runtime.PyInt_FromLong (intptr) 
<0x00060>
  at (wrapper managed-to-native) Python.Runtime.Runtime.PyInt_FromLong (intptr) 
<0x>
  at Python.Runtime.Runtime.PyInt_FromInt32 (int) <0x0006b>
  at Python.Runtime.Runtime.Initialize () <0x00433>
  at Python.Runtime.PythonEngine.Initialize () <0x00073>
  at (wrapper runtime-invoke) object.runtime_invoke_void 
(object,intptr,intptr,intptr) <0x>


oh well... anybody managed to get python.net working with UCS4 python?


cheers,
laszlo

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] building on linux, mono 2.8.1

2010-12-09 Thread Tribble, Brett
Maya works fine with python.net. We use it all the time. Just remember that 
Maya is very particular as to how it handles multithreading, raising events, 
and the like. There is some info in the Maya Python SDK regarding how to deal 
with Python threading and Maya, and it seems to work with .NET callbacks as 
well. I've found that is seems best to add a flag to your .NET assembly that 
enables/disable events so that you can shut them off quickly before you end up 
with stacked event callbacks and resulting Maya crashes. If you're not raising 
events that percolate into Maya, then you probably don't need to worry about 
this.


-Original Message-
From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Laszlo 
Sebo
Sent: Thursday, December 09, 2010 12:06 PM
To: pythondotnet@python.org
Subject: Re: [Python.NET] building on linux, mono 2.8.1

 > Sadly, our other target, Maya, seems to be linking python 
statically... So I hope i can figure out how to get this integrated 
somehow...

Actually, scratch that. It seems like it has it's own .so as well. Time 
for some testing



cheers,
laszlo

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


Re: [Python.NET] building on linux, mono 2.8.1

2010-12-13 Thread Tribble, Brett
I'm not a huge GIT lover, but it seems to have the most inertia behind it right 
now, so that would be my preference should the change be made...


-Original Message-
From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Christian 
Heimes
Sent: Monday, December 13, 2010 9:32 AM
To: pythondotnet@python.org
Subject: Re: [Python.NET] building on linux, mono 2.8.1

Am 12.12.2010 07:25, schrieb Brian Lloyd:
> Hi all - I've recently taken a position that is MUCH more open-source
> friendly. Now that I don't
> have to have lawyers parse everything, what do you think about moving this
> whole thing to
> github? I don't know that I'll have much more time to devote to the project
> near term, but I would
> really like to lower the barrier-to-entry for folks with a vested interest
> in this project to contribute
> (and divest myself and others of of managing the SF project).
> 
> Unless anyone objects I think we should migrate the repo to github and
> redirect SF there...

I'm generally +1 for a DVCS but why git? I prefer to eat my own food and
stick to a Python based DVCS like hq.

Christian

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


Re: [Python.NET] Fwd: PythonNET 2.0 Alpha2 and .NET 4.0

2011-01-07 Thread Tribble, Brett
Merge away!

From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Barton
Sent: Friday, January 07, 2011 1:02 AM
To: Oleksii Bidiuk
Cc: pythondotnet@python.org
Subject: Re: [Python.NET] Fwd: PythonNET 2.0 Alpha2 and .NET 4.0

I've got this working on my private (for the moment) branch.  I could do this 
merge by this weekend if folks will find it useful.
-Barton

On 1/6/2011 6:59 AM, Oleksii Bidiuk wrote:
Hi Alla,

thanks for your prompt repsonse. In Python terms String('A') means constructor 
with a string parameter AFAIK. When I use the python.exe build against CLR 2.0 
(from pythonnet-2.0-alpha2-clr2.0_115_py26.zip) it works, but then it talks 
against .NET 2.0 while I want to talk to the same 4.0 version as my .NET 
application.
With the example below using the .NET 2.0 version I get

>>> s = String.__overloads__[Char, Int32]('A', 10)
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: type object 'String' has no attribute '__overloads__'

Basically it seems that the version of python for .net compiled against .NET 
4.0 runtime does not work out of box for me. I wonder if somebody had more luck 
with this.

2011/1/6 Alla Gofman mailto:alla.gof...@sandisk.com>>

Hi Oleksii,

I have no experience with importing .net modules into Python.
I work on embedding Python into C#.
There is no such constructor String('A') for String class as you use, which 
gets char.
You can see which constructors exists in: 
http://msdn.microsoft.com/en-us/library/system.string.string.aspx

Example:
I read in http://pythonnet.sourceforge.net/readme.html
In most cases, Python for .NET can determine the correct constructor to call 
automatically based on the arguments. In some cases, it may be necessary to 
call a particular overloaded constructor, which is supported by a special 
"__overloads__" attribute on a class:
from System import String, Char, Int32

s = String.__overloads__[Char, Int32]('A', 10)

I hope you succeed,

Alla

From: 
pythondotnet-bounces+alla.gofman=sandisk.com@python.org
 
[mailto:pythondotnet-bounces+alla.gofman=sandisk.com@python.org]
 On Behalf Of Oleksii Bidiuk
Sent: Thursday, January 06, 2011 4:27 PM
To: pythondotnet@python.org
Subject: [Python.NET] PythonNET 2.0 Alpha2 and .NET 4.0

Hi,

I am trying to use Python for .NET under VS2010 and .NET 4.0. I've downloaded 
the pythonnet-2.0-alpha2.zip and changed the project settings to use .NET 4.0 
under VS2010 and recompiled everything. The resulting python.exe can be run, 
and statements like "import clr" and "from System import String" work (as the 
Python standard library calls as well) until I try to instantiate a class as 
e.g.

s = String('A')
At this moment the Python for .NET seem to crash in nativecall.cs at 
NativeCall.Call_3() at (the only) line

return Impl.Call_3(fp, a1, a2, a3);

with dreaded "Exception of type 'System.ExecutionEngineException' was thrown.". 
Trying to instantiate Int32() object results in "Attempted to read or write 
protected memory. This is often an indication that other memory is corrupt."

Suggestions are more than welcome! Thanks in advance!
--
oleksii


PLEASE NOTE: The information contained in this electronic mail message is 
intended only for the use of the designated recipient(s) named above. If the 
reader of this message is not the intended recipient, you are hereby notified 
that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify the sender by 
telephone or e-mail (as shown above) immediately and destroy any and all copies 
of this message in your possession (whether hard copies or electronically 
stored copies).



--
oleksii



--
oleksii






_

Python.NET mailing list - 
PythonDotNet@python.org

http://mail.python.org/mailman/listinfo/pythondotnet
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] PythonDotNet - IronPyton

2011-01-10 Thread Tribble, Brett
There are also logistical and political considerations. Some environments are 
tied to cpython, and switching to IronPython is impossible (such as the python 
environment included with Autodesk Maya). Also, many engineers have religious 
leanings, and would never tie their environment to .NET or other MicroSoft 
technologies. Adding .NET functionality "on the side" is usually an easier sell.



-Original Message-
From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Mark 
Tigges
Sent: Monday, January 10, 2011 9:12 AM
To: emmanuel.lamb...@intec.ugent.be
Cc: pythondotnet@python.org
Subject: Re: [Python.NET] PythonDotNet - IronPyton

On Mon, Jan 10, 2011 at 4:18 AM, Emmanuel Lambert
 wrote:
> Hi Oleksii Bidiuk,
>
> While access to the native Python libraries is apprently a nice feature
> of "Python for .NET", I don't think it is very useful in real-world .NET
> centric projects (in a corporate environment for example).
> An implementation like IronPython restricts itself to the use of
> native .NET features and thus cannot cause dangerous side-effects that
> inflict memory leak for example. With "Python for .NET", that is not the
> case.
> Therefore, in my opinion, IronPython looks like an implementation that
> is potentially useful for real-world projects, while "Python for .NET"
> looks more experimental in its nature...
>
> Emmanuel
>

Emmanual,

You're very mistaken.  In our "corporate environment" (a large game
studio), we use both.  IronPython is used where we want to extend a
.net environment with python scripting capabilities.  PythonDotNet is
used when we want to use our .net assemblies from another program
which has cpython embedded.  PythonDotNet allows us to extend Maya &
MotionBuilder by leveraging all the .net code we write for our tools.

Your opinion is yours, but trust me, while PythonDotNet is a little
rough around the edges it is hugely beneficial to us and others.

We use a cpython distribution augmented with PythonDotNet as our
standard python for distribution to client machines.  The only place
we use IronPython is embedded in our tools.  The start up time for
IronPython (about .5 secs) the last time I checked pretty much makes
it useless.

Mark.

>
>
> On Mon, 2011-01-10 at 09:55 +0100, Oleksii Bidiuk wrote:
>> Hi Emmanuel,
>>
>>
>> The basic differences are highlighted in several discussions like
>>
>>
>> http://stackoverflow.com/questions/1168914/ironpython-vs-python-net
>>
>>
>> In short IronPython is a complete managed implementation of Python
>> interpreter in .NET (developed parallel to the regular Python or
>> CPython), just like Jython. Python for .NET on the other hand is
>> a .NET wrapper around the CPython interpreter providing access to the
>> CPython from .NET application and back. There are differences in
>> implementation (e.g. no GIL in IronPython) and in the accessibility of
>> the libraries (no access to the C libraries from IronPython out of
>> box).
>>
>>
>> I am also interested in any hints to the roadmaps of the both
>> products. IronPython seem to be more mature, but it is also way more
>> effort than Python for .NET. So far I have difficulties to choose
>> strategically for either one as both are lagging behind the solid
>> community of CPython. Comments are more than welcome!
>>
>> 2011/1/10 Emmanuel Lambert 
>>         Dear all,
>>
>>         I was wondering : what is the difference between PythonDotNet
>>         and
>>         IronPython? It looks like IronPython is rapidly becoming a
>>         maturing
>>         implementation for the .NET platform, with also a plugin for
>>         Visual
>>         Studio becoming available : http://ironpython.net/
>>
>>         The distinction between the two implementations, future
>>         roadmaps, etc,
>>         is not clear to me. Any comments are welcome...
>>
>>         regards
>>         Emmanuel
>>
>>
>>         _
>>         Python.NET mailing list - PythonDotNet@python.org
>>         http://mail.python.org/mailman/listinfo/pythondotnet
>>
>>
>>
>> --
>> oleksii
>>
>
>
> _
> Python.NET mailing list - PythonDotNet@python.org
> http://mail.python.org/mailman/listinfo/pythondotnet
>
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


Re: [Python.NET] Python.NET and VS2001/.NET 4.0

2011-01-18 Thread Tribble, Brett
Thanks Biduik,

I will need this in a few short weeks.

From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Oleksii 
Bidiuk
Sent: Monday, January 17, 2011 8:06 AM
To: pythondotnet@python.org
Subject: [Python.NET] Python.NET and VS2001/.NET 4.0

Hi All,

I hope this will help some people like me searching for an answer. Several 
steps were mentioned by other people as well, but I haven't seen a step-by-step 
guide. It is not my intention to duplicate other posts in that sense, but 
rather have all-in-one post.

Here is how I've got VS2010 and .NET 4.0 working with the revision 119 of the 
Python.NET having Python 2.6 installed. Note that the latest trunk (revision 
122) gave me some problems, so I have basically reverted changes to match 119 
for the time being.

1. Get the sources (tarball from sourceforge or directly from SVN)
2. Open the pythonnet.sln with VS2010 and convert to 2010 format (will happen 
automagically)
3. Change the target framework to 4. Follow the following step for EACH project
3.1. Right-click on the project name and select "Properties"
3.2. Select the "Application" tab on the left (if not selected yet)
3.3. Change the "Target framework" to ".NET Framework 4"
4. Open the clrmodule.il and change the lines with the 
version number in the following piece of code

.assembly extern mscorlib
{
 .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
 .ver 2:0:0:0
}

to have


 .ver 4:0:0:0

5. Open the buildclrmodule.bat and change the

%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll 
%ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

to

%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll 
%ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

5. Recompile the whole solution, ignore the deprecation warnings.

Now you have all necessary files under the pythonnet folder where you have the 
sources. You need clr.pyd, python.exe and Python.Runtime.dll.

Test
Run the newly comiled python.exe
Type the following

>>> import System >>> print System.Environment.Version 4.0.30319.1

The last line proves that you're using hte 4.0 runtime. The precomiled binaries 
available from Sourceforge would show
2.0.50727.3615

This is also posted with somewhat better formatting under 
blog.bidiuk.com/2011/01/python-net-and-vs2010-net-4/

Comments and suggestions are welcome!
--
oleksii
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Python.NET and VS2010/.NET 4.0

2011-02-08 Thread Tribble, Brett
Has anyone been able to get this working on Windows 7 as 64 bit “all the way 
down”?
I’m about to have this thrown on my plate I think…

From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Oleksii 
Bidiuk
Sent: Tuesday, February 08, 2011 7:50 AM
To: Bart Jonkers
Cc: pythondotnet@python.org
Subject: Re: [Python.NET] Python.NET and VS2010/.NET 4.0

Hi Bart,

thanks for sharing the results! Indeed, you have to make sure the complete 
stack is compiled for the same platform. I hope this will help other people as 
well!
2011/2/8 Bart Jonkers mailto:jonkersb...@gmail.com>>
Hi Oleskii,

I was able to solve the issue.

I had to change the Platform target to x86 instead of Any CPU for
every project in the solution.

It seems that Any CPU will result in an executable that will run as
64-bit application on a 64-bit system and as 32-bit on a 32-bit
system.
As I have a 64-bit system and have the 32-bit version of python
installed it will not load the python dll.

By forcing a 32 - bit build the python executable was able to load the
python dll.

Thanks for your support,
Bart

On Tue, Feb 8, 2011 at 2:34 PM, Oleksii Bidiuk 
mailto:oleksii.bid...@gmail.com>> wrote:
> Hi Bart,
>
> I am no way an expert on this question, but it seem that your PythonNET is
> trying to load a different version of runtime than the one he was compiled
> against. You need to make sure the same runtime is built and used for
> python.exe. To make sure the 4.0 is used, you can create / edit the
> python.exe.config file (located in the same folder from where you start the
> newly compiled python.exe) with the following contents
> 
> 
> 
> 
> 
> 
> This will make sure the 4.0 is loaded (search
> on useLegacyV2RuntimeActivationPolicy for more info, normally 2.0 will be
> loaded).
> If the above does not help here are a few questions that may point further
> direction:
> - Have you compiled for 32 or 64 bits (there is an .il for 64 bits, but I
> haven't tried it myself)?
> - Which version of runtime (2.0, 3.0/3.5, 4.0; x32 or x64 bits) do you have
> installed?
> - Do you start on the same machine where your development environment is
> started or in a separate environment?
> Regarding the startup time, do you experience slow start of pythonNET
> version one time or every time it is started? I can imagine it is slow the
> first time (as it has to load CLR), but the consequent starts have to be
> reasonably fast.
> 2011/2/8 Bart Jonkers mailto:jonkersb...@gmail.com>>
>>
>> Hi Oleskii,
>>
>> Thanks for the quick response.
>>
>> I searched on my system for the python26.dll and I found it in
>> C:\Windows\SysWOW64.
>> I copied it to c:\windows\system32\ and now I'm getting the following
>> error:
>>
>> Unhandled Exception: System.BadImageFormatException: An attempt was made
>> to load
>>  a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
>>   at Python.Runtime.Runtime.Py_Initialize()
>>   at Python.Runtime.Runtime.Initialize()
>>   at Python.Runtime.PythonEngine.Initialize()
>>   at Python.Runtime.PythonConsole.Main(String[] args)
>>
>> Anny idea?
>>
>> I have installed python 2.6.6 (32-bit) on a 64-bit version of Windows 7.
>>
>> The problem that we have with the .NET version of python.exe is that
>> it takes some time before it starts.
>> As we use python in our build environment, it significantly slows down
>> our build process.
>>
>> Regards,
>> Bart
>>
>> On Tue, Feb 8, 2011 at 11:08 AM, Oleksii Bidiuk
>> mailto:oleksii.bid...@gmail.com>> wrote:
>> > Hi Bart,
>> > the python26.dll is installed to the c:\windows\system32\ folder
>> > regardless
>> > of where your main Python installation goes to. I've seen similar
>> > problem
>> > when I have copied the Python26 folder to a new machine and forgot to
>> > take
>> > the python26.dll along. Check if you have the python26.dll in place and
>> > make
>> > sure you use the newly built python.exe interpreter.
>> >
>> > It is indeed recommended to use the python.exe compiled with PythonNET
>> > as it
>> > does some additional initialization (see the implementation of the
>> > Initialize() method in pythonengine.cs code).
>> > 2011/2/8 Bart Jonkers mailto:jonkersb...@gmail.com>>
>> >>
>> >> Hi,
>> >>
>> >> I followed the instructions from oleskii to build Python.NET for
>> >> .NET4.0.
>> >> Compilation wend fine but when I try to run python.exe I get the
>> >> following error:
>> >>
>> >> Unhandled Exception: System.DllNotFoundException: Unable to load DLL
>> >> 'python26':
>> >>  The specified module could not be found. (Exception from HRESULT:
>> >> 0x8007007E)
>> >>   at Python.Runtime.Runtime.Py_Initialize()
>> >>   at Python.Runtime.Runtime.Initialize()
>> >>   at Python.Runtime.PythonEngine.Initialize()
>> >>   at Python.Runtime.PythonConsole.Main(String[] args)
>> >>
>> >> I have installed Python in C:\Python26.
>> >> Does any one an idea?
>> >>
>> >> Is it necessary to use the python.exe build by the project 

Re: [Python.NET] Setting PYTHONPATH from code

2011-02-23 Thread Tribble, Brett
This is the code I use all the time to append a dir to the system path and then 
load assemblies from that dir. (note, they’re not in the GAC {woot!})

if os.path.isfile(myFile):
if not myDir in sys.path:
sys.path.insert(0, myDir)
clr.AddReference("myAssembly")

myFile is the name of the assembly dll ala: “C:/testdir/myAssembly.dll”
myDir would be: “C:/testdir”

I always make sure that the namespace in the compiled assembly is the same as 
the filename. This seems to make things run more smoothly.

From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Sharon 
Rozenblum
Sent: Wednesday, February 23, 2011 5:37 AM
To: Oleksii Bidiuk
Cc: pythondotnet@python.org
Subject: Re: [Python.NET] Setting PYTHONPATH from code

Hi!

Trying to do as you said:


string script = "import sys\nsys.path.insert(0, '" + modulePath + 
"')";

IntPtr pythonLock = PythonEngine.AcquireLock();
PythonEngine.RunSimpleString(script);
PythonEngine.ReleaseLock(pythonLock);

And then:

IntPtr gs = PythonEngine.AcquireLock();
pyportal = PythonEngine.ImportModule(moduleName);
if (pyportal == null)
{
…
}
   …

I got Null value from the ImportModule.

When setting the PYTHONPATH manually in the system variables with the 
“modulePath” and opening the VS is works.

Any idea?

Thanks,

SAHRON


From: Oleksii Bidiuk [mailto:oleksii.bid...@gmail.com]
Sent: Thursday, February 10, 2011 2:21 PM
To: Sharon Rozenblum
Cc: pythondotnet@python.org
Subject: Re: [Python.NET] Setting PYTHONPATH from code

Hi Sharon,

What do you want to achieve with this? If you want to provide path for loading 
your own modules you can change the sys.path value by e.g. running a 
'initialization' script with

import sys
sys.path.insert(0, 'your/own/path')

You can build up the script above in C# by inserting the path you need and then 
performing e.g. RunSimpleString(

Re: [Python.NET] Fwd: Python.NET activity

2011-03-23 Thread Tribble, Brett
In other interesting/awesome Python news, the Python IDE stuff for Visual 
Studio 2010 that comes with the new version of IronPython has been split off 
into its own project.

http://pytools.codeplex.com/

I haven't tried debugging pythonnet with it yet though.




From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Barton
Sent: Tuesday, March 22, 2011 11:45 PM
To: pythondotnet@python.org
Subject: [Python.NET] Fwd: Python.NET activity


I thought the list might be interested in something that's going on over on the 
python-win32 list:



It seems that my favorite project is getting some attention...



http://mail.python.org/pipermail/python-win32/2011-March/011247.html



On 28/02/2011 09:40, Tim Golden wrote:

> Well, the last Svn commit was 4 weeks ago, by "barton_c", and Python27

> "support" (ie switches") were added 2 months ago. Looks like "Barton_C"

> needs to do some advertising. I'll see if I can contact him/her through

> sf.



Got this reply from Barton, who's not subscribed to this list:



"""

Using the current state of the art, I freely mix wxPython, MS Framework

2.0 (others are hooking to .NET 4.0) and ctypes in full GUI apps and

drivers.

The current challenge for me is getting the whole thing working

(together) on Ubuntu Maverick (10.10).

I have brought the PythonDotNet project up to python27 compatibility,

but have not published the binaries yet.



"""



TJG


 Original Message 
Subject:

Python.NET activity

Date:

Mon, 28 Feb 2011 09:44:54 +

From:

Tim Golden 

To:

barto...@users.sourceforge.net



Hi, Barton.



There was some discussion on the python-win32 list about the

status of Python.NET and I noticed that you'd been comitting

in the last few weeks. Would you care to chime in to the

conversation?



http://mail.python.org/pipermail/python-win32/2011-February/011222.html



Thanks



TJG


_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Using numpy/matplotlib - DLL Load Failed

2011-04-19 Thread Tribble, Brett
Import multiarray first as well. Numpy is doing an import in the __init__ 
according to what I see here, unless I'm wrong, which is also likely. Lather, 
rinse, repeat for any additional modules that fail to load.

This bug has plagued my pythondotnet usage since day 1...


-Original Message-
From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of ElMariachi
Sent: Tuesday, April 19, 2011 6:23 AM
To: pythondotnet@python.org
Subject: Re: [Python.NET] Using numpy/matplotlib - DLL Load Failed


I've tried just this - starting up pythonnet.exe and importing pylab, or
matplotlib, or numpy as the first import prior to clr. I still get the DLL
not found errors. Have you found any other solution?



Barton wrote:
> 
> I have had tons of issues with python 2.7 and manifest issues that did 
> not occur in 2.6.
> A short term solution would be to start python from the standard 
> (cpython) python.exe, import your extension libraries that don't play 
> nicely first, then import clr (relying on the late-bound import hook).
> 
> On 4/14/2011 7:26 AM, ElMariachi wrote:
>> Has anyone encountered this error before? What DLL is being searched for
>> and
>> not found? Any help is greatly appreciated!
>>
>>
> import numpy
>> Traceback (most recent call last):
>>File "", line 1, in
>>File "C:\Python27\lib\site-packages\numpy\__init__.py", line 142, in
>> 
>>  import add_newdocs
>>File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in
>> 
>>
>>  from numpy.lib import add_newdoc
>>File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in
>> >  from type_check import *
>>File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8,
>> in
>> > le>
>>  import numpy.core.numeric as _nx
>>File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 5,
>> in
>> > e>
>>  import multiarray
>> ImportError: DLL load failed: The specified module could not be found.
> _
> Python.NET mailing list - PythonDotNet@python.org
> http://mail.python.org/mailman/listinfo/pythondotnet
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Using-numpy-matplotlib---DLL-Load-Failed-tp31397569p31432493.html
Sent from the Python - pythondotnet mailing list archive at Nabble.com.

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


Re: [Python.NET] Using numpy/matplotlib - DLL Load Failed

2011-04-20 Thread Tribble, Brett
Check to make sure that your pythonpath and system path are the same after you 
import the CLR. In other words, what are both of these set to when it works, 
and when it fails. Perhaps Barton has some idea what causes the underlying 
error.


-Original Message-
From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of ElMariachi
Sent: Wednesday, April 20, 2011 1:46 PM
To: pythondotnet@python.org
Subject: Re: [Python.NET] Using numpy/matplotlib - DLL Load Failed


I have tried, as you mentioned, importing multiarray first. It is a module
declared in numpy.core (the filename is "multiarray.pyd") though I keep
getting the same error. Any idea what else I might try? 

>>> from numpy.core import multiarray
Traceback (most recent call last):
  File "", line 1, in 
  File "c:\python27\lib\site-packages\numpy\__init__.py", line 142, in

import add_newdocs
  File "c:\python27\lib\site-packages\numpy\add_newdocs.py", line 9, in


from numpy.lib import add_newdoc
  File "c:\python27\lib\site-packages\numpy\lib\__init__.py", line 4, in

from type_check import *
  File "c:\python27\lib\site-packages\numpy\lib\type_check.py", line 8, in

import numpy.core.numeric as _nx
  File "c:\python27\lib\site-packages\numpy\core\__init__.py", line 5, in

import multiarray
ImportError: DLL load failed: The specified module could not be found.



Tribble, Brett wrote:
> 
> Import multiarray first as well. Numpy is doing an import in the __init__
> according to what I see here, unless I'm wrong, which is also likely.
> Lather, rinse, repeat for any additional modules that fail to load.
> 
> This bug has plagued my pythondotnet usage since day 1...
> 


-- 
View this message in context: 
http://old.nabble.com/Using-numpy-matplotlib---DLL-Load-Failed-tp31397569p31443742.html
Sent from the Python - pythondotnet mailing list archive at Nabble.com.

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


Re: [Python.NET] Better doc strings.

2011-04-25 Thread Tribble, Brett
Well done sir!

-Original Message-
From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Barton
Sent: Saturday, April 23, 2011 4:05 PM
To: Brad Byrd
Cc: pythondotnet@python.org
Subject: Re: [Python.NET] Better doc strings.

I just pushed the initial DocStringAttribute mods to the trunk:

* Python.Runtime now exposes a public class called DocStringAttribute
with usage = AttributeTargets.All

* Decorating .NET classes and methods has passed initial tests on Mono.

### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;

namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {

[DocStringAttribute("External funtion simulation: 
WriteToFile(char) 
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
 return;
}
}
}


## test.py ##
import clr
clr.AddReference("SimpleLibTest")   # the name of the .NET or Mono assembly
import PinvokeTest
from PinvokeTest import Invoke  # .NET or Mono namespace maps to a 
python module
 # so grab the class from there 
using import
Invoke.WriteToFile('a') # Now call a method on the class
print "Function docstring:",
print Invoke.WriteToFile.__doc__
print "Class docstring:", Invoke.__doc__
i = Invoke()
print "Instance docstring:", i.__doc__



On 03/28/2011 10:44 AM, Brad Byrd wrote:
I'm trying to provide better documentation for some C# classes that are 
called from Python.  Ideally, I'd like to markup my class in C#, either 
with the standard XML comments or with something like a 
[PythonDocAttribute], and have this documentation show up as the __doc__ 
string for the method or class in Python.  That way, the clients of my 
wrapped objects will see nice tool-tips on my classes as they code away 
in their IDE.

So, is this easily done?  Has anyone else crossed this bridge before? 
Does something already exist that would work before I start hacking on 
the Python.NET source?

(Also, are the archives of the list searchable somewhere?  I just saw 
clickable-by-month archives, not searchable.)

Thanks,

Brad...

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


Re: [Python.NET] Fedora FC15

2011-08-15 Thread Tribble, Brett
Pythono?

-Original Message-
From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Barton
Sent: Sunday, August 14, 2011 3:51 PM
To: 'pythondotnet@python.org'
Subject: [Python.NET] Fedora FC15

I've rebuilt Christians work on the embedded Mono "clrpython" in order 
to get things in working order on Fedora FC15 Python 2.7.1.
"clrpython" is a little clunky, so I'm proposing to make this public 
with the name mPython, nPython or maybe nmPython after testing on Windows.

Any thoughts are greatly appreciated-
barton
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


[Python.NET] Python Tools For Visual Studio

2011-12-02 Thread Tribble, Brett
If you haven't checked it out, you really should. It lets you write both 
CPython and IronPython in Visual Studio and you can debug both. It does a 
pretty good job of dependency and usage tracking so that things like "find all 
references" and "go to definition" work pretty well, and it even lets you 
attach to a running process to do debugging in Python and/or a mixed 
environment. It is a Microsoft open source project, and 3rd party contributions 
are welcome, but as a DevStudio language plugin, you will need an expensive 
version of DevStudio to participate.

http://pytools.codeplex.com/

Brett

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] import clr_2, import clr_4 vs import clr

2012-03-22 Thread Tribble, Brett
might any of this help?

http://stackoverflow.com/questions/2455654/what-additional-configuration-is-necessary-to-reference-a-net-2-0-mixed-mode
http://stackoverflow.com/questions/3267491/when-linking-a-net-2-0-managed-assembly-from-a-net-4-0-application-which-fram
 see the answer by “htw”
http://blogs.msdn.com/b/dotnet/archive/2009/06/03/in-process-side-by-side-part1.aspx

From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Liam 
Corrigan
Sent: Thursday, March 22, 2012 2:03 PM
To: Brad Friedman; pythondotnet@python.org
Subject: Re: [Python.NET] import clr_2, import clr_4 vs import clr

The one lib that has issues, includes some cpp runtime stuff that needs to be 
changed.
I’ve done it in the past, but it was a pain and is not our production code – 
which I need to test.
All the other .NET libs that I use targeted against 2.0, worked in the 4.0 .NET 
python.


From: Brad Friedman [mailto:b...@fie.us]
Sent: March-22-12 5:00 PM
To: Liam Corrigan
Cc: 
Subject: Re: [Python.NET] import clr_2, import clr_4 vs import clr

Silly question: isn't a .net 2.0 assembly backwards compatible with a .net 4.0 
runtime?  Why do you actually need to run a physically separate runtime?  What 
is breaking?

On Mar 22, 2012, at 4:27 PM, "Liam Corrigan" 
mailto:liam.corri...@allenvanguard.com>> wrote:
Hi guys,
I’ve been using python .NET 2.0 in python 2.7.2 successfully for some time now 
and have also used the .NET 4.0 version, but of course I need to replace the 
clr.pyd and Python.Runtime.dll with the .NET 4.0 versions.
Although most of my 2.0 libs work over the 4.0 version, there is one in house 
library targeted against .NET 2.0 that will not, without some awkward hacks.
I need to be able to call into libraries written against both .NET 2.0 and 4.0, 
as separated calls - ideally, I’d like to have things such that I can operate 
in a python script something like this:

import clr_2
import clr_4

clr_2.AddReference("MyDOTNET_2.0_BasedLib")
clr_4.AddReference("MyDOTNET_4.0_BasedLib")


Are there any settings in the source build that I can do, to kick out two 
separate clr.pyd and Python.Runtime.dll’s with new names and matching .NET 
version support?


Liam Corrigan


IMPORTANT LEGAL NOTICE

This message is intended only for the use of the named addressee. It may 
contain information that is copywritten, privileged, confidential and exempt 
from disclosure under applicable law. If you are not the intended recipient, 
you are notified that any dissemination, distribution or copying of this 
communication is strictly prohibited. If you have received this in error, 
please notify the sender immediately and delete it from your system. 
Communications using this system are monitored and recorded for lawful business 
purposes.
_
Python.NET mailing list - 
PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet
=
IMPORTANT LEGAL NOTICE

This message is intended only for the use of the named addressee. It may 
contain information that is copywritten, privileged, confidential and exempt 
from disclosure under applicable law. If you are not the intended recipient, 
you are notified that any dissemination, distribution or copying of this 
communication is strictly prohibited. If you have received this in error, 
please notify the sender immediately and delete it from your system. 
Communications using this system are monitored and recorded for lawful business 
purposes.
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] import clr_2, import clr_4 vs import clr

2012-03-22 Thread Tribble, Brett
I would say you could just dupe the projects under the solution and change the 
target info, but how are you going to control which one handles imports IE 
"import System"?

From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Liam 
Corrigan
Sent: Thursday, March 22, 2012 1:28 PM
To: pythondotnet@python.org
Subject: [Python.NET] import clr_2, import clr_4 vs import clr

Hi guys,
I've been using python .NET 2.0 in python 2.7.2 successfully for some time now 
and have also used the .NET 4.0 version, but of course I need to replace the 
clr.pyd and Python.Runtime.dll with the .NET 4.0 versions.
Although most of my 2.0 libs work over the 4.0 version, there is one in house 
library targeted against .NET 2.0 that will not, without some awkward hacks.
I need to be able to call into libraries written against both .NET 2.0 and 4.0, 
as separated calls - ideally, I'd like to have things such that I can operate 
in a python script something like this:

import clr_2
import clr_4

clr_2.AddReference("MyDOTNET_2.0_BasedLib")
clr_4.AddReference("MyDOTNET_4.0_BasedLib")


Are there any settings in the source build that I can do, to kick out two 
separate clr.pyd and Python.Runtime.dll's with new names and matching .NET 
version support?


Liam Corrigan


IMPORTANT LEGAL NOTICE

This message is intended only for the use of the named addressee. It may 
contain information that is copywritten, privileged, confidential and exempt 
from disclosure under applicable law. If you are not the intended recipient, 
you are notified that any dissemination, distribution or copying of this 
communication is strictly prohibited. If you have received this in error, 
please notify the sender immediately and delete it from your system. 
Communications using this system are monitored and recorded for lawful business 
purposes.
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] import clr_2, import clr_4 vs import clr

2012-03-23 Thread Tribble, Brett
Scary voodoo. (not significantly scarier voodoo than what python.net itself 
does though)

Glad to hear you were able to make it work. I'll file this away under "things I 
hope to never have to duplicate".

From: Liam Corrigan [mailto:liam.corri...@allenvanguard.com]
Sent: Friday, March 23, 2012 10:18 AM
To: pythondotnet@python.org
Cc: Tribble, Brett
Subject: RE: import clr_2, import clr_4 vs import clr

Opening up our existing products native lib output to mixed mode proved to be a 
real pain, so I took your first suggestion Brett.
After changing the project to .NET 4.0, changing the target info to 'clr4.pyd' 
and changing all clr related strings in all the files to clr4, I have it 
working.
In my implementation, all my custom rack code and .NET support are called in 
from testlib

>>> import testlib
>>> twoDotOAssemblies = testlib.clr.ListAssemblies(True)
>>> twoDotOAssemblies[0]
u'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
>>> fourDotOAssemblies = testlib.clr4.ListAssemblies(True)
>>> fourDotOAssemblies[0]
u'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

I agree, it is fuzzy to me as to what is happening behind the scenes when I do:
testlib.clr.AddReference("System")

>>> testlib.clr4.AddReference("System")


...but for my purposes, it doesn't matter.  I don't do any dot net calls other 
than my custom packaged C# library functions in .NET.
When I do want to play in that realm, I use IronPython but I generally just 
write what I need in C# and then call it in pythonnet
Thanks for the help!


From: Liam Corrigan
Sent: March-22-12 5:09 PM
To: pythondotnet@python.org
Subject: RE: import clr_2, import clr_4 vs import clr

I make a reference to System, I need to do it through from clr.

>>> import System
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named System
>>> import clr
>>> clr.AddReference("System")

>>>

So I figured if I had a 'import clr_2',
Then the call to 'clr_2.AddReference("System") would call the 2.0 version of 
System.


From: Tribble, Brett [mailto:btrib...@ea.com]
Sent: March-22-12 4:59 PM
To: Liam Corrigan; pythondotnet@python.org<mailto:pythondotnet@python.org>
Subject: RE: import clr_2, import clr_4 vs import clr

I would say you could just dupe the projects under the solution and change the 
target info, but how are you going to control which one handles imports IE 
"import System"?

From: 
pythondotnet-bounces+btribble=ea@python.org<mailto:pythondotnet-bounces+btribble=ea@python.org>
 [mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Liam 
Corrigan
Sent: Thursday, March 22, 2012 1:28 PM
To: pythondotnet@python.org<mailto:pythondotnet@python.org>
Subject: [Python.NET] import clr_2, import clr_4 vs import clr

Hi guys,
I've been using python .NET 2.0 in python 2.7.2 successfully for some time now 
and have also used the .NET 4.0 version, but of course I need to replace the 
clr.pyd and Python.Runtime.dll with the .NET 4.0 versions.
Although most of my 2.0 libs work over the 4.0 version, there is one in house 
library targeted against .NET 2.0 that will not, without some awkward hacks.
I need to be able to call into libraries written against both .NET 2.0 and 4.0, 
as separated calls - ideally, I'd like to have things such that I can operate 
in a python script something like this:

import clr_2
import clr_4

clr_2.AddReference("MyDOTNET_2.0_BasedLib")
clr_4.AddReference("MyDOTNET_4.0_BasedLib")


Are there any settings in the source build that I can do, to kick out two 
separate clr.pyd and Python.Runtime.dll's with new names and matching .NET 
version support?


Liam Corrigan


IMPORTANT LEGAL NOTICE

This message is intended only for the use of the named addressee. It may 
contain information that is copywritten, privileged, confidential and exempt 
from disclosure under applicable law. If you are not the intended recipient, 
you are notified that any dissemination, distribution or copying of this 
communication is strictly prohibited. If you have received this in error, 
please notify the sender immediately and delete it from your system. 
Communications using this system are monitored and recorded for lawful business 
purposes.
IMPORTANT LEGAL NOTICE

This message is intended only for the use of the named addressee. It may 
contain information that is copywritten, privileged, confidential and exempt 
from disclosure under applicable law. If you are not the intended recipient, 
you are notified that any dissemination, distribution or copying of this 
communication is strictly prohibited. If you have received this in error, 
please notify the sender immediately and delete it from your system. 
Communications using this system are monitored and recorded for lawful business 
purposes.
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Struggling with a library

2012-03-27 Thread Tribble, Brett
Do you have the same versions of .NET installed on both machines?

From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Juanma 
Belda
Sent: Tuesday, March 27, 2012 8:52 AM
To: pythondotnet@python.org
Subject: [Python.NET] Struggling with a library

Dear all,

I'm a newbie in pythonnet and I have the following problem.
I am trying to load an assembly from a .dll file.
Currently I am running the trials over Windows XP and python 2.6.5 and 
pythonnet version 2.0 alpha 2

On my computer there is no problem on loading the library. However in another 
computer (notebook) with the same installation (the library in the path etc) 
the system fails to do the AddReference. However if I ask for findAssemblies 
the system is able to find it. I can add the Reference to the test dll that 
come with the pythonnet.

I was assuming a mismatch on the .net versions, but then: why can l loaded from 
some computers and not from some others?

Kind regards,

--
Juanma
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Struggling with a library

2012-03-29 Thread Tribble, Brett
Hmmm, here are a couple more ideas:

Are both machines 32 or 64 bit? Are both copies of Python also 32 or 64 bit? 
You could be attempting to load a 32 bit dll on a 64 bit machine, or visa 
versa. In theory, if the assembly is C#, or VB.NET, you can compile the 
assembly for "Any CPU", and it should work on both. Alternatively, you could 
use 32bit Python on both machines, and explicitly compile the assembly for x86 
(32bit).

I have also found that loading assemblies is also much more reliable if the 
internal namespace of the assembly matches the name of the resulting .dll.

From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Juanma 
Belda
Sent: Thursday, March 29, 2012 1:31 AM
To: pythondotnet@python.org
Subject: Re: [Python.NET] Struggling with a library

Checked. I have Microsfot .NET framework 2.0 Service Pack 2 and Microsoft .NET 
framewor 3.0 Service Pack 2 on both computers.

Kind regards


2012/3/27 Tribble, Brett mailto:btrib...@ea.com>>
Go to Windows Update and make sure that all versions of .NET are installed.

From: Juanma Belda [mailto:jmbeldal...@gmail.com<mailto:jmbeldal...@gmail.com>]
Sent: Tuesday, March 27, 2012 12:50 PM
To: Tribble, Brett
Subject: Re: [Python.NET] Struggling with a library

Sorry for my ignorance. If I type:

print System.Version()

I get: 0.0

This in the machine where everything rules (I don't have access to the others 
from home)


2012/3/27 Tribble, Brett mailto:btrib...@ea.com>>
Do you have the same versions of .NET installed on both machines?

From: pythondotnet-bounces+btribble=ea@python.org<mailto:ea@python.org> 
[mailto:pythondotnet-bounces+btribble<mailto:pythondotnet-bounces%2Bbtribble>=ea@python.org<mailto:ea@python.org>]
 On Behalf Of Juanma Belda
Sent: Tuesday, March 27, 2012 8:52 AM
To: pythondotnet@python.org<mailto:pythondotnet@python.org>
Subject: [Python.NET] Struggling with a library

Dear all,

I'm a newbie in pythonnet and I have the following problem.
I am trying to load an assembly from a .dll file.
Currently I am running the trials over Windows XP and python 2.6.5 and 
pythonnet version 2.0 alpha 2

On my computer there is no problem on loading the library. However in another 
computer (notebook) with the same installation (the library in the path etc) 
the system fails to do the AddReference. However if I ask for findAssemblies 
the system is able to find it. I can add the Reference to the test dll that 
come with the pythonnet.

I was assuming a mismatch on the .net versions, but then: why can l loaded from 
some computers and not from some others?

Kind regards,

--
Juanma


_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] DataGridView Issue

2012-06-28 Thread Tribble, Brett
Can Person derive from System.Collections.Arraylist instead of a System.Object?

http://msdn.microsoft.com/en-us/library/system.collections.arraylist(v=vs.71).aspx



From: pythondotnet-bounces+btribble=ea@python.org 
[mailto:pythondotnet-bounces+btribble=ea@python.org] On Behalf Of Manfred 
Schulte-Oversohl
Sent: Thursday, May 31, 2012 10:19 AM
To: pythondotnet@python.org
Subject: [Python.NET] DataGridView Issue

With Ironpython 2.7 the following code works. Not so with python for .Net where 
only a blank Form is displayed.
Used python for .Net is compiled from trunk of May 26, 2012 python 2.6 and clr4.

Any help is appreciated.

Cheers
Manfred
#-

import clr

clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')

import System.Windows.Forms as WinForms
import System
from System.Drawing import Size, Point

SAMPLE_DATA = [
('Joe', 23),
('Bob', 8),
('Thomas', 32),
('Patrick', 41),
('Kathy', 19),
('Sue', 77),
]

class Person(System.Object):
def __init__(self, name, age):
self.Name = name
self.Age = age

people = []
for name, age in SAMPLE_DATA:
people.append(Person(name, age))

f=WinForms.Form()
f.Text = u"DataGridView From Python"
h = WinForms.SystemInformation.CaptionHeight
fdgv=WinForms.DataGridView()
fdgv.AutoSize = True
fdgv.Dock = WinForms.DockStyle.Fill
fdgv.DataSource = people
fdgv.Refresh()
f.Controls.Add(fdgv)
WinForms.Application.Run(f)
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Problem to use a dll: System.ApplicationException: Error 1: OpenDevice: Invalid handle

2013-01-15 Thread Tribble, Brett
I assume you don't have the source to the .dll?

If you do, you can add a line to use debug the error using 
System.Diagnostics.Debugger.Break():

http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx



From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Daniel Krause
Sent: Tuesday, January 15, 2013 12:42 PM
To: pythondotnet@python.org
Subject: [Python.NET] Problem to use a dll: System.ApplicationException: Error 
1: OpenDevice: Invalid handle

I am trying to use a dll to control a camera.
It is possible for me to use the dll with ironpython, but I fail to use it with 
python for .NET (CLR 4.0).
(And I would like to use e.g. numpy as well, so I need python for .NET).

Below follow a short test script, the python / ironpython versions and their 
console output when running the test script.

Any hints are welcome.
Thank you
Daniel


#test script "testcam.py" #1 for python for .NET
import clr
import sys
sys.path.append("C:\\Users\\mdk\\workspace\\camera\\")
clr.AddReference("xiAPI40.NET")
from xiApi.NET import *
cam = xiCam()
cam.OpenDevice(0)
print cam.GetParamString(PRM.DEVICE_NAME) #print device name

###
#console output showing the python version,
#installed is .NET-support with pythonnet-2.0dev.clr4.0.win-amd64-py2.7.exe on 
Win7 64bit
PS C:\Users\mdk\workspace\camera> python.exe
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.


###
#running test script #1 with python, console output
Traceback (most recent call last):
  File "C:\Users\mdk\workspace\camera\testcam.py", line 8, in 
cam.OpenDevice(0)
System.ApplicationException: Error 1: OpenDevice: Invalid handle
   at xiApi.NET.xiCam.throwException(Int32 errNum, String param)

   at xiApi.NET.xiCam.OpenDevice(Int32 DevID)

##
#test script "testcam.py" #1 modified for ironpython, test script #2
import clr
import sys
sys.path.append("C:\\Users\\mdk\\camera\\")
clr.AddReference("xiAPI40.NET.dll")
from xiApi.NET import *
cam = xiCam()
cam.OpenDevice(0)
print cam.GetParamString(PRM.DEVICE_NAME)   #print device name

###
#console output showing the ironpython version
PS C:\Users\mdk\workspace\camera> ipy.exe
IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.17929
Type "help", "copyright", "credits" or "license" for more information.
>>>

##
#running test script #2 with ironpython, console output
MQ013MG-E2
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Problem to use a dll: System.ApplicationException: Error 1: OpenDevice: Invalid handle

2013-01-16 Thread Tribble, Brett
How does it differ from the working ironpython environment?

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Daniel Krause
Sent: Wednesday, January 16, 2013 11:49 AM
To: pythondotnet@python.org
Subject: Re: [Python.NET] Problem to use a dll: System.ApplicationException: 
Error 1: OpenDevice: Invalid handle

Hi Brett,

to check your suggestion I added a print statement to the script (after 
clr.AddReference("xiAPI40.NET"):

print sys.path

The result looks ok to me:

['C:\\Users\\mdk\\workspace\\camera\\', 
'C:\\Python27\\lib\\site-packages\\distribute-
0.6.21-py2.7.egg', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib
\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 
'C:\\Python27\\lib\\si
te-packages', 'C:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg-inf
o', 'C:\\Users\\mdk\\.eclipse\\org.eclipse.platform_4.2.0_248562372\\plugins\\or
g.python.pydev_2.7.1.2012100913\\pysrc\\pydev_sitecustomize', 'C:\\Windows\\syst
em32\\python27.zip', 'C:\\Python27\\lib\\site-packages\\PIL', 'C:\\Python27\\lib
\\plat-win', 
'C:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg-info
', 'C:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg-info', 'C:\\Wi
ndows\\Microsoft.NET\\Framework64\\v4.0.30319\\']

I also copied the folder to a temp folder and run the script from there without 
adding the new path explicitly to the python path.

The new location is then automatically added to the path, and the console 
output looks the similar.

C:\temp\camera> python.exe .\testcam.py
['C:\\temp\\camera', 
'C:\\Python27\\lib\\site-packages\\distribute-0.6.21-py2.7.egg', 
'C:\\Windows\\system32\\python27.z
ip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 
'C:\\Python27\\lib\\lib-tk', 'C:\\Python2
7', 'C:\\Python27\\lib\\site-packages', 
'C:\\Python27\\lib\\site-packages\\PIL', 'C:\\Python27\\lib\\site-packages\\setu
ptools-0.6c11-py2.7.egg-info', 
'C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\', 
'C:\\Users\\mdk\\workspace\\camera\\']
Traceback (most recent call last):
  File ".\testcam.py", line 9, in 
cam.OpenDevice(0)
System.ApplicationException: Error 1: OpenDevice: Invalid handle
   at xiApi.NET.xiCam.throwException(Int32 errNum, String param)
   at xiApi.NET.xiCam.OpenDevice(Int32 DevID)

Best regards
Daniel
2013/1/15 Tribble, Brett mailto:btrib...@ea.com>>
You might try making and swapping in a simple assembly that opens a command 
prompt so that you can inspect the environment variables. For me, this is 
almost always a system path / current directory issue. Hopefully I'm not 
leading you down a false road.

From: m.daniel.kra...@googlemail.com<mailto:m.daniel.kra...@googlemail.com> 
[mailto:m.daniel.kra...@googlemail.com<mailto:m.daniel.kra...@googlemail.com>] 
On Behalf Of Daniel Krause
Sent: Tuesday, January 15, 2013 1:44 PM
To: Tribble, Brett
Subject: Re: [Python.NET] Problem to use a dll: System.ApplicationException: 
Error 1: OpenDevice: Invalid handle

No, I don't have the source, only the dll.

But thanks for the sugggestion.
Daniel

2013/1/15 Tribble, Brett mailto:btrib...@ea.com>>
I assume you don't have the source to the .dll?

If you do, you can add a line to use debug the error using 
System.Diagnostics.Debugger.Break():

http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx



From: PythonDotNet 
[mailto:pythondotnet-bounces+btribble<mailto:pythondotnet-bounces%2Bbtribble>=ea@python.org<mailto:ea@python.org>]
 On Behalf Of Daniel Krause
Sent: Tuesday, January 15, 2013 12:42 PM
To: pythondotnet@python.org<mailto:pythondotnet@python.org>
Subject: [Python.NET] Problem to use a dll: System.ApplicationException: Error 
1: OpenDevice: Invalid handle

I am trying to use a dll to control a camera.
It is possible for me to use the dll with ironpython, but I fail to use it with 
python for .NET (CLR 4.0).
(And I would like to use e.g. numpy as well, so I need python for .NET).

Below follow a short test script, the python / ironpython versions and their 
console output when running the test script.

Any hints are welcome.
Thank you
Daniel


#test script "testcam.py" #1 for python for .NET
import clr
import sys
sys.path.append("C:\\Users\\mdk\\workspace\\camera\\")
clr.AddReference("xiAPI40.NET")
from xiApi.NET import *
cam = xiCam()
cam.OpenDevice(0)
print cam.GetParamString(PRM.DEVICE_NAME) #print device name

###
#console output showing the python version,
#installed is .NET-support with p

Re: [Python.NET] Problem with System.ArgumentException in call to method from dll

2013-01-22 Thread Tribble, Brett
Did you try:

from System.Windows.Media.Imaging import BitmapSource
bitmapsrc = BitmapSource()   # <- set to an instance of type BitmapSource, not 
the class.
cam.GetImage(bitmapsrc, timeout)

If you need to pass it a variable that is of type BitmapSource, but which is 
set to null, then you might be able to use System.Reflection to do this, but I 
haven't tried...

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Daniel Krause
Sent: Tuesday, January 22, 2013 1:11 PM
To: pythondotnet@python.org
Subject: Re: [Python.NET] Problem with System.ArgumentException in call to 
method from dll

That is right, I want to get the value of the output parameter.

The following variant looks much more logical to me, but than I get another 
error:
bitmapsrc = cam.GetImage(timeout)
TypeError: No method matches given arguments

So it seems that I have to pass the "out"-parameter to the method as well, but 
that was not working either.


2013/1/22 b...@fie.us mailto:b...@fie.us>>
You are setting the bitmapsrc variable to be equal to the class BitmapSource.  
I assume you mean to get the value of an output parameter, rather than pass a 
class object into the method.

Though I do not speak german.  But I think that's it.

On Jan 22, 2013, at 2:58 PM, Daniel Krause 
mailto:m.daniel.kra...@googlemail.com>> wrote:

> I want to use a method from an API to control a camera (xiApi.NETX64.dll).
>
> The method is described in two ways:
> //
> void GetImage( out WriteableBitmap image, int timeout)
> Description : This function acquires image and returns fills WritableBitmap 
> object. Supports UNSAFE buffer policy mode.
> Parameters :
> out WriteableBitmap image : WPF BitmapSource to be filled.
> int timeout : Time interval required to wait for the image (in milliseconds).
> //
> void GetImage(WriteableBitmap image, int timeout)
> Description : This function acquires image and returns fills WritableBitmap 
> object. Supports SAFE buffer policy mode.
> Parameters :
> WriteableBitmap image : WPF BitmapSource to be filled.
> int timeout : Time interval required to wait for the image (in milliseconds).
> //
>
> The code in a c#-sample looks like this (I skipped the initialisation of 
> myCam, but if it helps I can provide the complete code):
> //
> using System.Windows.Media.Imaging;
> int timeout = 1;
> BitmapSource myBitmapSrc;
> myCam.GetImage(out myBitmapSrc, timeout);
> //
> This code I can compile, and it is working.
>
> I tried to keep the python code as close as possible, but I get errors I do 
> not understand:
> ##
> import clr
> import sys
> sys.path.append("C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\WPF")
> clr.AddReference("PresentationCore")
> clr.AddReference("xiAPI.NETX64")
> from xiApi.NET import *
> from System.Windows.Media.Imaging import BitmapSource
> bitmapsrc = BitmapSource
> print bitmapsrc
> cam = xiCam()
> cam.OpenDevice(0)
> cam.SetParam(PRM.BUFFER_POLICY, BUFF_POLICY.SAFE)
> cam.SetParam(PRM.IMAGE_DATA_FORMAT,  IMG_FORMAT.MONO8)
> cam.StartAcquisition()
> timeout = 1000
> bitmapsrc = cam.GetImage(bitmapsrc, timeout)
> cam.StopAcquisition()
> ##
>
> Console output:
> 
> Traceback (most recent call last):
>   File "C:\Users\mdk\workspace\camera\testbitmap.py",
> line 17, in 
> bitmapsrc = cam.GetImage(bitmapsrc, timeout)
> System.ArgumentException: Das Objekt mit dem Typ "System.RuntimeType" kann 
> nicht
>  in den Typ "System.Drawing.Bitmap&" konvertiert werden.
>bei System.RuntimeType.TryChangeType(Object value, Binder binder, 
> CultureInfo
>  culture, Boolean needsSpecialCast)
>
>bei System.Reflection.MethodBase.CheckArguments(Object[] parameters, 
> Binder b
> inder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
>
>bei System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, 
> Bind
> ingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
>
>bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags 
> invok
> eAttr, Binder binder, Object[] parameters, CultureInfo culture)
>
>bei Python.Runtime.MethodBinder.Invoke(IntPtr inst, IntPtr args, IntPtr 
> kw, M
> ethodBase info, MethodInfo[] methodinfo)
> _
> Python.NET mailing list - 
> PythonDotNet@python.org
> http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Problem with System.ArgumentException in call to method from dll

2013-01-23 Thread Tribble, Brett
My personal solution would be to wrap the camera code in a very thin assembly 
that manages this stuff and provides a clean interface for python.net to hook 
into. I'm lazy that way though...

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Daniel Krause
Sent: Tuesday, January 22, 2013 10:08 PM
To: pythondotnet@python.org
Subject: Re: [Python.NET] Problem with System.ArgumentException in call to 
method from dll

@Brett

When I try

bitmapsrc = BitmapSource()

I get the following error:

Traceback (most recent call last):
  File "C:\Users\mdk\workspace\\camera\testbitmap.py", line 8, in 
bitmapsrc = BitmapSource()
TypeError: cannot instantiate abstract class

I will have a look at System.Reflection, thanks for the hint.

@Brad
The documentation does not say anything about "safe" or "unsafe". I do not have 
the source for the dll, only for the examples shipped with the dll. If you 
would like to have a look at them, I could send them to you.


Daniel

2013/1/23 b...@fie.us mailto:b...@fie.us>>
Just to clarify: neither version of the methods you are calling are marked 
"unsafe" in the proper c# .net manner are they?  I would not be surprised to 
find PythonNet not providing access to "unsafe" methods.  I would need to take 
a trip through the source to verify.

On Jan 22, 2013, at 4:10 PM, Daniel Krause 
mailto:m.daniel.kra...@googlemail.com>> wrote:


That is right, I want to get the value of the output parameter.

The following variant looks much more logical to me, but than I get another 
error:
bitmapsrc = cam.GetImage(timeout)
TypeError: No method matches given arguments

So it seems that I have to pass the "out"-parameter to the method as well, but 
that was not working either.


2013/1/22 b...@fie.us mailto:b...@fie.us>>
You are setting the bitmapsrc variable to be equal to the class BitmapSource.  
I assume you mean to get the value of an output parameter, rather than pass a 
class object into the method.

Though I do not speak german.  But I think that's it.

On Jan 22, 2013, at 2:58 PM, Daniel Krause 
mailto:m.daniel.kra...@googlemail.com>> wrote:

> I want to use a method from an API to control a camera (xiApi.NETX64.dll).
>
> The method is described in two ways:
> //
> void GetImage( out WriteableBitmap image, int timeout)
> Description : This function acquires image and returns fills WritableBitmap 
> object. Supports UNSAFE buffer policy mode.
> Parameters :
> out WriteableBitmap image : WPF BitmapSource to be filled.
> int timeout : Time interval required to wait for the image (in milliseconds).
> //
> void GetImage(WriteableBitmap image, int timeout)
> Description : This function acquires image and returns fills WritableBitmap 
> object. Supports SAFE buffer policy mode.
> Parameters :
> WriteableBitmap image : WPF BitmapSource to be filled.
> int timeout : Time interval required to wait for the image (in milliseconds).
> //
>
> The code in a c#-sample looks like this (I skipped the initialisation of 
> myCam, but if it helps I can provide the complete code):
> //
> using System.Windows.Media.Imaging;
> int timeout = 1;
> BitmapSource myBitmapSrc;
> myCam.GetImage(out myBitmapSrc, timeout);
> //
> This code I can compile, and it is working.
>
> I tried to keep the python code as close as possible, but I get errors I do 
> not understand:
> ##
> import clr
> import sys
> sys.path.append("C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\WPF")
> clr.AddReference("PresentationCore")
> clr.AddReference("xiAPI.NETX64")
> from xiApi.NET import *
> from System.Windows.Media.Imaging import BitmapSource
> bitmapsrc = BitmapSource
> print bitmapsrc
> cam = xiCam()
> cam.OpenDevice(0)
> cam.SetParam(PRM.BUFFER_POLICY, BUFF_POLICY.SAFE)
> cam.SetParam(PRM.IMAGE_DATA_FORMAT,  IMG_FORMAT.MONO8)
> cam.StartAcquisition()
> timeout = 1000
> bitmapsrc = cam.GetImage(bitmapsrc, timeout)
> cam.StopAcquisition()
> ##
>
> Console output:
> 
> Traceback (most recent call last):
>   File "C:\Users\mdk\workspace\camera\testbitmap.py",
> line 17, in 
> bitmapsrc = cam.GetImage(bitmapsrc, timeout)
> System.ArgumentException: Das Objekt mit dem Typ "System.RuntimeType" kann 
> nicht
>  in den Typ "System.Drawing.Bitmap&" konvertiert werden.
>bei System.RuntimeType.TryChangeType(Object value, Binder binder, 
> CultureInfo
>  culture, Boolean needsSpecialCast)
>
>bei System.Reflection.MethodBase.CheckArguments(Object[] parameters, 
> Binder b
> inder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
>
>bei System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, 
> Bind
> ingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
>
>bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags 
> invok
> eAttr, Binder binder, Object[] parameters, CultureInfo culture)
>
>bei Python.Runtime.MethodBinder.Invoke(IntPtr inst, IntPtr args, Int

Re: [Python.NET] How to pass a Type to a method?

2013-01-24 Thread Tribble, Brett
I don't think the python.net clr module supports most of the methods etc. that 
the IronPython one does:

http://nullege.com/codes/search/clr

Can you use the following instead?

import System
...

...
array = Array.CreateInstance(System.Int32, rows, columns)

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Daniel Krause
Sent: Thursday, January 24, 2013 12:11 PM
To: pythondotnet@python.org
Subject: [Python.NET] How to pass a Type to a method?

I would like to use System.Array.

The following code is running with iron python

import clr
import System
from System import Array
from System import Int32
from clr import GetClrType
rows = 1
columns = 2
#method: Array.CreateInstance(Type, Int32, Int32)
array = Array.CreateInstance(GetClrType(Int32), rows, columns)
print array.GetLength(0)
print array.GetLength(1)

ouptput:
1
2

The same code throws an import error in python for .NET
from clr import GetClrType
ImportError: cannot import name GetClrType

Is another syntax for python for .Net necessary?
Or is there perhaps another method to pass a Type to a method?
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Python 3 version of Python for .NET

2013-02-26 Thread Tribble, Brett
This is crazy talk!

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Tony Roberts
Sent: Tuesday, February 26, 2013 3:31 AM
To: pythondotnet@python.org
Subject: [Python.NET] Python 3 version of Python for .NET

Hi,

I've made the necessary changes to the Python for .NET package for it to work 
with Python 3.

What's the best way to get this integrated back into the main project? Can I 
get access to the svn repo and check it into a branch for peer review and 
integration? Or should I email someone a patch file?

thanks,
Tony
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Python 3 version of Python for .NET

2013-02-28 Thread Tribble, Brett
Barton is probably the one to help you out. He'll likely respond shortly.

From: Tony Roberts [mailto:t...@pyxll.com]
Sent: Thursday, February 28, 2013 7:24 AM
To: Tribble, Brett
Cc: pythondotnet@python.org
Subject: Re: [Python.NET] Python 3 version of Python for .NET

Hi,

I've built eggs for python 2.7, 3.2 and 3.3 (windows x86 and x64) and made them 
available here:
http://www.pyxll.com/pythonnet/

If someone can let me know how to contribute these changes back to the main 
project I'm happy to do that. The changes are backwards compatible so 
everything still works the same with older versions of python.

cheers,
Tony

On Tue, Feb 26, 2013 at 6:35 PM, Tribble, Brett 
mailto:btrib...@ea.com>> wrote:
This is crazy talk!

From: PythonDotNet 
[mailto:pythondotnet-bounces+btribble<mailto:pythondotnet-bounces%2Bbtribble>=ea@python.org<mailto:ea@python.org>]
 On Behalf Of Tony Roberts
Sent: Tuesday, February 26, 2013 3:31 AM
To: pythondotnet@python.org<mailto:pythondotnet@python.org>
Subject: [Python.NET] Python 3 version of Python for .NET

Hi,

I've made the necessary changes to the Python for .NET package for it to work 
with Python 3.

What's the best way to get this integrated back into the main project? Can I 
get access to the svn repo and check it into a branch for peer review and 
integration? Or should I email someone a patch file?

thanks,
Tony

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] C# dynamic object support / Easy calling from C#

2013-07-05 Thread Tribble, Brett
Star Trek jokes, yeah, heard those...

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Mark Tigges
Sent: Friday, July 05, 2013 7:49 AM
To: Patrick Stewart
Cc: pythondotnet@python.org
Subject: Re: [Python.NET] C# dynamic object support / Easy calling from C#

Nice work captain! (sorry, couldn't resist.)

On Tue, Jul 2, 2013 at 2:35 AM, Patrick Stewart 
mailto:pats...@gmail.com>> wrote:
Hi,
Just thought I'd send a heads up to say I've made some modifications to 
python.net to make it much more convenient to call python 
code from C#, which can be found here: http://github.com/patstew/pythonnet
I've inherited PyObject from DynamicObject, wired up the appropriate bits and 
added a few convenience functions, so now you can write C# code like this:

static void Main(string[] args)
{
using (Py.GIL()) {
dynamic np = Py.Import("numpy");
dynamic sin = np.sin;
Console.WriteLine(np.cos(np.pi*2));
 Console.WriteLine(sin(5));
Console.WriteLine(np.cos(5) + sin(5));
dynamic a = np.array(new List { 1, 2, 3 };
dynamic b = np.array(new List { 6, 5, 4 }, Py.kw("dtype", np.int32));
 Console.WriteLine(a.dtype);
Console.WriteLine(b.dtype);
Console.WriteLine(a * b);
Console.ReadKey();
}
}

which outputs:

1.0
-0.958924274663
-0.6752620892
float64
int32
[  6.  10.  12.]

as you might expect. You can call, access members and perform mathematical 
operations all as normal. Managed arguments are automatically converted to 
python types when used with a python function, and mathematical operations like 
multiplying numpy arrays happen entirely within python. You can specify keyword 
arguments using Py.kw("key1", value1, "key2", value2, ) as an extra 
argument to the function. One slight annoyance is that np.pi*2 works while 
2*np.pi doesn't, due to limitations of DynamicObject.
This is just a first shot, and I haven't actually used it much yet, so there 
are almost certainly bugs, leaked references, etc lurking. I'll probably keep 
adding to it in the near future. Hope it's useful to someone.
Cheers,
Patrick

_
Python.NET mailing list - 
PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] debugging

2013-07-22 Thread Tribble, Brett
I would love to hear some good answers to this. I've been able to use 
PTVS/Visual Studio to debug either python or .NET, but trying to cross the 
bridge between the two leaves you debugging pythondotnet, and not the .NET 
project you actually want to debug.

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Jason Sachs
Sent: Monday, July 22, 2013 11:56 AM
To: pythondotnet@python.org
Subject: [Python.NET] debugging

Hi there--

I've used Python a lot but am new to pythondotnet. I got it running on Windows 
7 with no problem, by unzipping the download file, making sure PYTHONPATH and 
PYTHONHOME were setup properly, and running npython.exe.

How do you get it to run in a debugger? (either PyDev on Eclipse, or Microsoft 
PTVS)

Also, is there a way to install it "permanently" in an existing Python 
installation so that it will pickup the pythondotnet bridge when you run the 
regular "python.exe"?

--Jason
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] debugging

2013-07-22 Thread Tribble, Brett
I'm guessing that yes, it is Reflection. I'm sure I could cobble together 
something that works, but I haven't wanted to spend the time to play with it 
that much. I'm pretty used to debugging by instrumenting code with a ton of 
logging and "print statements" regardless.

From: Bradley Friedman [mailto:b...@fie.us]
Sent: Monday, July 22, 2013 1:39 PM
To: Tribble, Brett
Cc: Jason Sachs; pythondotnet@python.org
Subject: Re: [Python.NET] debugging

I'm intrigued by this Brett.  Is it that all the .NET Reflection gets in the 
way?  I could certainly see that being a problem.  Though I'd think you could 
get around it by setting break points at the entry points of concern?  This is 
always a problem for these kinds of cross language bridges.  Often each 
language consumes exceptions from the other and eliminates the "uncaught 
exception" as a useful debug tool.  Though hard-core developers will often 
suggest that uncaught exceptions should never be allowed anyway.  So maybe 
that's not really a problem.

An example would be very interesting to see if nothing else.

On Jul 22, 2013, at 3:32 PM, "Tribble, Brett" 
mailto:btrib...@ea.com>> wrote:


but trying to cross the bridge between the two leaves you debugging 
pythondotnet, and not the .NET project you actually want to debug.

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] debugging

2013-07-22 Thread Tribble, Brett
Yeah, I need to upgrade to the 2.0 beta. It's nice to see that pythondotnet has 
PTVS devs watching it. PTVS is one of the cooler things to come out of 
Microsoft!

From: Bradley Friedman [mailto:b...@fie.us]
Sent: Monday, July 22, 2013 2:10 PM
To: Tribble, Brett
Cc: Jason Sachs; pythondotnet@python.org
Subject: Re: [Python.NET] debugging

it looks like there's something similar to the WingIDE solution, for PTVS

http://pytools.codeplex.com/wikipage?title=Remote%20Debugging%20for%20Windows%2c%20Linux%20and%20OS%20X

-brad

On Jul 22, 2013, at 5:05 PM, Bradley Friedman mailto:b...@fie.us>> 
wrote:


Yea I usually do that until I give up and go through the trouble of setting up 
a complex debugging environment.  Usually it's caused by trying to debug Python 
code inside of Maya.  And I end up wrapping entry points in calls to the 
debugger.  Since I'm usually using WingIDE for that, it's usually done this way:

http://wingware.com/doc/debug/importing-the-debugger

Likewise, when I'm stuck on a Python <--> .NET debugging problem, I usually do 
the same if my main entry point was a .NET one.

If it's the other way around, I'm usually attaching mono-develop manually or VS 
manually.  But the key in that case is to have breakpoints set.  I've not 
really found a great way to launch .NET remote debugging from within a .NET 
runtime.  But I do think the best solution will none-the-less, be a remote 
debugging styled solution, like it is handled in WingIDE.  Or, how something 
like Unity3D handles mono debugging as remote debugging.  I have messed around 
with the Debugging classes inside of .NET a little bit.  And they can be useful 
for things like making your app pause until a debugger is attached, and such.

On Jul 22, 2013, at 4:48 PM, "Tribble, Brett" 
mailto:btrib...@ea.com>> wrote:


I'm guessing that yes, it is Reflection. I'm sure I could cobble together 
something that works, but I haven't wanted to spend the time to play with it 
that much. I'm pretty used to debugging by instrumenting code with a ton of 
logging and "print statements" regardless.



_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] C# path for 3rd-party libraries?

2013-07-23 Thread Tribble, Brett
I think you can register them in the GAC as well, but this is a pain in the 
butt to maintain.

http://en.wikipedia.org/wiki/Global_Assembly_Cache

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Jason Sachs
Sent: Tuesday, July 23, 2013 2:06 PM
To: pythondotnet@python.org
Subject: Re: [Python.NET] C# path for 3rd-party libraries?

Never mind, I figured it out, you just have to make sure the .dll files are in 
the PYTHONPATH.

On Tue, Jul 23, 2013 at 1:45 PM, Jason Sachs 
mailto:jmsa...@gmail.com>> wrote:
I got the pythonnet libraries installed and working with my Python 
installation, and I can do

  import clr
  import System

without errors, but when I go to import a 3rd-party .NET library I have 
installed, it can't find it:

>>> import clr
>>> import System
>>> import OpenLayers.Base
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named OpenLayers.Base
>>>

How do I tell pythonnet where .NET libraries are? I have essentially no 
background with .NET, I'm familiar with Java so there are a lot of parallels 
but I don't understand how to make these libraries visible to Python.

_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] ImportError: dynamic module does not define init function (PyInit_CLR)

2013-08-20 Thread Tribble, Brett
Python for .NET is in a superpositional state in which it is both working and 
not working. You just collapsed its wave function prematurely. Also you didn't 
which is why we're also not having this conversation.

Addressing the question not clearly at hand, support for Python 3.x is pretty 
green still. You might try grabbing Tony Robert's build that has tentative 
support:

On 5 Jul 2013 07:01, "Tony Roberts" mailto:t...@pyxll.com>> 
wrote:
Yes, I made some changes to get it working in Python 3 a while ago. The code's 
on github: https://github.com/tonyroberts/pythonnet.

I've tested it with 3.3 x64 and it works ok for me (although I've only really 
used the 3.2 x64 build extensively).

regards,
Tony



From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Catherine Holloway
Sent: Tuesday, August 20, 2013 1:06 PM
To: pythondotnet@python.org
Subject: [Python.NET] ImportError: dynamic module does not define init function 
(PyInit_CLR)

When I try to do:

import CLR

I get the following error:

ImportError: dynamic module does not define init function (PyInit_CLR)

any ideas? I downloaded what I thought was the windows installer from 
sourceforge, but running nPython.exe just crashes (it gives something about not 
being able to find python27). I have python33. Does that mean that python for 
.net is not compatible with python 3.3.?

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Catherine Holloway
Institute for Quantum Computing
Lab Phone: 519-888-4567 ext. 32107
Office Phone: 519-888-4567 ext. 39038
Cell Phone: 519-998-1264
_
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Moving the project to github

2013-11-12 Thread Tribble, Brett
I'm all for having it reside wherever it is easiest to continue development!

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of John Gill
Sent: Tuesday, November 12, 2013 5:29 AM
To: pythondotnet@python.org
Subject: [Python.NET] Moving the project to github

As has been mentioned on the list here, Tony Roberts' version in github is 
currently the most actively maintained version of python dot net:

https://github.com/renshawbay/pythonnet/

As I understand things, the original author, Brian Lloyd is still active in the 
project, but has less time to work on it than previously.

It would be good if work could consolidate on a single source base.I think 
moving to github would help with that, certainly makes merging Tony's changes 
with the official release easier.

This is a really useful project, I am finding it wonderful to be able to use 
.NET and cpython seamlessly + it would be good not to fragment the user base by 
having multiple versions of the code.

John
This communication and any attachments contain information which is 
confidential and may also be legally privileged. It is for the exclusive use of 
the intended recipient(s). If you are not the intended recipient(s) please note 
that any form of disclosure, distribution, copying, printing or use of this 
communication or the information in it or in any attachments is strictly 
prohibited and may be unlawful. If you have received this communication in 
error, please return it with the title "received in error" to 
postmas...@tokiomillennium.com and then 
permanently delete the email and any attachments from your system.


E-mail communications cannot be guaranteed to be secure or error free, as 
information could be intercepted, corrupted, amended, lost, destroyed, arrive 
late or incomplete, or contain viruses. It is the recipient's responsibility to 
ensure that e-mail transmissions and any attachments are virus free. We do not 
accept liability for any damages or other consequences caused by information 
that is intercepted, corrupted, amended, lost, destroyed, arrives late or 
incomplete or contains viruses.
**
_
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] PTVS and python.NET

2013-11-26 Thread Tribble, Brett
So, who is willing to be the primary maintainer of the github repository? I 
think we should wait for a little while to see if Brian or Barton respond. I 
see that tiran has a github account as well: https://github.com/tiran

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of davidacoder
Sent: Tuesday, November 26, 2013 6:37 AM
To: pythondotnet@python.org
Subject: Re: [Python.NET] PTVS and python.NET

Great idea!

Best,
David

From: PythonDotNet 
[mailto:pythondotnet-bounces+davidacoder=hotmail@python.org] On Behalf Of 
John Gill
Sent: Tuesday, November 26, 2013 7:47 AM
To: pythondotnet@python.org
Subject: [Python.NET] PTVS and python.NET

Related to a move to github, I have been in touch with the maintainer of PTVS 
asking if they are aware of this project.  It seems such a natural fit.

He would be happy to:


1.   Put a link on our "Related projects" page

2.   Identify some interesting scenarios and do a blog post

3.   Add a dedicated doc page

4.   Etc.

Subject to:


1.   The project is actively maintained

2.   Up to date docs

3.   It "works"

a.   Reliable & robust

b.  Works with PTVS (eg PTVS doesn't crash, ...)

It would be great if PTVS was able to install python .NET for people (the 
current install process "copy these dll's" is simple and effective, but a 
direct install from PTVS would be good.

I think we would need to resolve the current situation with the code split 
between github and sourceforge before we could get the endorsement from PTVS.

John
This communication and any attachments contain information which is 
confidential and may also be legally privileged. It is for the exclusive use of 
the intended recipient(s). If you are not the intended recipient(s) please note 
that any form of disclosure, distribution, copying, printing or use of this 
communication or the information in it or in any attachments is strictly 
prohibited and may be unlawful. If you have received this communication in 
error, please return it with the title "received in error" to 
postmas...@tokiomillennium.com and then 
permanently delete the email and any attachments from your system.


E-mail communications cannot be guaranteed to be secure or error free, as 
information could be intercepted, corrupted, amended, lost, destroyed, arrive 
late or incomplete, or contain viruses. It is the recipient's responsibility to 
ensure that e-mail transmissions and any attachments are virus free. We do not 
accept liability for any damages or other consequences caused by information 
that is intercepted, corrupted, amended, lost, destroyed, arrives late or 
incomplete or contains viruses.
**
_
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] github migration DONE

2014-01-31 Thread Tribble, Brett
Yes! So glad to see this happen.

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Kyle Rocha
Sent: Friday, January 31, 2014 6:43 PM
To: A list for users and developers of Python for .NET
Subject: Re: [Python.NET] github migration DONE


This is great work.

Thanks!
On Jan 31, 2014 4:24 PM, "David Anthoff" 
mailto:anth...@berkeley.edu>> wrote:
Hi all,

I got an ok from Brian and Barton on the github migration, so please consider 
https://github.com/pythonnet/pythonnet the new home for this project.

Please do use the issue tracker to file your ideas, fork the project, create 
pull requests, test the current version etc. Hopefully we can revive this 
project!

If you would want to volunteer with reviewing stuff etc, please let me know, I 
myself don't know the codebase well, so right now I'm just trying to get things 
moving again but it would be good if someone with more familiarity with the 
code would be active as well.

My immediate next goal would be to release a stable version. So my sense is 
that we should not try to do new features, but first get something out that 
works again.

Best,
David

--
David Anthoff
University of California, Berkeley

http://www.david-anthoff.com


_
Python.NET mailing list - 
PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet
_
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] Passing in null as the value for a nullable type.

2014-02-05 Thread Tribble, Brett
I believe you want to import System and pass System.Null. I can't remember if 
I've done this, but I think so.

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of John Gill
Sent: Wednesday, February 05, 2014 8:47 AM
To: pythondotnet@python.org
Subject: [Python.NET] Passing in null as the value for a nullable type.

I am sure there is a really simple answer to this one... but so far it is 
eluding me.

I have a class something like this:

public class Foo
{
  ...
public int process_date(DateTime? mydate)
   {
  ...
   }
}


I want to call this from python using pythondotnet.


Calling it like this works fine:

 mydate = DateTime(0)
 Foo().process_date(mydate)

But if I try to pass in a null as the date as follows:

Foo().process_date(None)

I get:

   TypeError: No method matches given arguments

Hoping there is something really obvious I am missing here.

John
This communication and any attachments contain information which is 
confidential and may also be legally privileged. It is for the exclusive use of 
the intended recipient(s). If you are not the intended recipient(s) please note 
that any form of disclosure, distribution, copying, printing or use of this 
communication or the information in it or in any attachments is strictly 
prohibited and may be unlawful. If you have received this communication in 
error, please return it with the title "received in error" to 
postmas...@tokiomillennium.com and then 
permanently delete the email and any attachments from your system.


E-mail communications cannot be guaranteed to be secure or error free, as 
information could be intercepted, corrupted, amended, lost, destroyed, arrive 
late or incomplete, or contain viruses. It is the recipient's responsibility to 
ensure that e-mail transmissions and any attachments are virus free. We do not 
accept liability for any damages or other consequences caused by information 
that is intercepted, corrupted, amended, lost, destroyed, arrives late or 
incomplete or contains viruses.
**
_
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] WPF and XAML

2014-04-28 Thread Tribble, Brett
I'm sure I've interacted with WPF apps written in C# from python.net. I don't 
think I've tried to write one from scratch. I know that I had trouble trying to 
get Iron Python UI code working in python.net because of how I.P. uses 
attributes to do some of the UI markup, and this did not come through from 
regular python correctly. Remember that you will need to compile python.net 
using a version of .NET that supports WPF (3.0 or greater).

-Original Message-
From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of David Anthoff
Sent: Monday, April 28, 2014 11:41 AM
To: 'A list for users and developers of Python for .NET'
Subject: Re: [Python.NET] WPF and XAML

Hi Min,

I am not sure about that. Have you tried to just interact with the WPF object 
model from Python.Net? That might work. There is certainly nothing specific for 
WPF/XAML in Python.Net. I am not aware of anyone having specific plans on 
improving the Python.Net and WPF/XAML story. But, volunteers are obviously most 
welcome.

Best,
David

-Original Message-
From: PythonDotNet
[mailto:pythondotnet-bounces+anthoff=berkeley@python.org] On Behalf Of Min 
Kim
Sent: Friday, April 25, 2014 6:56 PM
To: pythondotnet@python.org
Subject: [Python.NET] WPF and XAML

Python for .Net does not seem to support development of UIs in WPF/XAML.

Google search shows one question several years ago but without reply.

Is there a trick to making it work or is it in the "to be implemented" list?

Thanks.
_
Python.NET mailing list - PythonDotNet@python.org 
https://mail.python.org/mailman/listinfo/pythondotnet
_
Python.NET mailing list - PythonDotNet@python.org 
https://mail.python.org/mailman/listinfo/pythondotnet

_
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet


Re: [Python.NET] homebrew pythonnet, versus pip install --pre pythonnet

2014-06-03 Thread Tribble, Brett
It has been a while since I've had to deal with this, but make sure that your 
assembly is in the system path and/or pythonpath if it is not registered in the 
GAC.

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Adam Klein
Sent: Tuesday, June 03, 2014 4:02 PM
To: pythondotnet@python.org
Subject: [Python.NET] homebrew pythonnet, versus pip install --pre pythonnet

Hi All,

Amazing library, first of all!

I am experimenting with integrating ipython / numpy / pandas for interactive 
data analysis with our large existing C# codebase. We are using the Anaconda 
2.0 release from ContinuumIO. With `pip install -pre pythonnet`, everything 
goes as expected (great!)

However, when I build from source (in VS2013), point my PYTHONPATH to the 
clr.pyd and Python.Runtime.dll that results from the build, and run my ipython, 
I can do `import clr` and `ref = clr.AddReference("assemblyname")`, but I 
cannot load any modules within this assembly. I get a `ImportError: No module 
named ...` Furthermore, if I try to do ref.ExportedTypes, I get a 
`FileNotFoundException: Could not load file or assembly ...` where it cannot 
find an assembly that is referenced by the original assembly. There must be 
some broken loading going on... Any thoughts why this might have different 
behavior than what I install via PyPI 
(https://pypi.python.org/pypi/pythonnet/2.0.0.dev1)? Or, hints on how to debug?

Thanks!!!

--Adam



This e-mail is intended only for the person or entity to which it is addressed 
and may contain confidential and/or privileged material. Any review, 
retransmission, dissemination or other use of, or taking of any action in 
reliance upon, the information in this e-mail by persons or entities other than 
the intended recipient is prohibited and may be unlawful. If you received this 
in error, please contact the sender and delete the material from any computer.

This communication is for informational purposes only. It is not intended as 
and does not constitute an offer or solicitation for the purchase or sale of 
any financial instrument or as an official confirmation of any transaction. All 
market prices, data and other information are not warranted as to completeness 
or accuracy and are subject to change without notice. Any expected returns are 
provided for illustrative purposes only and are not intended to serve as, and 
must not be relied upon by any prospective investor as, a guaranty, an 
assurance, a prediction of a definitive statement of fact or a probability. 
Investment in funds managed by BlueMountain carries certain risks, including 
the risk of loss of principal. Unless indicated otherwise, performance results 
are presented net of fees and expenses. Certain market and economic events 
having an impact on performance may not repeat themselves. Any comments or 
statements made herein do not necessarily reflect those of BlueMountain Capital 
Management, LLC or its affiliates. PAST PERFORMANCE IS NOT NECESSARILY 
INDICATIVE OF FUTURE RESULTS AND NO REPRESENTATION IS MADE THAT RESULTS SIMILAR 
TO THOSE SHOWN CAN BE ACHIEVED.
_
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] surveying the landscape ...

2015-06-15 Thread Tribble, Brett
Adam, I’m ecstatic that there’s a player out there who is making good use of 
Python.net, and who would like to help contribute. Organizational and 
logistical issues aside, I’m all for anything you can throw at the project! 
Someone correct me if I’m wrong, but I believe Brian Lloyd has largely yielded 
this project to Tony and the community. Based on Brian and  Tony’s past posts, 
I’m fairly sure they’ll welcome any and all contributions to the project.

It may sound sacrilegious to some, but I would love to see the PTVS 
(https://pytools.codeplex.com/) folks get involved with the project. They’re 
turning out a solid product, and this fits solidly in with what Microsoft is 
trying to do with PTVS, .NET Core, Azure etc.


From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Brad Friedman
Sent: Monday, June 15, 2015 2:36 PM
To: A list for users and developers of Python for .NET
Subject: Re: [Python.NET] surveying the landscape ...

I'll chime in and say the lack of these kinds of legitimate "stake-holder" 
systems and responsibilities has forced me to turn away from depending my work 
on this project. I still keep up on it in hopes that it will turn around.  If a 
legitimate player were to step up and contribute to a responsible, active and 
stable future for the project, I'd likely reconsider my stance and begin active 
support again. It's hard to justify putting much into it as one guy with 
limited resources.  It needs full multi-platform release and development 
support both as a python module and a .net embedding toolkit, both for Python 
2.x and 3.x.  That's a lot of work to commit to getting set right and 
maintaining.

On Jun 15, 2015, at 3:57 PM, Adam Klein 
mailto:akl...@bluemountaincapital.com>> wrote:
Hello all,

We are using Python.NET at BlueMountain to interface between 
our large .NET code base and the cpython ecosystem for interactive, exploratory 
computing. By way of background, I was a major contributor to the pandas 
library for a time; my firm is behind the Deedle library 
(https://github.com/BlueMountainCapital/Deedle).
To state the obvious, the project has proven hugely valuable. BlueMountain has 
an interest in making sure the library doesn’t languish. To that end, we’re 
interested in contributing to the project in terms of manpower and possibly 
funding development. I’d like to get a better sense of a few things:

- is there a BDFL … is Brian Lloyd still active; or is Tony Roberts steering 
the ship (being the top code contributor recently on github?) It looks like 
python 3.x integration and more recent work is happening on on 
renshawbay/pythonnet? Is pythonnet/pythonnet still the official repo?
- who manages releases to PyPI?
- is this PythonDotNet mailing list the appropriate clearinghouse for all 
discussions related to the project?
- are there other institutions that are public users of this project?
- is there an official vision or roadmap for future releases?

I see that python 3.x support looks like it’s happening on renshawbay/pythonnet 
(awesome). For other wish-list items or proposed contributions, is it best to 
start opening issues on the pythonnet/pythonnet github site? How are pull 
requests managed?

I’m also wondering if there’s any collective / documented knowledge about the 
inherent limitations and pitfalls of the library and/or where development 
resources are needed?

Best,
  Adam



_
Python.NET mailing list - 
PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet
_
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet

Re: [Python.NET] pythonnet 2.1.0.dev1 released

2015-06-26 Thread Tribble, Brett
Wow, awesome!

From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea@python.org] On 
Behalf Of Tony Roberts
Sent: Friday, June 26, 2015 7:39 AM
To: pythondotnet@python.org
Subject: [Python.NET] pythonnet 2.1.0.dev1 released

Hi,

I've merged the changes from the renshawbay/pythonnet fork into the develop 
branch in pythonnet/pythonnet and released it as 2.1.0.dev1.

Binary wheels for windows (2.6 to 3.4, x86 and x86_64) have been uploaded to 
PyPI, along with the source dist for Linux and Mac. You can install it with pip 
with the --pre argument:

> pip install --pre pythonnet

New features are:
 - Python 3 support
 - Managed types can be sub-classed in Python and have virtual methods 
overridden.
 - Uses dynamic objects for cleaner code when embedding Python
 - Better Linux support (work with or without --enable-shared configure option)

Now the Linux build works for Python built with and without the --enable-shared 
configure option, AFAIK, there's no need for the npython executable anymore so 
I've removed it. If it is still needed for some use case I've not considered 
please let me know and I will reinstate it.

cheers,
Tony


_
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet