Does pip handle extras_requires from setuptools/distribute based sources?

前端 未结 3 452
囚心锁ツ
囚心锁ツ 2020-12-24 10:54

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

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

And a package \"

相关标签:
3条回答
  • 2020-12-24 11:31

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

    0 讨论(0)
  • 2020-12-24 11:34

    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
    
    0 讨论(0)
  • 2020-12-24 11:42

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

    0 讨论(0)
提交回复
热议问题