easy_install python扩展允许从控制台安装python鸡蛋,如下所示:
easy_install py2app
但是,可以在python脚本中访问easy_install功能吗?我的意思是,不调用os.system( "easy_install py2app“),而是将easy_install作为python模块导入,并使用它的本地方法?
发布于 2009-06-01 15:05:47
当我查看设置工具源代码时,看起来您可以尝试以下操作。
from setuptools.command import easy_install
easy_install.main( ["-U","py2app"] )
发布于 2009-06-01 15:38:09
from setuptools.command import easy_install
def install_with_easyinstall(package):
easy_install.main(["-U", package]).
install_with_easyinstall('py2app')
发布于 2009-06-01 15:13:47
你具体想做什么?除非您有一些奇怪的要求,否则我建议您在setup.py中将包声明为依赖项:
from setuptools import setup, find_packages
setup(
name = "HelloWorld",
version = "0.1",
packages = find_packages(),
scripts = ['say_hello.py'],
# Project uses reStructuredText, so ensure that the docutils get
# installed or upgraded on the target machine
install_requires = ['docutils>=0.3'],
package_data = {
# If any package contains *.txt or *.rst files, include them:
'': ['*.txt', '*.rst'],
# And include any *.msg files found in the 'hello' package, too:
'hello': ['*.msg'],
}
# metadata for upload to PyPI
author = "Me",
author_email = "me@example.com",
description = "This is an Example Package",
license = "PSF",
keywords = "hello world example examples",
url = "http://example.com/HelloWorld/", # project home page, if any
# could also include long_description, download_url, classifiers, etc.
)
这里的关键一行是install_requires = ['docutils>=0.3']
。这将导致setup.py文件自动安装此依赖项,除非用户另行指定。您可以在此here上找到更多文档(请注意,setuptools网站非常慢!)。
如果你确实有某种需求不能以这种方式满足,你可能应该看看S.Lott's answer (尽管我自己从来没有尝试过)。
https://stackoverflow.com/questions/935111
复制相似问题