pex_binary question I was running through the <Op...
# general
g
pex_binary question I was running through the Optimizing Python + Docker deploys using Pants blog post and I found that the pex_binary with
include_sources=False
doesn't actually include anything in the pex. Before I followed the blog post the pex_binary had everything in it.
Copy code
$ pants package apps/app-api:binary-deps
15:10:29.30 [INFO] Wrote dist/apps.app-api/binary-deps.pex

$ tree dist/apps.app-api/binary-deps.pex
dist/apps.app-api/binary-deps.pex
├── PEX-INFO
├── __main__.py
└── __pex__
    └── __init__.py

1 directory, 3 files
Copy code
# BUILD
pex_binary(
    name="binary-deps",
    include_sources=False,
    include_tools=True,
    complete_platforms=[
        "3rdparty/platforms:docker_python_3_9_bullseye",
    ],
    dependencies=[
        "apps/app-api:poetry#celery",
        "apps/app-api:poetry#ddtrace",
        "apps/app-api:poetry#gunicorn",


        # Generated
        "apps/app-api/app_api:app_api",
        "apps/app-api/app_api/alembic:alembic",
        "apps/app-api/app_api/alembic/versions:versions",
        "apps/app-api/app_api/auth:auth",
        "apps/app-api/app_api/config:config",
        "apps/app-api/app_api/controllers:controllers",
        "apps/app-api/app_api/custom_models:custom_models",
        "apps/app-api/app_api/data:data",
    ],
    # Optimal settings for Docker builds
    layout = "packed",
    execution_mode = "venv",
)
c
do you see any 3rd party deps as dependencies when peek'ing that
pex_binary
?
pants peek apps/app-api:binary-deps
would expect so, given you have a few explicitly listed there, by the looks of it. in which case I'm 🤷 (don't know much about how pex works... 😬 )
g
yep, it's in there
Copy code
$ pants peek apps/app-api:binary-deps
[
  {
    "address": "apps/app-api:binary-deps",
    "target_type": "pex_binary",
    "args": null,
    "complete_platforms": [
      "3rdparty/platforms:docker_python_3_9_bullseye"
    ],
    "dependencies": [
      "apps/app-api:poetry#celery",
      "apps/app-api:poetry#ddtrace",
      "apps/app-api:poetry#gunicorn",
...
c
my next step would probably be to run with
--keep-sandboxes=always
and inspect the sandbox building the pex file, to see what files are in there, and what pex command was used etc..
g
yeah, that's the path I'm headed down. Thank you.
👌 1
c
sorry I'm not able to be more helpful 😉
b
Just to double-check here - if you comment out these two lines, everything comes back into the PEX?
Copy code
include_sources=False,
include_tools=True,
👍 1
g
I'm realizing I'm clueless how PEX works 🙂 I changed the
layout
from
packed
to
loose
without any other changes and it breaks everything also 😢
b
I think pex might put things in hidden directories (
.deps
maybe), so if you’re inspecting one, make sure that those are included in the listing (eg
ls -a
)