Search code examples
pythonpipdistutilspypi

Python live dependency installation via pip (PyPI)


I want to pull the live version of a package as a dependency of another package I install with pip.

Now, I have already found out how to install a live version of a package via pip; and that is not the question I am asking here.

I'd like to know whether I can pull in a live dependency version (e.g. from the PyPI index) - at present I was only able to set up tarballs via PyPI.


Solution

  • In your setup.py, do:

    from setuptools import setup
    
    
    setup(
        ...
        install_requires=[
            'a_required_pypi_package',
            'another_package_in_pypi>=minimum_version'
        ]
        ...
    )
    

    and pip, setup.py install or setup.py develop will take care of it.

    However the requirement will be considered satisfied, if any version of a_required_pypi_package is installed. This is especially true, if you use pip freeze to write a requirements.txt and use it to install packages.