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

wide-zoo-86070

03/15/2022, 2:27 PM
I am facing the following error while I am trying to run pants in a new repo. Any idea?
Copy code
pants.option.errors.ParseError: Error computing value for --requirement-constraints in scope 'python' (may also be from PANTS_* environment variables).
Caused by:
File value `constraints.txt` for option `requirement_constraints` in `scope 'python'` does not exist.
c

curved-television-6568

03/15/2022, 2:30 PM
Hi, The message indicates that you don’t have the
constraints.txt
file. You’ll have to create it yourself. I’m assuming you’re on 2.9.0, in which case this section is relevant for you: https://www.pantsbuild.org/docs/python-third-party-dependencies#lockfiles notably the phrase “To use a lockfile, first generate a
constraints.txt
file, such as by using one of these techniques” Let us know if this makes sense 🙂
h

hundreds-father-404

03/15/2022, 4:54 PM
Hi! Andreas I'm not sure that's it - if the file didn't exist, the error would be different saying that the file does not exist. This is saying the option is not legal @wide-zoo-86070 how are you setting this option? e.g. pants.toml?
c

curved-television-6568

03/15/2022, 5:23 PM
Oh! Riiight, that error message is having me confused. May I suggest rephrasing, so what is important is presented sooner. What the value was is secondary for invalid options.. ;)
1
w

wide-zoo-86070

03/15/2022, 7:04 PM
I definitely did not generate constraints.txt. I will try to do it and revert back. Btw, where is the benefit of using this constraints.txt.
c

curved-television-6568

03/15/2022, 7:13 PM
It is to pin your dependencies, so you know exactly which version is being used.
@hundreds-father-404 actually, I think I was right. The error says that the file does not exist. When the option doesn’t, it says:
Copy code
20:14:36.78 [ERROR] Invalid option 'arequirement_constraints' under [python] in /Users/aadt/src/github/kaos/pants/pants.toml
20:14:36.78 [ERROR] Invalid config entries detected. See log for details on which entries to update or remove.
...
pants.option.errors.ConfigValidationError: Invalid config entries detected. See log for details on which entries to update or remove.
(Specify --no-verify-config to disable this check.)
👀 1
h

hundreds-father-404

03/15/2022, 7:17 PM
Oh dang you're right. Good eye / apologies!
🙏 1
w

wide-zoo-86070

03/15/2022, 9:23 PM
I am wondering how pants handle multiple requirements.txt. Suppose below is the structure of the repo
Copy code
-project_A
   -requirements.txt
-project_B
   -requirements.txt
-env.yaml
-requirements.txt
The env.yaml will have something like below to use with conda
Copy code
- pip:
  - -r requirements.txt
  - -r project_A/requirements.txt
  - -r project_B/requirements.txt
How pants handle such cases? e.g. do i need to generate a single constraints.txt which includes all requirements.txt?
h

hundreds-father-404

03/15/2022, 9:25 PM
The story got a lot better in Pants 2.10, which is close to a stable release 🙂 https://pantsbuild.slack.com/archives/C046T6T9U/p1647295890676559
h

happy-kitchen-89482

03/15/2022, 9:53 PM
@wide-zoo-86070 you can have multiple lockfiles in 2.10, as Eric mentions, but the key point is that you don't have to. You can have a single global requirements.txt (and accompanying lockfile), and Pants will take just the necessary subset as needed.
👍 3
So you don't need to have separate requirements.txt for each project
Typically the reason to have a per-project requirements.txt file is so that your tooling knows what that project's exact requirements are . But Pants can compute this for you.
🙌 1
However you can also have multiple requirements.txt files, if you prefer, it's just a little more work to generate more lockfiles.
🙌 2
6 Views