https://pantsbuild.org/ logo
b

bitter-ability-32190

10/20/2022, 8:02 PM
Is there a way to run
pex3 lock create
with the
-r
coming from
stdin
? Coming from
pip-compile
I can
cat requirements.txt | pip-compile -o out.txt -
āœ… 1
Oddly:
Copy code
-o PATH, --output PATH
                        A file to output the lock to; STDOUT by default or when `-` is specified.
but
pex3 lock create -o out.lock -
fails with
Copy code
Problem parsing '-' as a requirement: Parse error at "'-'": Expected W:(abcd...)
e

enough-analyst-54434

10/20/2022, 8:13 PM
That refers to
-o -
which you're not doing.
b

bitter-ability-32190

10/20/2022, 8:13 PM
šŸ¤¦ā€ā™‚ļø
e

enough-analyst-54434

10/20/2022, 8:14 PM
But, effectively no for the
-r
question.
This works to get requirements from stdout:
Copy code
pex3 lock create $(echo cowsay) -o - --indent 2
Using
-r <(...)
, however, is problematic.
b

bitter-ability-32190

10/20/2022, 8:17 PM
Bummer. I'm generating an additional lockfile with pytorch pinned to a CUDA version. In order to keep every other dep the same I'm
sed
-ding the version.
Le tme see if
$(sed ...)
like you suggest works
e

enough-analyst-54434

10/20/2022, 8:18 PM
You might save yourself some trouble and slap an echo in front of the whole thing to visually inspect.
b

bitter-ability-32190

10/20/2022, 8:20 PM
Ah no, the reqs file has hashes via
--hash
so no dice. Another file isn't going to kill me (use an intermediate
.txt
)
e

enough-analyst-54434

10/20/2022, 8:23 PM
Wait a sec.
pex3 lock update -p just_update_this ...
šŸ‘€ 1
But I'm not fully following "another lockfile" plus --hash
The lock update doesn't have an option to update to a new file, it mutates the one you give it if not --dry-run, but maybe what you want almost.
b

bitter-ability-32190

10/20/2022, 8:27 PM
cp
can fix that šŸ™‚
e

enough-analyst-54434

10/20/2022, 8:28 PM
Well, you weren't happy about doing effectively that with -r!
-p can be a full requirement string if that's not clear.
b

bitter-ability-32190

10/20/2022, 8:29 PM
I assumed as much
This
cp
is better because right now we have: • `pip-compile`:
<http://requirements.in|requirements.in>
->
requirements.txt
•
pex3
:
requirements.txt
->
requirements.lock
This is because people still are using
requirements.txt
as an out-of-band lockfile and I want them to agree 100%
e

enough-analyst-54434

10/20/2022, 8:30 PM
Gotcha
You can then use pex3 lock export on the new lockfile you're generating with cp + lock update if you need that canonical form back again.
b

bitter-ability-32190

10/20/2022, 8:32 PM
Yup!
works like a charm ā¤ļø
3 Views