acoustic-librarian-29560
02/06/2025, 4:56 PMacoustic-librarian-29560
02/06/2025, 6:30 PMkeyrings.google-artifactregistry-auth installed. Pex provides a --keyring-provider option so I just need a way to propagate that.acoustic-librarian-29560
02/06/2025, 7:01 PMkeyrings.google-artifactregistry-aut installed on the `PEX_PYTHON`path for this to work. I don't think there's a way to do that currently?curved-manchester-66006
02/06/2025, 7:12 PMkeyrings.google-artifactregistry-auth on a find links server/nfs-mount/checked-into-your-repoacoustic-librarian-29560
02/06/2025, 7:20 PMDownloading: file:///Users/nicholas.dellosa/Projects/my-repo/pex-cli.pexacoustic-librarian-29560
02/06/2025, 7:23 PMacoustic-librarian-29560
02/06/2025, 8:40 PMfast-nail-55400
02/06/2025, 8:45 PM--keyring-provider option to pass through to Pip.fast-nail-55400
02/06/2025, 8:46 PM--pex-cli-global-args is set to include --keyring-provider=subprocess and the keyring binary is installed somewhere on the PATH seen by Pex.fast-nail-55400
02/06/2025, 8:46 PMfast-nail-55400
02/06/2025, 8:48 PM@fast-nail-55400 Seems like you were able to get this to work?Which is to say, that it did appear to work against AWS CodeArtifact in a proof of concept setting. Relevant Pants PRs are https://github.com/pantsbuild/pants/pull/21852 and https://github.com/pantsbuild/pants/pull/21853. Note: I'm not in a position any more to finish those.
fast-nail-55400
02/06/2025, 8:50 PM--pex-cli-global-args sketched above is likely the way forward for now.acoustic-librarian-29560
02/06/2025, 9:30 PMkeyring and keyrings.google-artifactregistry-auth in a pex together which I named keyring and put in my /usr/local/bin directory. Then I set global_args = ["--keyring-provider=subprocess"] . Still not working, even though when I run keyring --list-backends it looks good.fast-nail-55400
02/06/2025, 9:36 PMPATH for the pex-cli invocations including the installation location?acoustic-librarian-29560
02/06/2025, 9:36 PM/usr/local/bin is in there.fast-nail-55400
02/06/2025, 9:37 PMacoustic-librarian-29560
02/06/2025, 9:38 PMpython3.fast-nail-55400
02/06/2025, 9:38 PMacoustic-librarian-29560
02/06/2025, 9:39 PMfast-nail-55400
02/06/2025, 9:39 PM--pex-verbosity=9fast-nail-55400
02/06/2025, 9:40 PM--keep-sandboxes=always) and try to find where the pip.log was writtenfast-nail-55400
02/06/2025, 9:42 PMacoustic-librarian-29560
02/06/2025, 9:42 PMacoustic-librarian-29560
02/06/2025, 9:42 PMfast-nail-55400
02/06/2025, 9:42 PM--keyring-provider) if only the vendored Pip in Pex (which does not support --keyring-provider) is available.fast-nail-55400
02/06/2025, 9:43 PM--keyring-provider option.fast-nail-55400
02/06/2025, 9:43 PMensurepip package.fast-nail-55400
02/06/2025, 9:44 PMacoustic-librarian-29560
02/06/2025, 9:48 PM2025-02-06T16:46:49,693 Keyring provider requested: subprocess
2025-02-06T16:46:49,693 Keyring provider set: subprocess with executable /usr/local/bin/keyring
2025-02-06T16:46:49,698 Status code 401 not in (200, 203, 300, 301, 308)
So it looks like it is using keyring but it's still getting unauthorizedfast-nail-55400
02/06/2025, 9:50 PMacoustic-librarian-29560
02/06/2025, 9:55 PMgcloud on my path and am logged in, but maybe the pex can't see that?fast-nail-55400
02/06/2025, 10:09 PMfast-nail-55400
02/06/2025, 10:10 PMacoustic-librarian-29560
02/06/2025, 10:21 PMkeyrings.google-artifactregistry-auth into a virtual environment it all works like magic. But when I put it in a pex the credentials are not set up right.acoustic-librarian-29560
02/06/2025, 10:26 PMpip install so it's an issue with the keyring pex and not Pants.fast-nail-55400
02/06/2025, 10:32 PMfast-nail-55400
02/06/2025, 10:33 PMacoustic-librarian-29560
02/06/2025, 10:34 PMacoustic-librarian-29560
02/06/2025, 10:34 PMacoustic-librarian-29560
02/07/2025, 3:36 PM--keyring-provider=import. When I set it to subprocess it fails the same way it does with pex.fast-nail-55400
02/07/2025, 4:08 PMfast-nail-55400
02/07/2025, 4:09 PMoauth2accesstokenacoustic-librarian-29560
02/07/2025, 4:14 PMkeyring get <my registry url> '' does work however.acoustic-librarian-29560
02/07/2025, 4:15 PMacoustic-librarian-29560
02/07/2025, 4:17 PM--keyring-provider=import does not work with pex?acoustic-librarian-29560
02/07/2025, 4:46 PMKeyring provider requested: subprocess
Keyring provider set: subprocess with executable /usr/bin/keyring
/root/.cache/pex/installed_wheels/0/e7dae6694313f434a2727bf2906f27ad259bae090d7aa896590d86feec3d9d4a/google_auth-2.38.0-py2.py3-none-any.whl/google/auth/_default.py:76: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. See the following page for troubleshooting: <https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds>.
warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
Found credentials in keyring for us-central1-python.pkg.dev
Status code 401 not in (200, 203, 300, 301, 308)
Looking up "<my repo>/<my package>" in the cache
Request header has "max_age" as 0, cache bypassed
No cache entry available
<https://us-central1-python.pkg.dev:443> "GET <my project>/<my repo>/<my package> HTTP/1.1" 401 60
WARNING: 401 Error, Credentials not correct for <my repo>/<my package>
💀acoustic-librarian-29560
02/07/2025, 4:46 PMfast-nail-55400
02/07/2025, 7:12 PMkeyring trampoline script to log the exact env and args passed to it, and then exec the real keyring binary (and tee stderr to a log). That might provide some insight into what is happening.
2. Inject a MitM proxy of some sort to inspect the actual request being sent.acoustic-librarian-29560
02/07/2025, 8:22 PMacoustic-librarian-29560
02/07/2025, 8:23 PMoath2accesstoken instead of oauth2accesstokenfast-nail-55400
02/08/2025, 6:08 PMacoustic-librarian-29560
02/10/2025, 2:46 PMacoustic-librarian-29560
02/10/2025, 4:44 PM--pip-version=latest set but no dice.
The --keyring-provider option is set to `subprocess`, but Pip v20.3.4+patched does not support the
`--keyring-provider` option (which is only available in Pip v23.1 and later versions).
Consequently, Pex is ignoring the --keyring-provider option for this particular Pip invocation.
Note: If this Pex invocation fails, it may be because Pex is trying to use its vendored Pip v20.3.4+patched
to bootstrap a newer Pip version which does support `--keyring-provider`, but you configured Pex/Pip
to use a Python package index which is not available without additional authentication.
In that case, you might wish to consider manually creating a `find-links` directory with that newer version
of Pip, so that Pex will still be able to install the newer version of Pip from the `find-links` directory
(which does not require authentication).acoustic-librarian-29560
02/10/2025, 4:45 PMacoustic-librarian-29560
02/10/2025, 5:19 PMacoustic-librarian-29560
02/10/2025, 5:28 PMfast-nail-55400
02/10/2025, 7:07 PM--keyring-provider ) to bootstrap a newer version of Pip which does support the optionfast-nail-55400
02/10/2025, 7:07 PMfast-nail-55400
02/10/2025, 7:10 PMfind-links at that directory)fast-nail-55400
02/10/2025, 7:11 PMacoustic-librarian-29560
02/10/2025, 7:12 PMnutritious-hair-72580
03/25/2025, 11:42 PMnutritious-hair-72580
03/26/2025, 3:42 AMpants publish, by adding a custom resolve for twine that contains the following requirements
twine
keyring
keyrings.google-artifactregistry-auth
That's without doing anything with --keyring-provideracoustic-librarian-29560
03/26/2025, 12:12 PM--keyring-provider=subprocess and creating a custom keyring binary that's actually a pex with keyring and keyrings.google-artifactregistry-auth provided and adding that to my PATH.acoustic-librarian-29560
03/26/2025, 12:13 PM"<https://oauth2accesstoken@YOUR_GAR_REGISTRY>"nutritious-hair-72580
03/26/2025, 10:25 PM[python.resolves]
python-default = "3rdparty/python/default.lock"
twine = "3rdparty/python/twine.lock"
[twine]
install_from_resolve = "twine"
requirements = ["//:twine-reqs"]
Where :twine-reqs is the requirements file with reqs mentioned above.
For registry pull (which I think this thread was originally about), I'm still using the oauth2token approach.acoustic-librarian-29560
03/27/2025, 5:52 PMstale-waitress-56895
04/01/2025, 4:25 PMacoustic-librarian-29560
04/01/2025, 4:42 PMkeyring and your provider in it, like this
pex_binary(
name="keyring",
dependencies=[":tool_requirements#keyring", ":tool_requirements#keyrings.google-artifactregistry-auth"],
resolve="tools",
interpreter_constraints=[">=3.8,<=3.12"],
sh_boot=True,
entry_point="keyring",
output_path="keyring",
)
and pop that pex onto your path somewhere, though not at /usr/local/bin which pip is weird about for some reason.
Then add your private registry to [python-repos].indexes and under [pex-cli] add global_args = ["--keyring-provider=subprocess"].