English 中文(简体)
p2exe编成法典的未兼容金刚成金
原标题:Dynamic loading of uncompiled python plugins in py2exe compile code

我的沙尔申请是建筑的,因此一些功能可以用作花.。 原始结构目前非常简单: 我有一根 p子/包裹,其中载有一些on形模块。 我把相关金字装上如下:

plugin_name = blablabla
try:
    module = __import__(plugin_name, fromlist= do_something )
except ImportError:
   #some error handling ...

之后执行:

try:
    loans = module.do_something(id_t, pin_t)
except xxx:
    # error handling

我利用Py2exe将申请汇编到Windows binary。 这一工程课以罚金,但以下事实除外:所有金刚石(而且必须)都列入本金。 这不是非常实际的,因为对每一个新鲜花来说,我不得不对我的申请进行反驳和发表新的版本。 如果能够把新的假象(即花名册)复制到一些应用面粉碎夹上来,那么,用我的申请来解释档案法典中的“灰色”法则更好。

这样做的最佳办法是什么?

(一) 阅读选定的原始卷宗的每一行,并应用exec statement。 但可能有更好的办法......

问题回答

PyInstaller 也请你进口外部档案。 如果你接手申请,就不会将这些文件列入起诉范围。 那么,你就必须确保道路正确(即,你的申请能够找到正确的目录上的磁盘模块),所有工作都应奏效。

我建议你使用kg-资源切入-点特征(从 set/d/rib)来进行原始发现和瞬时:首先,它为做到这一点提供了标准的方法;其次,它不会遇到你提到AFAIK的问题。 你们都必须扩大申请范围,将一些gin果包到一个鸡蛋中,该蛋可以宣布某些切片(鸡蛋可以申报许多gin),如果你将鸡蛋列入你的猪肉分配,那么它宣布的所有gin都可以通过你的申请自动发现。 您还可以把申请和“杂货”混入同一个鸡蛋,这非常方便。

I m not sure you have to put plugin files in the zip library. This may be because you re using the default for py2exe packaging your script.

您可尝试使用压缩 = False(如py2exe ListOfOptions) ,从而消除图书馆。 粉末产生的脂肪,并可能允许你使用on式模块(粉碎块是 p式模块,我估计,从import)以“正常”方式使用,而不是被迫在你zi或双手里包装。

I found how to do import external modules (on top of the compiled executable, at runtime) with pyinstaller. it figures that originally, the path of the executable was automatically added to sys.path, but for security reasons they removed this at some point. to re-enable this, use:

sys.path.append(os.path.dirname(sys.executable))

this will enable importing .py files that sit in the same path as the executable. you can add this line to the runtime hook, or to the main app.





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...