我希望PIP在用户发出命令以安装原始软件(也从github上的源)上安装原始软件时,安装我在github上的依赖项。这些包都没有在PYPI上(并且永远不会)。

用户发出命令:

pip -e git+https://github.com/Lewisham/cvsanaly@develop#egg=cvsanaly

这个存储库有一个 requirements.txt 文件,另一个对github的依赖性:

-e git+https://github.com/Lewisham/repositoryhandler#egg=repositoryhandler

我想要的是 单命令 用户可以发出安装原始软件包,让PIP查找需求文件,然后安装依赖项。

有帮助吗?

解决方案

这个答案 帮助我解决了您所谈论的同样问题。

setup.py似乎没有一种简单的方法可以直接使用需求文件来定义其依赖项,但是可以将相同的信息放入setup.py本身中。

我有这个要求。txt:

PIL
-e git://github.com/gabrielgrant/django-ckeditor.git#egg=django-ckeditor

但是,在安装该要求。TXT的包含软件包时,PIP忽略了要求。

此设置。PY似乎可以迫使PIP安装依赖项(包括我的django-ckeditor的GitHub版本):

from setuptools import setup

setup(
    name='django-articles',
    ...,
    install_requires=[
        'PIL',
        'django-ckeditor>=0.9.3',
    ],
    dependency_links = [
        'http://github.com/gabrielgrant/django-ckeditor/tarball/master#egg=django-ckeditor-0.9.3',
    ]
)

编辑:

这个答案 还包含一些有用的信息。

需要将版本指定为“ #EGG = ...”的一部分,以识别链接中可以使用哪个版本的软件包。 但是请注意,如果您始终想依赖最新版本,则可以将版本设置为 dev 在install_requires,depentency_links和其他软件包的设置中

编辑: 使用 dev 根据以下评论,由于版本不是一个好主意。

其他提示

这是我用来生成的小脚本 install_requiresdependency_links 从需求文件。

import os
import re

def which(program):
    """
    Detect whether or not a program is installed.
    Thanks to http://stackoverflow.com/a/377028/70191
    """
    def is_exe(fpath):
        return os.path.exists(fpath) and os.access(fpath, os.X_OK)

    fpath, _ = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ['PATH'].split(os.pathsep):
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

    return None

EDITABLE_REQUIREMENT = re.compile(r'^-e (?P<link>(?P<vcs>git|svn|hg|bzr).+#egg=(?P<package>.+)-(?P<version>\d(?:\.\d)*))$')

install_requires = []
dependency_links = []

for requirement in (l.strip() for l in open('requirements')):
    match = EDITABLE_REQUIREMENT.match(requirement)
    if match:
        assert which(match.group('vcs')) is not None, \
            "VCS '%(vcs)s' must be installed in order to install %(link)s" % match.groupdict()
        install_requires.append("%(package)s==%(version)s" % match.groupdict())
        dependency_links.append(match.group('link'))
    else:
        install_requires.append(requirement)

这回答了你的问题了吗?

setup(name='application-xpto',
  version='1.0',
  author='me,me,me',
  author_email='xpto@mail.com',
  packages=find_packages(),
  include_package_data=True,
  description='web app',
  install_requires=open('app/requirements.txt').readlines(),
  )
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top