Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency links for extras_require in setup.py

  1. Is there a way to process dependency links automatically when installing a package with extras, without having to call --process-dependency-links as it is the case with install_requires?

    pip install -e .[extra] --process-dependency-links
    

    I need this because the dependency is only located on a private git repo.

  2. Is it possible to install extras using python setup.py install?

  3. Is --process-dependency-links still to be considered as it is deprecated? I am not sure about the status here.

like image 584
tupui Avatar asked Dec 07 '16 20:12

tupui


2 Answers

I searched way too long to figure out how to do this with setup.cfg so hopefully this will help someone else if they don't want to use setup.py as the OP didn't specify. I've also included a custom URL for install_requires as that took a while to figure out as well.

#setup.cfg (only showing relevant parts)
[options]
install_requires =
    pyyaml @ git+https://github.com/yaml/pyyaml.git@master
    
[options.extras_require]
jsonschema = jsonschema @ git+https://github.com/Julian/[email protected]
six = six
  1. pip install -e .[jsonschema] will get you the extra with a custom URL or pip install -e .[jsonschema,six] will get you both extras (note that there are NO spaces after the . or around the comma(s) in the extras list).
  2. As far as I can tell, you cannot get extras installed using python setup.py install.
  3. Yes --process-dependency-links is still deprecated in spite of much complaining but the above is good enough once you know the syntax.
like image 152
Eric McDonald Avatar answered Oct 17 '22 10:10

Eric McDonald


  1. Yes, you no longer need --process-dependency-links if you use extras_require.

Tested with pip version 19.3.1

Example:

$ pip install -e .[graphs]

# setup.py  

from setuptools import setup
setup(
    name='myservice',
    version='0.1.0',
    install_requires=[
        'requests',
    ],
    extras_require={
        'graphs': [
            'graphcommons @ git+ssh://[email protected]/graphcommons/graphcommons-python@master',
        ],
    },
)

By using ssh protocol (instead of https) to access git repo, you can install from your private repos.

  1. Not sure about python setup.py install but pip install .[extras] should be good enough?

  2. Yes, in pip version 19.

like image 25
chishaku Avatar answered Oct 17 '22 11:10

chishaku