Okay my pants migration is far along enough to fin...
# general
p
Okay my pants migration is far along enough to finally say.. macro time (oddly enough I'm realizing that this is my favorite part of being a long term bazel user... tweaking the build for your specific build). I have apps that I run with gunicorn. I got this target to work
Copy code
pex_binary(
  name="app",
  script="gunicorn",
  args=["foo.bar.baz:app"],
  dependencies=[
    ":bar",   <---- This is the //foo/bar:bar where baz.py lives
    ".build/requirements:reqs#gunicorn"
],
)
I'd like to present this interface in the build
Copy code
gunicorn_pex_binary(
  name="app",
  wsgi_app = file:app (where file == pwd/baz.py)
)
Where app is of form
$(module_name):$(variable_name)
Under the hood this makes the pex_binary target where the file is added as a dependency to the pex_binary target. Is there a way I can construct this macro by getting the .. calling location? of the target? In bazel I'd accomplish this with
package_name
and minimal starlark.
b
build_file_dir()
returns a
pathlib.PurePath
of the
BUILD
file's dir
p
Can I throw errors if something is invalid? Like wsgi_app doesn’t end with
.py
b
I don't remember. Try it and find out
c
you should be able to throw errors, I believe…