high-psychiatrist-4761
07/25/2025, 5:29 PMproject/config/redis/
project/config/cassandra/
project/app1
project/app2
app1 and app2 both need these shared configs for redis and cassandra. When I distribute app1 or app2, I want to claim these configs as resources. How can I do it? I try to put BUILD
file under project/config, and define resource in it, and then include it in the app1 and app2's BUILD files’ dist section. But pants complain there is no owner for project/configcurved-manchester-66006
07/25/2025, 5:31 PMhigh-psychiatrist-4761
07/25/2025, 5:34 PMpython_distribution
in the file project/config/BUILD
. Obviously, I do not want to publish config files only as a python package
10:32:19.30 [ERROR] 1 Exception encountered:
Engine traceback:
in `package` goal
NoOwnerError: No python_distribution target found to own project/config/redis/integration/config.json:../../resource. Note that the owner must be in or above the owned target's directory, and must depend on it (directly or indirectly). See <https://www.pantsbuild.org/2.27/docs/python/overview/building-distributions> for how python_sources targets are mapped to distributions. See <https://www.pantsbuild.org/2.27/docs/python/overview/building-distributions>.
curved-manchester-66006
07/25/2025, 5:50 PMpython_distribution
is meant to build python wheels for use outside of the monorepo. In that use case each file needs to belong to exactly one wheel, just like one would expect from a package on PyPI. If the resources in question are covered by a python_distribution
, then the generated metadata for the app1
should depend on it.
The more typical way to package up and entire application and deploy it would be to use pex and/or docker.high-psychiatrist-4761
07/25/2025, 5:56 PMcurved-manchester-66006
07/25/2025, 6:30 PMhigh-psychiatrist-4761
07/25/2025, 7:28 PMpython_distribution
cannot include the shared resources?busy-ram-14533
07/25/2025, 7:53 PMresource
targets that are dependencies on the pex_binary
target will get packaged into the .pex output
example
# project/BUILD
resources(
name="configs",
sources=["config/**/*.json"] # update to match your config files
)
pex_binary(
name="app1",
entry_point="app1/main.py",
dependencies=[":configs"]
)
pex_binary(
name="app2",
entry_point="app2/main.py",
dependencies=[":configs"]
)
something like this, although usually you'd have multiple BUILD files
if you do
pants package ::
and then
unzip -l dist/project.app1/app1.pex
you'll see the config files in therehigh-psychiatrist-4761
07/25/2025, 11:17 PMbusy-ram-14533
07/25/2025, 11:24 PMhigh-psychiatrist-4761
07/25/2025, 11:25 PMhigh-psychiatrist-4761
07/25/2025, 11:26 PMpython_distribution
, have not tried pexhigh-psychiatrist-4761
07/25/2025, 11:27 PMbusy-ram-14533
07/25/2025, 11:28 PMpex_binary
target. Is that not an option? For portable python apps, a .pex file usually makes a lot of sensehigh-psychiatrist-4761
07/25/2025, 11:28 PMbusy-ram-14533
07/25/2025, 11:32 PMpants package
to build the pex files, and then that CI job adds the git commit sha (as a sort of version) before uploading them. I’m sure it’s simpler if you’re packaging it into a docker image or uploading to something like Artifactorybusy-ram-14533
07/25/2025, 11:34 PMbusy-ram-14533
07/25/2025, 11:35 PMhigh-psychiatrist-4761
07/25/2025, 11:39 PMhigh-psychiatrist-4761
07/26/2025, 1:36 AM1.2.3
, this released docker image can be overridden, right? The benefit for pypi package is that once you upload the version, it cannot be overridden. Any solution for this?curved-manchester-66006
07/28/2025, 3:25 PM