问题描述
我不太确定如何构建一个非常简单的单文件源模块.是否有一个示例模块可以构建为 python .egg?
I'm not quite sure how to build a really simple one-file source module. Is there a sample module out there one the web somewhere which can be built as a python .egg?
从 setuptools 页面,它看起来非常简单,您只需进行 设置.py
文件,然后在某处至少有一个其他 .py 文件,我可以构建一个 .egg 文件,甚至可以使用 easy_install
安装它,但我似乎无法import
从 python 中导入文件.(注意:使用 2.6.4)
From the setuptools page it looks pretty simple, you just have your setup.py
file and then at least one other .py file somewhere, and I can build an .egg file OK, and even install it using easy_install
, but I can't seem to import
the file from within python. (note: using 2.6.4)
这是我的示例目录:
sconsconfig
setup.py
sconsconfig.py
setup.py:
from setuptools import setup, find_packages
setup(name='sconsconfig',
version='0.1',
packages = find_packages(),
)
sconsconfig.py:
sconsconfig.py:
def blarg(x):
return x+1
如果我运行 setup.py bdist_egg
然后它会创建一个 egg 文件,但是如果我查看它,没有 .py 源文件....
If I run setup.py bdist_egg
it then creates an egg file, but if I look in it, there's no .py source file....
推荐答案
您可以使用 py_modules
参数代替 packages
参数来列出单个文件模块.
You can use the py_modules
argument instead of the packages
argument to list single file modules.
参见 https://docs.python.org/3/distutils/setupscript.html#listing-individual-modules
这篇关于python:带有单文件源文件的python egg的简单示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!