使用setuptools(或其他python egg builder)进行顶级包处理 [英] top-level package handling with setuptools (or another python egg builder)

查看:90
本文介绍了使用setuptools(或其他python egg builder)进行顶级包处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个小python应用程序。我希望能够轻松部署该应用程序。我知道python 2.6如果在鸡蛋的根目录中有一个 main 模块,它将允许人们直接执行一个鸡蛋。我确实可以正常工作。

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.

一个弯头是,当我尝试使用argparse库时,如果不将其安装到源目录中就无法将其包含在egg中(或者将argparse.py符号链接到我的源目录中),因为argparse模块位于顶层软件包中。

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.

如果我将其安装到名为 argparse的子目录中,我必须像从argparse import argparse那样导入它,而不是正常的 import argparse。

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".

我希望能够指定站点软件包在egg中输入目录,我可以在其中安装第三方模块/软件包。有什么方法可以使用setuptools(或其他一些Egg生成器)来实现?

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)?

谢谢!

推荐答案

我相信您可以创建一个名为toplevel的子目录,并在您的入口点执行

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

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

未经测试

这篇关于使用setuptools(或其他python egg builder)进行顶级包处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆