我发现的是,PIP运行一个python命令行脚本,看起来像这样:
__file__ = '<path to package>/setup.py'
from setuptools.command import egg_info
def replacement_run(self):
self.mkpath(self.egg_info)
installer = self.distribution.fetch_build_egg
for ep in egg_info.iter_entry_points('egg_info.writers'):
# require=False is the change we're making:
writer = ep.load(require=False)
if writer:
writer(self, ep.name, egg_info.os.path.join(self.egg_info,ep.name))
self.find_sources()
egg_info.egg_info.run = replacement_run
execfile(__file__)
在包的顶级目录,其中没有setup.py,我把一个setup.py那转载此行为,但chdir'd包含“真正的”setup.py目录,并在最后执行,而不是。
唯一的另一个问题是,pip创建了一个目录“pip-egg-info”,它期望被填充,需要在“real”setup.py目录中创建一个符号链接。
新的顶级设置。吡啶是这样的:
#! /usr/bin/env python
from os import chdir, symlink, getcwd
from os.path import join, basename, exists
filename = basename(__file__)
chdir("python")
setupdir = getcwd()
egginfo = "pip-egg-info"
if not exists(egginfo) and exists(join("..", egginfo)):
symlink(join("..", egginfo), egginfo)
__file__ = join(setupdir, filename)
from setuptools.command import egg_info
def replacement_run(self):
self.mkpath(self.egg_info)
installer = self.distribution.fetch_build_egg
for ep in egg_info.iter_entry_points('egg_info.writers'):
# require=False is the change we're making:
writer = ep.load(require=False)
if writer:
writer(self, ep.name, egg_info.os.path.join(self.egg_info,ep.name))
self.find_sources()
egg_info.egg_info.run = replacement_run
execfile(__file__)
这也可能是脆弱的,但应该继续工作,直到画中画改变,它的产生
我假设你知道你可以解开它,并自己运行'python setup.py install'? – 2011-03-15 22:28:26
是的,我知道这一点。只是我宁愿使用pip,因为我可以使用pip冻结需求文件以及制作一个包与其他人共享。 – dave 2011-03-16 17:01:54