I have a package called `pytest-emulators-ewx` in ...
# general
c
I have a package called
pytest-emulators-ewx
in a private Google Artifact Registry repo and I need Pants to use it as a requirement. I authenticate with
keyrings.google-artifactregistry-auth
and this works fine in Poetry (and
pip
). However, when I run
pants test ::
I run into this error (anonymized):
Copy code
22:27:32.95 [INFO] Completed: Building requirements.pex with 12 requirements: dependency-injector-fork<5.0.0,>=4.42.1, google-cloud-pubsub<3.0.0,>=2.21.5, google-cloud-storage<3.0.0,>=2.17.0, pulsar-client<4.0.0,>=3.5.0, pydantic<... (217 characters truncated)
22:27:32.96 [ERROR] 1 Exception encountered:

Engine traceback:
  in `test` goal

ProcessExecutionFailure: Process 'Building requirements.pex with 12 requirements: dependency-injector-fork<5.0.0,>=4.42.1, google-cloud-pubsub<3.0.0,>=2.21.5, google-cloud-storage<3.0.0,>=2.17.0, pulsar-client<4.0.0,>=3.5.0, pydantic<2.0.0,>=1.10.10, pytest-emulators-ewx<0.13.0,>=0.12.0, pytest<8.0.0,>=7.4.4, redis<5.0.0,>=4.6.0, types-redis<5.0.0,>=4.6.0.20240425, types-requests<3.0.0,>=2.32.0.20240622, urllib3<3.0.0,>=2.2.2, xxhash<4.0.0,>=3.4.1' failed with exit code 1.
stdout:

stderr:
pid 32450 -> /path/to/python -sE /path/to/pex --disable-pip-version-check --no-python-version-warning --exists-action a --no-input --isolated -q --cache-dir /path/to/cache/pex_root/pip/24.0/pip_cache --log /path/to/log/pex-pip-log.log download --dest /path/to/cache/pex_root/downloads/resolver_download/usr.bin.python3.12 dependency-injector-fork<5.0.0,>=4.42.1 google-cloud-pubsub<3.0.0,>=2.21.5 google-cloud-storage<3.0.0,>=2.17.0 pulsar-client<4.0.0,>=3.5.0 pydantic<2.0.0,>=1.10.10 pytest-emulators-ewx<0.13.0,>=0.12.0 pytest<8.0.0,>=7.4.4 redis<5.0.0,>=4.6.0 types-redis<5.0.0,>=4.6.0.20240425 types-requests<3.0.0,>=2.32.0.20240622 urllib3<3.0.0,>=2.2.2 xxhash<4.0.0,>=3.4.1 --index-url <https://pypi.org/simple/> --extra-index-url <https://example.com/python-private/simple/> --retries 5 --timeout 15 exited with 1 and STDERR:
ERROR: Could not find a version that satisfies the requirement pytest-emulators-ewx<0.13.0,>=0.12.0 (from versions: none)
ERROR: No matching distribution found for pytest-emulators-ewx<0.13.0,>=0.12.0
So I guess the question is. How do I use Pants with a requirement that lives in a private Google Artifact Registry repo? I also like to understand what's happening: Idon't completely get how Pants is telling pex what (to tell pip what) to do. I can't recreate it with vanilla pex for example. (Complains that
--extra-index-url
is not a valid flag. Which is correct, that's a pip flag.
c
Hi! Have you provided the index url for the GAR repo in your
pants.toml
? https://www.pantsbuild.org/2.21/reference/subsystems/python-repos#indexes
c
Hey Andreas, Yes I did. That's when it started showing up in the above command as
--extra-index-url
c
Ah, yea sorry, I was looking for that but missed it 😛 So my only other avenue to explore then would be if there could be any constraints on
pytest-emulators-ewx
that gets discarded.. but the
(from versions: none)
seems to suggest not, so I'm all out of ideas on this one (not my area of expertise either..)
c
Thanks, I'll see if I can verify that.
h
Pants uses its own internal
pip
, maybe the internal config isn’t targeting keyring in the same way normal pip’s default config would? Could try playing around with keyring flag https://pip.pypa.io/en/stable/topics/authentication/#keyring-support
c
Thanks, I'll do that too
I'm trying, but I can't find where/how I even configure the internal
pip
used by Pants. I get the feeling I'm thinking about it the wrong way, but I can't figure out the right one.
Oh wow, that
pex
executable is actually pip. Okey, I may have a lead now.
Nope, no joy. I think I need to add
keyrings.google-artifactregistry-auth
to the Pants internal
pip
(Before it runs. I can't just add it as a req.) Any idea how I can do that?
Okey, it does work if I use this method: https://cloud.google.com/artifact-registry/docs/python/authentication#sa-key So I'm down to 2 theories: either
keyrings.google-artifactregistry-auth
is not available as a package to pip when its building, or it is but it somehow doesn't have access to the credentials.