【问题标题】:pip target and post installation in setup.pypip 目标并在 setup.py 中安装后
【发布时间】: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”唯一的东西?

【问题讨论】:

    标签: python pip setup.py


    【解决方案1】:

    阅读教育: http://pythonwheels.com/ 2. 避免安装时执行任意代码。 (避免 setup.py) 由于我使用轮子和轮子不会执行 setup.py,所以我这样做的概念是垃圾。 https://github.com/pypa/packaging-problems/issues/64

    我猜这是在部署和安装之间,虽然我显然会计算我对安装的一点改变......

    有没有办法避免在 pip install whl 时创建 pyc 文件?

    【讨论】:

      猜你喜欢
      • 2013-10-08
      • 1970-01-01
      • 1970-01-01
      • 2020-01-24
      • 1970-01-01
      • 2018-01-28
      • 2015-03-05
      • 1970-01-01
      • 2014-12-19
      相关资源
      最近更新 更多