【发布时间】:2019-10-23 00:09:12
【问题描述】:
我的项目树结构
.
├── example.gif
├── funmotd
│ ├── config.json
│ ├── __init__.py
│ └── quotes_db.py
├── LICENSE
├── README.md
└── setup.py
setup.py(删除了一些代码以减少代码)
import sys
import os
import setuptools
from setuptools.command.install import install
class PostInstall(install):
def run(self):
mode = 0o666
bashrc_file = os.path.join(os.path.expanduser('~'), ".bashrc")
install.run(self)
# Added CLI to .bashrc
# Change "config.json" file permission
setuptools.setup(
...
entry_points={'console_scripts': ['funmotd = funmotd:main']},
package_dir={'funmotd': 'funmotd/'},
package_data={'funmotd': ['config.json'], },
include_package_data=True,
python_requires=">=3.4",
cmdclass={'install': PostInstall, },
...
)
当我运行python3 setup.py install 时,PostInstall 运行良好。所以,像下面这样上传到Pypi(来自this doc)
$ python3 setup.py bdist_wheel
# Created "dist", "funmotd.egg-info" and "build" dirs
$ twine upload dist/*
但是当我运行 pip install funmotd 时,PostInstall 是 NOT 执行的,我看到 dist/* 就像静态编译的东西。
当我运行pip install funmotd 时,有什么技巧可以运行安装后任务。或者如何让setup.py 在pip 处执行。
我遵循以下问题,没有得到我需要的解决方案
PS:我不希望用户克隆 repo 并运行 python setup.py install。想让它变得简单pip install funmotd
UDPATE1
似乎已经有issue on github,这是长线程
【问题讨论】:
标签: python-3.x pip setuptools pypi python-wheel