Skip to content

Instantly share code, notes, and snippets.

@baijum
Created July 10, 2011 18:03
Show Gist options
  • Save baijum/1074767 to your computer and use it in GitHub Desktop.
Save baijum/1074767 to your computer and use it in GitHub Desktop.
Flask Notes

Flask Notes

Useful Links

setup.py

from setuptools import setup, find_packages

setup(
    name="tracker",
    version="1.0.0",
    description="Issue Tracker",
    author="Baiju Muthukadan",
    url="https://gist.github.com/1074767",
    packages=find_packages("src"),
    package_dir={"": "src"},
    include_package_data=True,
    zip_safe=False,
    install_requires=[
        "setuptools",
        "Flask",
        "Flask-Script",
        "Flask-SQLAlchemy",
        "Flask-WTF",
        "blinker",
        "psycopg2",
        "gunicorn",
    ],
    extras_require=dict(
        test = ["pytest",
                "pytest-cov",
                "pytest-capturelog",
                ]),
    )

Buildout Configuration

[buildout]
develop = .
parts =
    pytest
    testrunner
    gunicorn
    tracker
    tracker_config
    tracker_env

[config]
host = 0.0.0.0
port = 8080

[pytest]
recipe = z3c.recipe.scripts
# Need exit status code for buildbot.
# See https://bugs.launchpad.net/zc.buildout/+bug/164629
script-initialization =
  import pytest
  if __name__ == '__main__': sys.exit(pytest.main())
eggs =
    tracker [test]
    pytest
scripts = py.test

[testrunner]
recipe = collective.recipe.template
input = inline:
    ${buildout:bin-directory}/${pytest:scripts} src --cov tracker --cov-report html $@
output = ${buildout:bin-directory}/run_all_tests
mode = 755

[tracker_config]
recipe = collective.recipe.template
input = inline:
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = 'sqlite:////${buildout:directory}/var/trackerdb.sqlite'
    SECRET_KEY = 'secret_key'
output = ${buildout:directory}/var/tracker_config.py

[tracker_env]
recipe = collective.recipe.template
input = inline:
    export TRACKER_SETTINGS=${tracker_config:output}
output = ${buildout:directory}/var/tracker_env.sh

[tracker]
recipe = z3c.recipe.scripts
eggs = tracker
entry-points = tracker=tracker.main:run
interpreter = python
script-initialization =
    host = "${config:host}"
    port = ${config:port}
arguments = host, port

[gunicorn]
recipe = z3c.recipe.scripts
eggs =
    tracker [test]
entry-points =
    gunicorn=gunicorn.app.wsgiapp:run
    coverage=coverage:main

Flask projects with code and test

@baijum
Copy link
Author

baijum commented Aug 1, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment