简体   繁体   English

“ pip install”两个具有相同名称空间包的模块

[英]'pip install' two modules with the same namespace package

I've created two wheels containing respectively foo/comp1.py and foo/comp2.py. 我创建了两个轮子,分别包含foo / comp1.py和foo / comp2.py。 'foo' is a namespace package ( PEP420 ). 'foo'是名称空间包( PEP420 )。 When installing these two packages in the same folder I would expect pip to merge them. 当在同一个文件夹中安装这两个软件包时,我希望pip将它们合并。 But it fails. 但是失败了。 Is it expected? 是预期的吗? Why? 为什么?

Example: 例:

pip_namespace>unzip -l comp1/dist/foo.comp1-1.0.0-py3-none-any.whl
Archive:  comp1/dist/foo.comp1-1.0.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2016-01-27 14:45   foo/comp1.py
       31  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/DESCRIPTION.rst
      377  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/metadata.json
        4  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/top_level.txt
       92  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/WHEEL
      244  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/METADATA
      568  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/RECORD
---------                     -------
     1316                     7 files

pip_namespace>unzip -l comp2/dist/foo.comp2-1.0.0-py3-none-any.whl
Archive:  comp2/dist/foo.comp2-1.0.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2016-01-27 14:56   foo/comp2.py
       31  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/DESCRIPTION.rst
      377  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/metadata.json
        4  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/top_level.txt
       92  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/WHEEL
      244  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/METADATA
      568  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/RECORD
---------                     -------
     1316                     7 files

pip_namespace>pip install -t test_pip comp1/dist/foo.comp1-1.0.0-py3-none-any.whl
Processing ./comp1/dist/foo.comp1-1.0.0-py3-none-any.whl
Installing collected packages: foo.comp1
Successfully installed foo.comp1
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

pip_namespace>pip install -t test_pip comp2/dist/foo.comp2-1.0.0-py3-none-any.whl
Processing ./comp2/dist/foo.comp2-1.0.0-py3-none-any.whl
Installing collected packages: foo.comp2
Successfully installed foo.comp2
Target directory /remote/devsup/users/flemaitre/tmp/pip_namespace/test_pip/foo already exists. Specify --upgrade to force replacement.
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

As a result comp2 is missing: 结果缺少comp2:

pip_namespace>find test_pip/foo
test_pip/foo
test_pip/foo/__pycache__
test_pip/foo/__pycache__/comp1.cpython-35.pyc
test_pip/foo/comp1.py

I think you could find an answer here: https://stackoverflow.com/a/38919020/4802862 我认为您可以在这里找到答案: https : //stackoverflow.com/a/38919020/4802862

Using this answer, I was able to deploy two wheels in the same top level namespace 使用此答案,我能够在同一顶级名称空间中部署两个轮子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM