[英]How do you list down a python dependency that depends on itself?
I have seen a few packages on github that does something like this: 我在github上看到了一些做如下事情的软件包:
from setuptools import setup, find_packages
import mypackage
setup(name="mypackage", version=mypackage.__version__ ..
This would fail as mypackage when running "python setup.py develop" as mypackage has not been installed yet. 由于尚未安装mypackage,因此在运行“ python setup.py development”时,由于mypackage将失败。 Is there a way to fix this?
有没有办法解决这个问题?
No it wouldn't. 不,不会。 If you have 2 files in the same directory, they can import each other.
如果您在同一目录中有2个文件,它们可以互相导入。
setup.py
and mypackage.py
are in the same directory, so when you run python setup.py develop
, mypackage
is being imported from the local directory, not from one of the standard locations where (presumably) mypackage
will eventually be installed. setup.py
和mypackage.py
位于同一目录中,因此,当您运行python setup.py develop
, mypackage
将从本地目录导入,而不是从最终可能会安装mypackage
的标准位置之一导入。
You could verify this, if you like, by adding 如果愿意,您可以通过添加
print my package.__file__
following the import
statement and observing the local path that is printed. 遵循
import
语句并观察打印的本地路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.