pip 是否处理来自 setuptools/distribute 源的 extras_requires ?

发布于 2024-10-14 05:28:04 字数 733 浏览 6 评论 0原文

我有一个包含 setup.py 和 extras_requires 行如下:

extras_require = {
    'ssh':  ['paramiko'],
},

以及依赖于 util 的包“B”:

install_requires = ['A[ssh]']

如果我在包 B 上运行 python setup.py install,它使用 setuptools.command .easy_install 在引擎盖下,extras_requires 已正确解析,并且 paramiko 已安装。

但是,如果我运行 pip /path/to/Bpip hxxp://.../b-version.tar.gz,则会安装软件包 A,但是帕里米科不是。

因为 pip “从源安装”,所以我不太确定为什么这不起作用。它应该调用B的setup.py,然后解析&安装 B 和 A 的依赖项。

这可以用 pip 实现吗?

I have package "A" with a setup.py and an extras_requires line like:

extras_require = {
    'ssh':  ['paramiko'],
},

And a package "B" that depends on util:

install_requires = ['A[ssh]']

If I run python setup.py install on package B, which uses setuptools.command.easy_install under the hood, the extras_requires is correctly resolved, and paramiko is installed.

However, if I run pip /path/to/B or pip hxxp://.../b-version.tar.gz, package A is installed, but paramiko is not.

Because pip "installs from source", I'm not quite sure why this isn't working. It should be invoking the setup.py of B, then resolving & installing dependencies of both B and A.

Is this possible with pip?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

说谎友 2024-10-21 05:28:04

我们使用 setup.pypip 来管理包的开发依赖项,但您需要更新版本的 pip(我们使用的是 1.4)目前为.1)。

#!/usr/bin/env python
from setuptools import setup
from myproject import __version__ 

required = [
    'gevent',
    'flask',
    ...
]

extras = {
    'develop': [
        'Fabric',
        'nose',
    ]
}

setup(
    name="my-project",
    version=__version__,
    description="My awsome project.",
    packages=[
        "my_project"
    ],
    include_package_data=True,
    zip_safe=False,
    scripts=[
        'runmyproject',
    ],
    install_requires=required,
    extras_require=extras,
)

安装包:

$ pip install -e . # only installs "required"

开发:

$ pip install -e .[develop] # installs develop dependencies

We use setup.py and pip to manage development dependencies for our packages, though you need a newer version of pip (we're using 1.4.1 currently).

#!/usr/bin/env python
from setuptools import setup
from myproject import __version__ 

required = [
    'gevent',
    'flask',
    ...
]

extras = {
    'develop': [
        'Fabric',
        'nose',
    ]
}

setup(
    name="my-project",
    version=__version__,
    description="My awsome project.",
    packages=[
        "my_project"
    ],
    include_package_data=True,
    zip_safe=False,
    scripts=[
        'runmyproject',
    ],
    install_requires=required,
    extras_require=extras,
)

To install the package:

$ pip install -e . # only installs "required"

To develop:

$ pip install -e .[develop] # installs develop dependencies
恰似旧人归 2024-10-21 05:28:04

自 2012 年 2 月(提出此问题一年后)发布的 pip 1.1 起就支持这一点。

This is suppported since pip 1.1, which was released in February 2012 (one year after this question was asked).

弄潮 2024-10-21 05:28:04

@aaronfay 的答案是完全正确的,但最好指出,如果您使用 zsh,则安装命令 pip install -e .[dev] 需要替换为 pip install -e ".[dev]"

The answer from @aaronfay is completely correct but it may be nice to point out that if you're using zsh that the install command pip install -e .[dev] needs to be replaced by pip install -e ".[dev]".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文