假设我有一个python包blah
我可以通过两种方式安装它:
pip install git+https://github.com/blah/blah.git@blah (使用github存储库)
和
pip install blah (使用pypi repo)
有没有办法找出用户在setup.py中安装软件包的方式?
这样我就可以做一些像这样的事情:
if INSTALLING_FROM_PYPI:
# some logic
if INSTALLING_FROM_SOMEWHERE_ELSE:
# some other logic发布于 2020-01-25 07:03:58
只需在您的Git存储库中包含一个文件:
$ touch .git-flag在您的MANIFEST.in文件中明确地将其从您的发行版中排除:
exclude .git-flag然后在setup.py中,相对于您的setup.py文件检查该文件是否存在:
import os
this_dir, this_filename = os.path.split(__file__)
path_to_flag = os.path.join(this_dir, ".git-flag")
installed_from_git = os.path.exists(path_to_flag)https://stackoverflow.com/questions/59856855
复制相似问题