自定义安装后脚本未运行pip

时间:2017-06-14 16:00:49

标签: python python-3.x setuptools distutils python-packaging

  在标记为重复之前

,我尝试了一堆解决方案   包括一个here   但没有运气

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

尝试安装时,我使用python setup.py install时会得到所需的效果,但pip install package_name只安装软件包但没有安装后的脚本。

以下是我的代码的一部分;

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

1 个答案:

答案 0 :(得分:1)

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

requirements.txt

您在chat中提到您要将此软件包添加到-e git://github.com/path/to/project 文件中。有关详细信息,请参阅this question

pip install

以前的答案(被OP拒绝):

我设法重新创造了你所拥有的问题。这似乎是-vvv沉默或重定向输出的问题(由this question的答案表示)。

解决方案是在pip install之后添加选项library(dplyr) df <- data_frame(col1 = sample(c(-1, 0, 1), 10, replace = TRUE), col2 = sample(c(-1, 0, 1), 10, replace = TRUE), col3 = sample(c(-1, 0, 1), 10, replace = TRUE), col4 = sample(c(-1, 0, 1), 10, replace = TRUE)) 。我猜测 v 代表详细