victorious-keyboard-86089
09/11/2023, 1:49 PMpackage = {version = "==1.0", editable = true, git = "https://${GITHUB_TOKEN}@github.com/githuborg/package@package-1.0"}
This works fine locally to generate Pipfile.lock, but when trying to package using pants, it keeps throwing this error and I am not able to find a solution:
ERROR: Could not find a version that satisfies the requirement package==1.0
ERROR: No matching distribution found for package==1.0
I am sorry if this is a repeated question and if this is quite straightforward, but can someone help me with this?
The env variable GITHUB_TOKEN
is something that is available in the local environment and will also be available to run in CI as well, as we have a CI pipeline for the project.
I tried adding the following in pants.toml to get it to work, but it did not help:
[subprocess-environment]
env_vars.add = ["GITHUB_TOKEN"]
bitter-ability-32190
09/11/2023, 1:51 PMpants --keep-sandboxes=on_failure ...
Run your command with that flag and Pants won't cleanup the sandbox of any Process that failed.
You can then try and re-run the command, see the output, twiddle bits, etc... and find out what's truly going on under the hoodlate-advantage-75311
09/11/2023, 1:53 PMvictorious-keyboard-86089
09/11/2023, 2:03 PMvictorious-keyboard-86089
09/11/2023, 3:27 PMWARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))’
victorious-keyboard-86089
09/11/2023, 3:28 PMenough-analyst-54434
09/12/2023, 1:19 PM"git"
or "ref"
lock keys here: https://github.com/pantsbuild/pants/blob/b625f09342aadd96a2882a32acce97d285034d64/src/python/pants/backend/python/macros/pipenv_requirements.py#L71-L88
So this is a bug in Pants Pipfile.lock handling @victorious-keyboard-86089.victorious-keyboard-86089
09/12/2023, 1:30 PMpython_requirement
to BUILD
as follows:
python_requirement(
name="package",
requirements=["package@ git+<https://env>(GITHUB_TOKEN)@github.com/git_org/package@package-1.0"],
dependencies=[":root#protobuf"],
)
This too kept failing after hitting max retries. I figured that it is not able to get the git url with the correct token for some reason. But I cannot really add the token directly anywhere and have to pass it as an environment variable.
How do you suggest I go about this?
Unfortunately, we are currently not allowed to use git+ssh
urls, which we were using previously and was working.victorious-keyboard-86089
09/12/2023, 1:32 PMvictorious-keyboard-86089
09/12/2023, 1:42 PMenough-analyst-54434
09/12/2023, 1:47 PMenough-analyst-54434
09/12/2023, 1:47 PMvictorious-keyboard-86089
09/12/2023, 1:51 PMpip install package@ git+https://$GITHUB_TOKEN@github.com/git_org/package@package-1.0
enough-analyst-54434
09/12/2023, 1:56 PMenv(...)
function is interpolated in strings by Pants: https://www.pantsbuild.org/docs/targets#environment-variables
Have you tried an f-string?victorious-keyboard-86089
09/12/2023, 1:59 PMenough-analyst-54434
09/12/2023, 1:59 PMvictorious-keyboard-86089
09/12/2023, 2:01 PMenough-analyst-54434
09/12/2023, 2:02 PMenough-analyst-54434
09/12/2023, 2:21 PM$ENV_VAR
in requirement strings just like Pip. As long as Pants doesn't get in the way, you should just be able to use that + subprocess_environment instead of the env function.victorious-keyboard-86089
09/12/2023, 2:26 PMpants generate-lockfile
and have all dependencies in a requirements file and ditch pipenv?enough-analyst-54434
09/12/2023, 2:30 PM$ENV
support is a bit orthogonal I think. For all I know, pipenv also supports env vars in (portions of) requirements.enough-analyst-54434
09/12/2023, 2:32 PMvictorious-keyboard-86089
09/12/2023, 2:38 PMFile "BUILD", line 12
requirements=["package@ git+<https://env>("GITHUB_TOKEN")@github.com/git_org/package@package-1.0"],
^
SyntaxError: invalid syntax
This is throwing syntax error nowlate-advantage-75311
09/12/2023, 2:39 PM\"GITHUB_TOKEN\"
enough-analyst-54434
09/12/2023, 2:44 PMvictorious-keyboard-86089
09/12/2023, 2:44 PMvictorious-keyboard-86089
09/12/2023, 2:45 PMdo you just need to escape it?Tried it, went back to\"GITHUB_TOKEN\"
ERROR: Could not find a version that satisfies the requirement package
ERROR: No matching distribution found for package
victorious-keyboard-86089
09/12/2023, 2:49 PMparse_pipenv_requirements
and supporting "git"
and related keys of Pipfile.lock? I can perhaps work on it, but only in a month or sovictorious-keyboard-86089
09/12/2023, 2:49 PMenough-analyst-54434
09/12/2023, 3:35 PMpython_requirements
target works with pip-style $ENV_VAR
(no use of env
function), then requirements.txt should also work just fine.enough-analyst-54434
09/12/2023, 3:36 PMvictorious-keyboard-86089
09/12/2023, 3:42 PM