0

I have a flask app where I'm trying to automate deployment to EC2.

Not a big deal, but is there a setting in either Fabric or Distribute that reads the requirements.txt file directly for the setup.py, so I don't have to spell everything out in the setup(install_requires=[]) list, rather than writing a file reader for my requirements.txt? If not, do people have recommendations or suggestions on auto-deployment and with pip?

I'm reviewing from here and here.

Mittenchops
  • 18,633
  • 33
  • 128
  • 246

1 Answers1

0

Not a big deal, but is there a setting in either Fabric or Distribute that reads the requirements.txt file directly for the setup.py, so I don't have to spell everything out in the setup(install_requires=[]) list, rather than writing a file reader for my requirements.txt?

You might still want to checkout frb's answer to the duplicate question How can I reference requirements.txt for the install_requires kwarg in setuptools.setup?, which provides a straight forward two line solution for writing a file reader.

If you really want to avoid this, you could alternatively add the common pip install -r requirements.txtto your fabfile.py, e.g.:

# ...
# create a place where we can unzip the tarball, then enter
# that directory and unzip it
run('mkdir /tmp/yourapplication')
with cd('/tmp/yourapplication'):
    run('tar xzf /tmp/yourapplication.tar.gz')
    # now install the requirements with our virtual environment's
    # pip installer
    run('/var/www/yourapplication/env/scripts/pip install -r requirements.txt')
    # now setup the package with our virtual environment's
    # python interpreter
    run('/var/www/yourapplication/env/bin/python setup.py install')
Community
  • 1
  • 1
Steffen Opel
  • 63,899
  • 11
  • 192
  • 211
  • Yeah, it's something that was so simple it wasn't a problem to write, but was also simple enough I equally assumed good python package writers may have just added an option somewhere. Thanks! – Mittenchops Apr 19 '13 at 13:44
  • @Mittenchops - Agreed, the non unified state of Python's various setup procedures/tools is actually violating [PEP 20](http://www.python.org/dev/peps/pep-0020/), unfortunately: _"There should be one-- and preferably only one --obvious way"_ to specify (and use) package/setup metadata, which obviously includes dependencies ... – Steffen Opel Apr 19 '13 at 15:51