为什么在 `setup.py develop` 之后新的子模块不可用?
Why after `setup.py develop` new submodules are not available?
为什么我要在添加新的 scripts/submodules 等后再次 运行 setup.py develop
?
例如我这样做:
pyvenv venv
. venv/bin/activate
现在,创建这些文件:
/
| setup.py
| testpkg
| | __init__.py
| | foo.py
| |__
|__
(setup.py是一个简单的,foo.py包含一个函数)
那么,
python setup.py develop
现在,如果您启动 python,您可以导入 testpkg.foo
。
但是现在,添加 bar.py :
/
| setup.py
| testpkg
| | __init__.py
| | foo.py
| | bar.py <---
| |__
|__
您无法导入 testpkg.bar
除非你再次运行
python setup.py develop
为什么? (为什么它不起作用,如果它是预期的行为,为什么选择这种行为?)
注意(并编辑)
在我的电脑上,在 运行ning python setup.py develop
之后,我注意到 link 指向 build/lib/[...].egg-info
在 egg 信息中,我看到来源指向这个 build/lib。这里的文件不是 links,所以它应该如何工作??
检查标志 use_2to3 是否设置。然后,正如医生所说:
If you have enabled the use_2to3 flag, then of course the .egg-link
will not link directly to your source code when run under Python 3,
since that source code would be made for Python 2 and not work under
Python 3. Instead the setup.py develop will build Python 3 code under
the build directory, and link there. This means that after doing code
changes you will have to run setup.py build before these changes are
picked up by your Python 3 installation.
为什么我要在添加新的 scripts/submodules 等后再次 运行 setup.py develop
?
例如我这样做:
pyvenv venv
. venv/bin/activate
现在,创建这些文件:
/
| setup.py
| testpkg
| | __init__.py
| | foo.py
| |__
|__
(setup.py是一个简单的,foo.py包含一个函数) 那么,
python setup.py develop
现在,如果您启动 python,您可以导入 testpkg.foo
。
但是现在,添加 bar.py :
/
| setup.py
| testpkg
| | __init__.py
| | foo.py
| | bar.py <---
| |__
|__
您无法导入 testpkg.bar
除非你再次运行
python setup.py develop
为什么? (为什么它不起作用,如果它是预期的行为,为什么选择这种行为?)
注意(并编辑)
在我的电脑上,在 运行ning python setup.py develop
之后,我注意到 link 指向 build/lib/[...].egg-info
在 egg 信息中,我看到来源指向这个 build/lib。这里的文件不是 links,所以它应该如何工作??
检查标志 use_2to3 是否设置。然后,正如医生所说:
If you have enabled the use_2to3 flag, then of course the .egg-link will not link directly to your source code when run under Python 3, since that source code would be made for Python 2 and not work under Python 3. Instead the setup.py develop will build Python 3 code under the build directory, and link there. This means that after doing code changes you will have to run setup.py build before these changes are picked up by your Python 3 installation.