请在标记为重复之前,我已经尝试了一堆解决方案 包括一个在这里 但没有运气
我创建了一个简单的工具来执行一些任务,并能够成功打包它。
尝试安装它时,当我使用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
。
直接从 GitHub 存储库安装包:
pip install -vvv git+url/for/github/repo@my-branch
您在聊天中提到要将此包添加到requirements.txt
文件中。有关详细信息,请参阅此问题:
-e git://github.com/path/to/project
以前的答案(被OP拒绝(:
我设法重现了您遇到的问题。这似乎是pip install
沉默或重定向输出的问题(如对此问题的回答所示(。
解决方案是在pip install
之后添加选项-vvv
。我猜 v 代表冗长。