Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
依赖于另一个子包的Python命名空间子包无法安装_Python_Git_Pip_Setuptools - Fatal编程技术网

依赖于另一个子包的Python命名空间子包无法安装

依赖于另一个子包的Python命名空间子包无法安装,python,git,pip,setuptools,Python,Git,Pip,Setuptools,我的目标是创建一个包含两个子包的名称空间包:foo和bar(依赖于foo),并将名称空间包推送到git repo(不将其发布到PyPI),这样我就可以使用repo url安装任意一个子包 下面是创建名称空间结构的步骤: root/ ├ setup.py └ microlibs/ ├ foo/ │ ├ setup.py │ ├ macrolib/ │ └ foo/ │ ├ __init__.py │ ├ m

我的目标是创建一个包含两个子包的名称空间包:foo和bar(依赖于foo),并将名称空间包推送到git repo(不将其发布到PyPI),这样我就可以使用repo url安装任意一个子包

下面是创建名称空间结构的步骤:

root/
 ├ setup.py
 └ microlibs/
    ├ foo/
    │  ├ setup.py
    │  ├ macrolib/
    │     └ foo/
    │        ├ __init__.py
    │        ├ module1.py
    │        ├ ...
    │        └ moduleN.py
    .
    .
    .
    └ bar/
       ├ setup.py
       ├ macrolib/
          └ bar/
             ├ __init__.py
             ├ module1.py
             ├ ...
             └ moduleN.py
foo的setup.py文件没有依赖项:

foo/setup.py

from setuptools import setup
microlib_name = 'macrolib.foo'
setup(
    name=microlib_name,
    version="0.1.0",
    namespace_packages=['macrolib'],
    packages=[microlib_name],
    install_requires=[]
)
由于bar的依赖项包括foo,因此bar的setup.py包括install_requires列表中的macrolib.bar:

bar/setup.py

from setuptools import setup
microlib_name = 'macrolib.bar'
setup(
    name=microlib_name,
    version="0.1.0",
    namespace_packages=['macrolib'],
    packages=[microlib_name],
    install_requires=[
        'macrolib.foo'
    ]
)
推送到bitbucket repo后,我可以安装macrolib.foo,而不会出现repo子目录的问题

$ pip install git+http://path/to/repo.git@<branch name>#"subdirectory=foo&egg=macrolib.foo"
$ pip install git+http://path/to/repo.git@<branch name>#"subdirectory=bar&egg=macrolib.bar"
我猜这是因为bar/setup.py中缺少依赖关系链接。所以我尝试了不同的链接URL组合,都失败了,出现了相同的错误

我尝试过的格式:

dependency_links=['http://path/to/repo.git@<branch name>#"subdirectory=foo&egg=macrolib.foo"']

dependency_links=['http://path/to/repo.git@<branch name>#subdirectory=foo&egg=macrolib.foo']

dependency_links=['http://path/to/repo/tarball/<branch name>#"subdirectory=foo&egg=macrolib.foo"']

dependency_links=['http://path/to/repo/tarball/<branch name>#subdirectory=foo&egg=macrolib.foo']

dependency_links=['http://path/to/repo/archive/<branch name>.zip#"subdirectory=foo&egg=macrolib.foo"']

dependency_links=['http://path/to/repo/archive/<branch name>.zip#subdirectory=foo&egg=macrolib.foo']
dependency\u links=[]http://path/to/repo.git@#“subdirectory=foo&egg=macrolib.foo”']
依赖关系链接=['http://path/to/repo.git@#子目录=foo&egg=macrolib.foo']
依赖关系链接=['http://path/to/repo/tarball/#“subdirectory=foo&egg=macrolib.foo”']
依赖关系链接=['http://path/to/repo/tarball/#subdirectory=foo&egg=macrolib.foo']
依赖关系链接=['http://path/to/repo/archive/.zip#“subdirectory=foo&egg=macrolib.foo”']
依赖关系链接=['http://path/to/repo/archive/.zip#subdirectory=foo&egg=macrolib.foo']
或者将前缀“git+”添加到上述所有URL


我的问题是,要将macrolib.foo安装为依赖项,依赖项链接的正确url格式是什么?或者是否有其他方法使其工作?

这是正确的格式(添加“git+”和依赖项版本):


谢谢添加
--进程依赖关系链接
确实使解决方案更接近一步,但由于链接格式无法识别,仍然会导致相同的错误。我刚刚发现添加
git+
和“依赖版本”可以使它正确。我对答案做了一点修改,以便能被接受。我还有一个问题。我可以看到许多其他人使用tarball/作为依赖项链接,例如。为什么.git链接也可以工作?因为
pip
可以运行
svn/hg/git clone
并在克隆的工作树中运行
python setup.py install
Collecting macrolib.foo (from macrolib.bar==0.1.0)
  Could not find a version that satisfies the requirement macrolib.foo (from macrolib.bar==0.1.0) (from versions: )
No matching distribution found for macrolib.foo (from macrolib.bar==0.1.0)
dependency_links=['http://path/to/repo.git@<branch name>#"subdirectory=foo&egg=macrolib.foo"']

dependency_links=['http://path/to/repo.git@<branch name>#subdirectory=foo&egg=macrolib.foo']

dependency_links=['http://path/to/repo/tarball/<branch name>#"subdirectory=foo&egg=macrolib.foo"']

dependency_links=['http://path/to/repo/tarball/<branch name>#subdirectory=foo&egg=macrolib.foo']

dependency_links=['http://path/to/repo/archive/<branch name>.zip#"subdirectory=foo&egg=macrolib.foo"']

dependency_links=['http://path/to/repo/archive/<branch name>.zip#subdirectory=foo&egg=macrolib.foo']
dependency_links=['git+http://path/to/repo.git@<branch name>#subdirectory=foo&egg=macrolib.foo-0.1.0']
pip install --process-dependency-links git+http://path/to/repo.git@<branch name>#"subdirectory=bar&egg=macrolib.bar"