自定义 post 安装脚本不是 运行 pip

Custom post install script not running with pip

Please before flagging as duplicate, I have tried a bunch of solutions including one here but no luck

我创建了一个简单的工具来完成一些任务,并且能够成功地打包它。

当我尝试安装它时,我在使用 python setup.py install 时得到了预期的效果,但是 pip install package_name 只安装了软件包,没有 post 安装脚本。

这是我的部分代码;

setup.py

from distutils import setup
from app.scripts import *

setup(

        #Application name
        name = "my-app-name",

        version = "my-app-version",
        author = "my-name",
        author_email = "my-email",
        packages = ['app'],
        include_package_data = True,
        license = 'MIT',
        url = "https://my-url",
        description = "description",
        install_requires = ["flake8"],
        cmdclass = {
            "install":Post_install
        }
    )

scripts.py

from distutils.command.install import install
import os

class Post_install(install):

    @staticmethod
    def func():      
        return True

    def run(self):
        install.run(self)
        #Pre install actions
        if Post_install.func():
            print("Bingo")
        else:
            print("Failed")

谢谢:)

PS我运行pip install上传包后

直接从您的 GitHub 存储库安装软件包:

pip install -vvv git+url/for/github/repo@my-branch

您在chat that you'd like to add this package to your requirements.txt file. See this question中提到的详情:

-e git://github.com/path/to/project

原回答(被OP拒绝):

我成功地重现了您遇到的问题。这似乎是 pip install 静音或重定向输出的问题(如对 this question 的回答所示)。

解决办法是在pip install后面加上选项-vvv。我猜 v 代表 verbose.