microscopic-parrot-94355
02/08/2024, 1:22 AMpex_binary 's script tag. I get the sense that I'm missing something obvious. Example:
# my/code/BUILD
python_sources()
pex_binary(
name="my_server",
script="gunicorn",
args=[
"--timeout",
"120",
"my.code.server:create_app()",
],
dependencies=[
"//.build/requirements:reqs#gunicorn",
# What do I put here to include the my.code.server + depenencies?
],
)
Basically, I'm getting a "No module found" error when I try to run the resulting PEX, and indeed, the my.code.server module does not seem to be packaged in the PEX file.
There are two gunicorn examples that I was able to find. The one I based this on appears here, but doesn't seem to be complete. (Unless I'm missing something, I don't think the required code would be packaged?)
The second example I found appears in the Django example, but it requires a lot of shim code that the script tag is supposed to avoid. Thanks in advance!microscopic-parrot-94355
02/08/2024, 6:18 PM# my/code/BUILD
python_sources(name="my_code_src")
pex_binary(
name="my_server",
script="gunicorn",
args=[
"--timeout",
"120",
"my.code.server:create_app()",
],
dependencies=[
"//.build/requirements:reqs#gunicorn",
"//my/code/server.py:my_code_src", # This was not obvious to me...
],
)curved-television-6568
02/09/2024, 1:59 PMentry_point for a pex_binary pants figures out the dependency for you, but here the dependency is embedded in the args which pants doesn't introspect, hence you need to add the dependency on your application code explicitly, otherwise pants doesn't know it should be included.