IronPython one of the packaging records: source packaging

Source: Internet
Author: User

Original link: http://xufive.blog.163.com/blog/static/17232616820125159303126/

A year ago, I wrote a program with IronPython that called. NET dynamic libraries, and was having trouble packaging them into executable programs. At that time because the project period is tight, had to use Python outside to do a layer of packaging, hastily done. Recently, the project was dug up: my client sold it to BD. Just take this opportunity to deal with the legacy of history.

Read the documentation before you know IronPython comes with a packaged script named pyc.py, in the \tools\scripts folder under the installation path. pyc.py can generate DLL files, can also generate EXE files, and can also generate Windows programs. A typical usage is as follows:

Ipy.exe pyc.py /main: program.py form.py / Target: winexe

The first file after main is the main program, and the other scripts (if any) are written in turn. Target represents the target type of the build, and Winexe indicates that a Windows program was generated.

It seems simple, but my program always goes wrong when it's packaged, and the error message is as follows:

Systemerror:unable to make a reference to a transient module from a non-transient module.

Transient module? What is this stuff? Google all over the whole day, and finally found some clues:supplying arguments to a Python function taking variable arguments causes a CLR. Compilemodules failure; arguements compiles fine. The Chinese word means that there are 13 parameters in the variable parameters of the function, compilation fails, 12 parameters, and the compilation is normal.

How can there be such a hidden bug? Look at my code, there really is a line like this:

class Rfidreader ():

def __init__ (Self, readername, IP, user, passwd, **cfg):

**cfg is a dictionary-type mutable parameter that, when instantiated, provides 10 parameters:

Insidepin=1, Outsidepin=3, redpin=0, Greenpin=1, inmode= ' S ', reddelay=5000, greendelay=3000, port=3000, timeout=1000, Readmode= ' OnDemand '

Plus readername, IP, user, passwd and other 4 parameters, a total of 14, indeed more than 13! Is that really the reason? The relatively fixed port=3000, timeout=1000, readmode= ' OnDemand ' and other 3 parameters written in the code, only 11 parameters left, run the packaging program again, haha, finally succeeded.

However, I am happy too early, compiling the package after the program can not run up! My source code can run smoothly on the IPY interpreter and should not be a problem with the code. To think about it, there's only one possibility: my program called one. NET, and pyc.py seems to compile only IronPython scripts, and cannot package DLL files and other resource files.

So, is there really no way to go? Continue to be confused in ...

IronPython one of the packaging records: source packaging (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.