' pip install'两个具有相同命名空间包的模块

时间:2016-01-27 14:28:01

标签: python pip

我创建了两个分别包含foo / comp1.py和foo / comp2.py的轮子。 '富'是命名空间包(PEP420)。当在同一个文件夹中安装这两个软件包时,我希望pip能够合并它们。但它失败了。这是预期的吗?为什么呢?

示例:

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.

因此缺少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

1 个答案:

答案 0 :(得分:0)

我想您可以在这里找到答案:https://stackoverflow.com/a/38919020/4802862

使用此答案,我能够在同一顶级名称空间中部署两个轮子