90

In my setup.py file, I've specified a few libraries needed to run my project:

setup(
    # ...
    install_requires = [
        'django-pipeline',
        'south'
    ]
)

How can I specify required versions of these libraries?

Tarsis Azevedo
  • 1,304
  • 13
  • 20
Naftuli Kay
  • 75,812
  • 80
  • 244
  • 374

1 Answers1

134

I'm not sure about buildout, however, for setuptools/distribute, you specify version info with the comparison operators (like ==, >=, or <=).

For example:

install_requires = ['django-pipeline==1.1.22', 'south>=0.7']
Adam Wagner
  • 13,492
  • 6
  • 50
  • 64
  • 1
    to undestand the setup.py better [read the docs](http://docs.python.org/distutils/setupscript.html) – Tarsis Azevedo Nov 17 '11 at 03:48
  • I know setup.py with distutils/setuptools/distribute, does buildout use this as well? I've never used it before, and wasn't sure why the OP mentioned buildout. – Adam Wagner Nov 17 '11 at 03:51
  • 4
    Buildout honors the `install_requires` entry of packages, including version requirements. It uses setuptools under the hood for this. – Martijn Pieters Nov 17 '11 at 07:13
  • Nice, thanks, that answers my question. I forgot that Buildout used setuptools under the hood. – Naftuli Kay Nov 17 '11 at 22:01
  • 2
    How can I specify the version of python? – qed Jul 27 '14 at 20:05
  • Does setup.py also honour the versions I have installed in my current env? Or does it just fetch the latest ones available? – Dev Aggarwal Sep 24 '18 at 16:43
  • 1
    @qed `python_requires='>=3',` [More information](https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires) – tuomastik Sep 28 '19 at 14:54
  • 2
    @TarsisAzevedo unfortunately the docs does not give these examples, as of April 2021. That page doesn’t even mention “ install_requires” – Tianyi Shi Apr 08 '21 at 11:32