Comtypes installation problem...

View: New views
15 Messages — Rating Filter:   Alert me  

Comtypes installation problem...

by David Goncalves-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm trying to install comtypes on Python 2.5 (2007-10 release).
I've copied the "comtypes" folder to "Program files\Python25\Lib".

When i do a "import comtypes" to check if everything is ok, i
get the following message :

function "SafeArrayCreateVectorEx" not found
with a lot of debug informations...

Does anyone already got the same message ?

BTW : I've tested on many machines and on a fresh WM5 with the Device
Emulator
       but the result is the same...


Regards.


_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by Michael Foord-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Goncalves wrote:
> Hi,
>
> I'm trying to install comtypes on Python 2.5 (2007-10 release).
> I've copied the "comtypes" folder to "Program files\Python25\Lib".

That is part of the Win32 extensions for Python which run on the desktop
(with a different CPU and different APIs to your WinCE device).

You would have to recompile especially for WinCE, which would be
'difficult'.

You are much better off using ctypes for PythonCE, which comes with the
latest PythonCE 2.5 I believe.

Michael Foord

>
> When i do a "import comtypes" to check if everything is ok, i
> get the following message :
>
> function "SafeArrayCreateVectorEx" not found
> with a lot of debug informations...
>
> Does anyone already got the same message ?
>
> BTW : I've tested on many machines and on a fresh WM5 with the Device
> Emulator
>       but the result is the same...
>
>
> Regards.
>
>
> _______________________________________________
> PythonCE mailing list
> PythonCE@...
> http://mail.python.org/mailman/listinfo/pythonce


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.resolverhacks.net/
http://www.theotherdelia.co.uk/

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by David Goncalves-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> That is part of the Win32 extensions for Python which run on the desktop
> (with a different CPU and different APIs to your WinCE device).
>
> You would have to recompile especially for WinCE, which would be
> 'difficult'.
>
> You are much better off using ctypes for PythonCE, which comes with the
> latest PythonCE 2.5 I believe.

Thanks for your response.

I installed comtypes because i'm trying to use PyPoom and it seems that
pypoom needs comtypes :(


Then my problem is with pypoom installation...
_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by Sergei Golubchik-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

On Jun 26, David Goncalves wrote:

> Hi,
>
>> That is part of the Win32 extensions for Python which run on the
>> desktop (with a different CPU and different APIs to your WinCE
>> device).  You would have to recompile especially for WinCE, which
>> would be 'difficult'.  You are much better off using ctypes for
>> PythonCE, which comes with the latest PythonCE 2.5 I believe.
>
> Thanks for your response.
>
> I installed comtypes because i'm trying to use PyPoom and it seems that
> pypoom needs comtypes :(
> Then my problem is with pypoom installation...

I've commented out all unknown API functions and could make pypoom
working and happily accessing the addressbook.

Regards
Sergei
_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by David Goncalves-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> I've commented out all unknown API functions and could make pypoom
> working and happily accessing the addressbook.

Nice tip !

I'll try it.

Thanks.


_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by Thomas Heller-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael Foord schrieb:
> David Goncalves wrote:
>> Hi,
>>
>> I'm trying to install comtypes on Python 2.5 (2007-10 release).
>> I've copied the "comtypes" folder to "Program files\Python25\Lib".
>
> That is part of the Win32 extensions for Python which run on the desktop
> (with a different CPU and different APIs to your WinCE device).

No, comtypes is a pure Python COM package, based on ctypes.  No need to
compile anything.

Thomas

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by Thomas Heller-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Goncalves schrieb:

> Hi,
>
> I'm trying to install comtypes on Python 2.5 (2007-10 release).
> I've copied the "comtypes" folder to "Program files\Python25\Lib".
>
> When i do a "import comtypes" to check if everything is ok, i
> get the following message :
>
> function "SafeArrayCreateVectorEx" not found
> with a lot of debug informations...

comtypes uses functions that do not exist on WinCE, and I haven't yet
found the time to fix that.  If someone would like to provide patches
that keep the Windows functionality intact, please go ahead (although
I will be in vacation the next two week, starting tomorrow.

--
Thanks,
Thomas

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by Michael Foord-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thomas Heller wrote:

> Michael Foord schrieb:
>  
>> David Goncalves wrote:
>>    
>>> Hi,
>>>
>>> I'm trying to install comtypes on Python 2.5 (2007-10 release).
>>> I've copied the "comtypes" folder to "Program files\Python25\Lib".
>>>      
>> That is part of the Win32 extensions for Python which run on the desktop
>> (with a different CPU and different APIs to your WinCE device).
>>    
>
> No, comtypes is a pure Python COM package, based on ctypes.  No need to
> compile anything.
>  
Oops - my mistake. Sorry.

Michael

> Thomas
>
> _______________________________________________
> PythonCE mailing list
> PythonCE@...
> http://mail.python.org/mailman/listinfo/pythonce
>  


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.resolverhacks.net/
http://wwww.theotherdelia.co.uk/

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by Michael Foord-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thomas Heller wrote:

> Michael Foord schrieb:
>  
>> David Goncalves wrote:
>>    
>>> Hi,
>>>
>>> I'm trying to install comtypes on Python 2.5 (2007-10 release).
>>> I've copied the "comtypes" folder to "Program files\Python25\Lib".
>>>      
>> That is part of the Win32 extensions for Python which run on the desktop
>> (with a different CPU and different APIs to your WinCE device).
>>    
>
> No, comtypes is a pure Python COM package, based on ctypes.  No need to
> compile anything.
>  
Oops - my mistake. Sorry.

Michael

> Thomas
>
> _______________________________________________
> PythonCE mailing list
> PythonCE@...
> http://mail.python.org/mailman/listinfo/pythonce
>  


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.resolverhacks.net/
http://wwww.theotherdelia.co.uk/

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Parent Message unknown Re: Comtypes installation problem...

by Alexandre Delattre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

By the time I wrote pypoom, comtypes (version 0.3 if I remember well) worked out of the box on WinCe.

Sergei, if you send me your tweaked version of comtypes, I think I'll be able to replace your "comments" with more portable statements like :
If os.name == 'ce': ...
, or so.
And then submit a preliminary patch to Thomas

Regards,
Alexandre

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by David Goncalves-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> By the time I wrote pypoom, comtypes (version 0.3 if I remember well)
> worked out of the box on WinCe.
>
> Sergei, if you send me your tweaked version of comtypes, I think I'll be
> able to replace your "comments" with more portable statements like :
> If os.name == 'ce': ...
> , or so.
> And then submit a preliminary patch to Thomas

I've done the same on the only needed file '_safearray.py'.
All the parts not working on WinCE are skipped with a

if os.name != "ce" :
     xxxxx
     xxxxx


The file is from the 0.4.2 version of comtypes.

Regards.

"""SAFEARRAY api functions, data types, and constants."""

from ctypes import *
from ctypes.wintypes import *
from comtypes import HRESULT, GUID
import os

################################################################
##if __debug__:
##    from ctypeslib.dynamic_module import include
##    include("""\
##    #define UNICODE
##    #define NO_STRICT
##    #include <windows.h>
##    """,
##            persist=True)

################################################################

VARTYPE = c_ushort
PVOID = c_void_p
USHORT = c_ushort

_oleaut32 = WinDLL("oleaut32")

class tagSAFEARRAYBOUND(Structure):
    _fields_ = [
        ('cElements', DWORD),
        ('lLbound', LONG),
]
SAFEARRAYBOUND = tagSAFEARRAYBOUND

class tagSAFEARRAY(Structure):
    _fields_ = [
        ('cDims', USHORT),
        ('fFeatures', USHORT),
        ('cbElements', DWORD),
        ('cLocks', DWORD),
        ('pvData', PVOID),
        ('rgsabound', SAFEARRAYBOUND * 1),
        ]
SAFEARRAY = tagSAFEARRAY

SafeArrayAccessData = _oleaut32.SafeArrayAccessData
SafeArrayAccessData.restype = HRESULT
# Last parameter manually changed from POINTER(c_void_p) to c_void_p:
SafeArrayAccessData.argtypes = [POINTER(SAFEARRAY), c_void_p]

if os.name != "ce" :
    SafeArrayCreateVectorEx = _oleaut32.SafeArrayCreateVectorEx
    SafeArrayCreateVectorEx.restype = POINTER(SAFEARRAY)
    SafeArrayCreateVectorEx.argtypes = [VARTYPE, LONG, DWORD, PVOID]

SafeArrayUnaccessData = _oleaut32.SafeArrayUnaccessData
SafeArrayUnaccessData.restype = HRESULT
SafeArrayUnaccessData.argtypes = [POINTER(SAFEARRAY)]

if os.name != "ce" :
    _SafeArrayGetVartype = _oleaut32.SafeArrayGetVartype
    _SafeArrayGetVartype.restype = HRESULT
    _SafeArrayGetVartype.argtypes = [POINTER(SAFEARRAY), POINTER(VARTYPE)]
    def SafeArrayGetVartype(pa):
        result = VARTYPE()
        _SafeArrayGetVartype(pa, result)
        return result.value

SafeArrayGetElement = _oleaut32.SafeArrayGetElement
SafeArrayGetElement.restype = HRESULT
SafeArrayGetElement.argtypes = [POINTER(SAFEARRAY), POINTER(LONG), c_void_p]

SafeArrayDestroy = _oleaut32.SafeArrayDestroy
SafeArrayDestroy.restype = HRESULT
SafeArrayDestroy.argtypes = [POINTER(SAFEARRAY)]

SafeArrayCreateVector = _oleaut32.SafeArrayCreateVector
SafeArrayCreateVector.restype = POINTER(SAFEARRAY)
SafeArrayCreateVector.argtypes = [VARTYPE, LONG, DWORD]

SafeArrayDestroyData = _oleaut32.SafeArrayDestroyData
SafeArrayDestroyData.restype = HRESULT
SafeArrayDestroyData.argtypes = [POINTER(SAFEARRAY)]

SafeArrayGetDim = _oleaut32.SafeArrayGetDim
SafeArrayGetDim.restype = UINT
SafeArrayGetDim.argtypes = [POINTER(SAFEARRAY)]

_SafeArrayGetLBound = _oleaut32.SafeArrayGetLBound
_SafeArrayGetLBound.restype = HRESULT
_SafeArrayGetLBound.argtypes = [POINTER(SAFEARRAY), UINT, POINTER(LONG)]
def SafeArrayGetLBound(pa, dim):
    result = LONG()
    _SafeArrayGetLBound(pa, dim, result)
    return result.value

_SafeArrayGetUBound = _oleaut32.SafeArrayGetUBound
_SafeArrayGetUBound.restype = HRESULT
_SafeArrayGetUBound.argtypes = [POINTER(SAFEARRAY), UINT, POINTER(LONG)]
def SafeArrayGetUBound(pa, dim):
    result = LONG()
    _SafeArrayGetUBound(pa, dim, result)
    return result.value


SafeArrayLock = _oleaut32.SafeArrayLock
SafeArrayLock.restype = HRESULT
SafeArrayLock.argtypes = [POINTER(SAFEARRAY)]
SafeArrayPtrOfIndex = _oleaut32.SafeArrayPtrOfIndex
SafeArrayPtrOfIndex.restype = HRESULT
# Last parameter manually changed from POINTER(c_void_p) to c_void_p:
SafeArrayPtrOfIndex.argtypes = [POINTER(SAFEARRAY), POINTER(LONG), c_void_p]
SafeArrayUnlock = _oleaut32.SafeArrayUnlock
SafeArrayUnlock.restype = HRESULT
SafeArrayUnlock.argtypes = [POINTER(SAFEARRAY)]

if os.name != "ce" :
    _SafeArrayGetIID = _oleaut32.SafeArrayGetIID
    _SafeArrayGetIID.restype = HRESULT
    _SafeArrayGetIID.argtypes = [POINTER(SAFEARRAY), POINTER(GUID)]
    def SafeArrayGetIID(pa):
        result = GUID()
        _SafeArrayGetIID(pa, result)
        return result

SafeArrayDestroyDescriptor = _oleaut32.SafeArrayDestroyDescriptor
SafeArrayDestroyDescriptor.restype = HRESULT
SafeArrayDestroyDescriptor.argtypes = [POINTER(SAFEARRAY)]

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by Sergei Golubchik-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

On Jun 27, Alexandre Delattre wrote:

> Hi,
>
> By the time I wrote pypoom, comtypes (version 0.3 if I remember well)
> worked out of the box on WinCe.
>
> Sergei, if you send me your tweaked version of comtypes, I think I'll
> be able to replace your "comments" with more portable statements like
> :
> If os.name == 'ce': ...
> , or so.
> And then  submit a preliminary patch to Thomas

David already replied - I've basically end up with the same, three
functions being commented out (SafeArrayCreateVectorEx,
SafeArrayGetVartype, SafeArrayGetIID) - but he properly used if os.name.

I don't have PythonCE or pypoom anymore (just keep a backup of changed
files) - as I couldn't make it to access ringtone field of a
contact :(
 
Regards
Sergei
_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Parent Message unknown Re: Comtypes installation problem...

by Alexandre Delattre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nice,

Maybe there some other part of comtypes that would require the missing SafeArrayGetIID function and would fail at runtime (I mean some functions or classes that use this internally).
I'll have a little search through the code and use a os.name switch if necessary.

Best regards,
Alexandre

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: Comtypes installation problem...

by Thomas Heller-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Goncalves schrieb:

> Hi,
>
>> By the time I wrote pypoom, comtypes (version 0.3 if I remember well)
>> worked out of the box on WinCe.
>>
>> Sergei, if you send me your tweaked version of comtypes, I think I'll be
>> able to replace your "comments" with more portable statements like :
>> If os.name == 'ce': ...
>> , or so.
>> And then submit a preliminary patch to Thomas
>
> I've done the same on the only needed file '_safearray.py'.
> All the parts not working on WinCE are skipped with a
>
> if os.name != "ce" :
>      xxxxx
>      xxxxx
>
>
> The file is from the 0.4.2 version of comtypes.

Before I apply this patch to comtypes:  This patch allows to *import* the comtypes.safearray
module, but it also probably makes it non-functional.

So, the question is:  Which COM objects are people using on Windows CE?  Do these objects
use the SAFEARRAY data type?

Thanks,
Thomas

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Parent Message unknown Re: Comtypes installation problem...

by Alexandre Delattre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thomas,

In pypoom and when embedding activex controls in venster/ppygui I hadn't met the need to use the SAFEARRAY type.

Regards,
Alexandre

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce