开发者

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

开发者 https://www.devze.com 2023-02-05 21:16 出处:网络
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

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 kin开发者_如何学JAVAk 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!


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

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

Untested, though.

0

精彩评论

暂无评论...
验证码 换一张
取 消