Question

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.

Was it helpful?

Solution

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')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top