the problem about the DLL file generate by py2exe

E

em00100

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__.update(kw)
# for the version info resources (Properties -- Version)
self.version = "0.0.1"
self.company_name = "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_main.py"])
setup(
name='Test',
options={"py2exe": {"bundle_files": 1, }},
zipfile=None,
version='1.0',
description='Test',
author='',
author_email='',
url='',
ctypes_com_server=[testTK],
)


and compile the it by the command:

C:\Python25\python setup.py py2exe


I use the script try to call the function "test001" in the "test01.py"
from ctypes import *
test01 = cdll.LoadLibrary("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?
 
D

Diez B. Roggisch

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__.update(kw)
# for the version info resources (Properties -- Version)
self.version = "0.0.1"
self.company_name = "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_main.py"])
setup(
name='Test',
options={"py2exe": {"bundle_files": 1, }},
zipfile=None,
version='1.0',
description='Test',
author='',
author_email='',
url='',
ctypes_com_server=[testTK],
)


and compile the it by the command:

C:\Python25\python setup.py py2exe


I use the script try to call the function "test001" in the "test01.py"
from ctypes import *
test01 = cdll.LoadLibrary("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
 
E

em00100

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__.update(kw)
        # for the version info resources (Properties -- Version)
        self.version = "0.0.1"
        self.company_name = "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_main.py"])
setup(
    name='Test',
    options={"py2exe": {"bundle_files": 1, }},
    zipfile=None,
    version='1.0',
    description='Test',
    author='',
    author_email='',
    url='',
    ctypes_com_server=[testTK],
    )
and compile the it by the command:
C:\Python25\python setup.py py2exe
I use the script try to call the function "test001" in the "test01.py"
from ctypes import *
test01 = cdll.LoadLibrary("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

How to define the "python-function"?
can you write the statement with my testing script, please.
the "python-function" is place in "test01.py"?
is it also need to define the "python-function" in "setup.py"

thanks for you time
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top