Skip to content

Instantly share code, notes, and snippets.

@ewhauser
Created April 19, 2022 15:31
Show Gist options
  • Save ewhauser/3c6eaaec507e96e068cc6633a3ec135a to your computer and use it in GitHub Desktop.
Save ewhauser/3c6eaaec507e96e068cc6633a3ec135a to your computer and use it in GitHub Desktop.
Bazel + Gunicorn
from gunicorn.app.wsgiapp import run
run()
gunicorn_binary(
name = "hello",
args = ["hello:app"],
deps = [
"@pypi_flask//:pkg",
],
)
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
def gunicorn_binary(name, deps = [], **kwargs):
py_library(
name = name + "_lib",
srcs = [name + ".py"],
deps = deps,
)
args = kwargs.pop("args", [name + ":app"])
py_binary(
name = name,
srcs = ["//python/wrappers/gunicorn:__main__.py"],
main = "//python/wrappers/gunicorn:__main__.py",
deps = [
"@pypi_gunicorn//:pkg",
":" + name + "_lib",
],
args = args,
**kwargs
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment