top-level package handling with setuptools (or another python egg builder)

倾然丶 夕夏残阳落幕 提交于 2019-12-11 05:59:48

问题


I am writing a little python app. I want to be able to easily deploy the app. I know that python 2.6 will allow one to execute an egg directly if there is a main module at the egg's root. I actually have that working.

The one kink is that when I try to use the argparse library, I cannot include the library in the egg without installing it into my source directory (or symlinking in the argparse.py into my source dir) since the argparse module is in the top-level package.

If I install it into a subdirectory called "argparse", I have to import it like "from argparse import argparse" instead of the normal "import argparse".

I would like to be able to specify a site-packages type directory in the egg where I could just install the third party modules/packages. Is there any way to do this with setuptools (or some other egg builder)?

Thanks!


回答1:


I believe you can create a subdirectory called toplevel and in your entry point do

import sys
sys.path.insert(0, './toplevel')

Untested, though.



来源:https://stackoverflow.com/questions/4743013/top-level-package-handling-with-setuptools-or-another-python-egg-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!