Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does pip handle extras_requires from setuptools/distribute based sources?

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?

like image 765
dsully Avatar asked Jan 25 '11 17:01

dsully


People also ask

Does pip depend on setuptools?

In Fedora, our pip package Recommends setuptools. Practically that means: Majority of users who install pip will get setuptools by default. Users can explicitly uninstall setuptools after installing pip or exclude setuptools when installing pip.

Does pip pull from PyPi?

pip is installing the packages from PyPi, yes. On the PyPi website you can find links to github where you can find the full package code, but where pip download is PyPi.

Does pip check for dependencies?

Because pip doesn't currently address dependency issues on installation, the pip check command option can be used to verify that dependencies have been installed properly in your project.


3 Answers

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
like image 53
aaronfay Avatar answered Oct 19 '22 02:10

aaronfay


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

like image 27
TryPyPy Avatar answered Oct 19 '22 02:10

TryPyPy


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]".

like image 18
cantdutchthis Avatar answered Oct 19 '22 02:10

cantdutchthis