https://pantsbuild.org/ logo
#general
Title
# general
r

rhythmic-morning-87313

05/01/2022, 9:36 AM
Q19: When I run
./pants run src/ai/backend/manager:server
(a
pex_binary()
target which depends on
python_sources()
target) or
./pants run src/ai/backend/manager/server.py
, it says
importlib.metadata.PackageNotFoundError: No package metadata was found for backend.ai-manager
with the following
__init__.py
. How do I make the package version information available in this case?
1
The pex binary seems to have missing dependencies (reqs were not explicitly propagated?).. hmm
I'm currently workarounding this by
__version__ = "<http://0.0.0.dev|0.0.0.dev>"
which may break in my API implementation's version check routines...
w

witty-crayon-22786

05/01/2022, 4:55 PM
is the version loaded from a resource/file? what are you expecting it to be computed from?
if it’s supposed to be a resource, then you need to make sure that your target has a (transitive) dependency on a
resources
target covering the file
👍 1
if it’s something that you’re expecting to be provided by a dist (i.e., you’re expecting a wheel to be built, and for it to have a version via setup.py/etc), then you’d need to depend on a
python_distribution
👍 1
r

rhythmic-morning-87313

05/02/2022, 6:28 AM
hmm. When I try to refer the VERSION file in the repository root in
resources()
of pkg-specific BUILD files, it says
Exception: Absolute paths not supported: "//:version"
i've tried to create a symbolic link from
src/ai/backend/common/VERSION
to
VERSION
, but it seems not to be recognized by pants (in
./pants peek
and
./pants dependencies
)
ah, that's my mistake to put dependency in sources key.
using symlinks resolved the issue!
w

witty-crayon-22786

05/02/2022, 4:04 PM
in many cases you can use multiple
resources
targets rather than symlinks, but yea: glad it’s working.
5 Views