the problem about the DLL file generate by py2exe

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • em00100@hotmail.com

    the problem about the DLL file generate by py2exe

    Dear All,

    I have try to use the py2exe to compile the DLL file

    first i write the simple python script "test01.py" :
    def test001():
    return 1

    then write the setup.py:
    # setup.py
    from distutils.core import setup
    import py2exe
    import sys

    if len(sys.argv) == 1:
    sys.argv.append ("py2exe")
    sys.argv.append ("-q")

    class Target:
    def __init__(self, **kw):
    self.__dict__.u pdate(kw)
    # for the version info resources (Properties -- Version)
    self.version = "0.0.1"
    self.company_na me = "Nil"
    self.copyright = "Nil"
    self.name = "test"

    testTK = Target(
    # used for the versioninfo resource
    description = "test app",
    # what to build
    modules = ["test01"],
    script = "test01.py" ,
    # specify which type of com server you want (exe and/or dll)
    create_exe = False,
    create_dll = True)

    #setup(windows=["hkcity_ide_mai n.py"])
    setup(
    name='Test',
    options={"py2ex e": {"bundle_files" : 1, }},
    zipfile=None,
    version='1.0',
    description='Te st',
    author='',
    author_email='' ,
    url='',
    ctypes_com_serv er=[testTK],
    )


    and compile the it by the command:

    C:\Python25\pyt hon setup.py py2exe


    I use the script try to call the function "test001" in the "test01.py"
    from ctypes import *
    test01 = cdll.LoadLibrar y("test01.dll ")
    test001 = test01.test001
    print test01()

    However, this is out the error:
    AttributeError: function 'test001' not found

    Is it any problem when i define the function?

  • Diez B. Roggisch

    #2
    Re: the problem about the DLL file generate by py2exe

    em00100@hotmail .com wrote:
    Dear All,
    >
    I have try to use the py2exe to compile the DLL file
    >
    first i write the simple python script "test01.py" :
    def test001():
    return 1
    >
    then write the setup.py:
    # setup.py
    from distutils.core import setup
    import py2exe
    import sys
    >
    if len(sys.argv) == 1:
    sys.argv.append ("py2exe")
    sys.argv.append ("-q")
    >
    class Target:
    def __init__(self, **kw):
    self.__dict__.u pdate(kw)
    # for the version info resources (Properties -- Version)
    self.version = "0.0.1"
    self.company_na me = "Nil"
    self.copyright = "Nil"
    self.name = "test"
    >
    testTK = Target(
    # used for the versioninfo resource
    description = "test app",
    # what to build
    modules = ["test01"],
    script = "test01.py" ,
    # specify which type of com server you want (exe and/or dll)
    create_exe = False,
    create_dll = True)
    >
    #setup(windows=["hkcity_ide_mai n.py"])
    setup(
    name='Test',
    options={"py2ex e": {"bundle_files" : 1, }},
    zipfile=None,
    version='1.0',
    description='Te st',
    author='',
    author_email='' ,
    url='',
    ctypes_com_serv er=[testTK],
    )
    >
    >
    and compile the it by the command:
    >
    C:\Python25\pyt hon setup.py py2exe
    >
    >
    I use the script try to call the function "test001" in the "test01.py"
    from ctypes import *
    test01 = cdll.LoadLibrar y("test01.dll ")
    test001 = test01.test001
    print test01()
    >
    However, this is out the error:
    AttributeError: function 'test001' not found
    >
    Is it any problem when i define the function?
    I guess you should define a python-function, inside which you call your
    dll-function.

    Diez

    Comment

    Working...