【发布时间】:2017-11-03 01:11:09
【问题描述】:
今天我试图在我的包(python 轮)通过 pip 安装后删除一个文件,并带有 -t --target 选项。 Post-install script with Python setuptools 我在 setup.py 中对 install 进行子类化,如下所示:
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
# here I am using
p = os.path.join(self.install_libbase,"myPackage/folder/removeThisPyc.pyc")
if os.path.isfile(p):
os.unlink(p)
#there is also self.install_platlib and
#self.install_purelib which seem to be used by pip distutil scheme
#Have not tested those yet
运行时
python setup.py install
这个工作文件在安装时被删除。 但是通过
pip install path-to-my-wheel.whl
这不起作用,文件仍然存在。
pip install -t /target/dir path-to-my-wheel.whl
也不行... 所以问题是,pip 对 distutils 和/或 setuptools 做了什么,如何使它工作? 我注意到的另一件事是 pip 似乎没有打印任何内容,我在 setup.py 中以详细模式打印? 是否可以看到 python 的完整输出而不是“pip”唯一的东西?
【问题讨论】: