本文介绍了如何编写setup.py以包含Git存储库作为依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的包裹写 setup.py .我的程序包需要指定对另一个Git存储库的依赖.

I am trying to write setup.py for my package. My package needs to specify a dependency on another Git repository.

这是我到目前为止所拥有的:

This is what I have so far:

from setuptools import setup, find_packages

setup(
    name='abc',
    packages=find_packages(),
    url='https://github.abc.com/abc/myabc',
    description='This is a description for abc',
    long_description=open('README.md').read(),
    install_requires=[
        "requests==2.7.0",
        "SomePrivateLib>=0.1.0",
        ],
    dependency_links = [
     "git+git://github.abc.com/abc/SomePrivateLib.git#egg=SomePrivateLib",
    ],
    include_package_data=True,
)

当我跑步时:

pip install -e https://github.abc.com/abc/myabc.git#egg=analyse

我知道

我在做什么错了?

推荐答案

注意:该答案现在已过时.请在下面的@Dick Fox中查看此答案以获取最新说明: https://stackoverflow.com/a/54794506/2272172

Note: this answer is now outdated. Have a look at this answer below from @Dick Fox for up-to-date instructions: https://stackoverflow.com/a/54794506/2272172

您可以找到正确的方法这里.

You can find the right way to do it here.

dependency_links=['http://github.com/user/repo/tarball/master#egg=package-1.0']

关键不是提供指向Git存储库的链接,而是提供指向tarball的链接.如果您如上所示附加/tarball/master ,则GitHub会为您创建master分支的tarball.

The key is not to give a link to a Git repository, but a link to a tarball. GitHub creates a tarball of the master branch for you if you append /tarball/master as shown above.

这篇关于如何编写setup.py以包含Git存储库作为依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 05:40