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

abundant-finland-56154

05/07/2021, 2:55 AM
Is there a way to use multiple pants.toml's? Let's say, for example, I have
/pants.toml
,
/src/python/project_a
,
/src/python/project_b
. What I'd like to do is have different configurations for those projects for various tools, and ideally a "fallback" default. From what I can tell a single toml file must specify all of the config paths for various tools, based on
Config files must be explicitly declared
in the docs - so I was wondering if instead it might make sense to just use multiple tomls instead?
h

hundreds-father-404

05/07/2021, 3:21 AM
It is possible to have multiple config files, indeed, eg https://www.pantsbuild.org/docs/using-pants-in-ci#pantscitoml-optional But note that you have to either use the arg --pants-config-files or env var PANTS_CONFIG_FILES to say which you want. It's not possible to have part of the project automatically use one config and another part of the project use another config
Oh the "config files must be explicitly specified" is talking about something else, that is config files for tools Pants runs, rather than Pants itself. Eg .flake8 or mypy.ini. And that warning is also now out of date for Pants 2.5, which got a new feature to discover tool config files for you :)
a

abundant-finland-56154

05/07/2021, 3:24 AM
😮
Where can I read about that? I'm basically after a solution to having projects use different pytest.ini configs
h

hundreds-father-404

05/07/2021, 3:29 AM
It is not yet documented beyond the help system, I still need to update docs. But you can use 2.5.0rc0 and run
./pants help-advanced pytest
for example :) Note that all Pants is doing is detecting the relevant config files and then putting them in the chroot. It's then up to Pytest to do with that what it wants - for Pytest, config files must be in a parent directory of your tests and can't be in an unrelated folder, for example. That sounds consistent with what you're hoping for though. Because Pants runs each test file as a separate process, you can have dirA/pytest.ini and dirB/pytest.ini and be sure that Pytest is using the appropriate config files when running
./pants test ::
:)
See this tip to verify the correct config files are being included in each test process: https://www.pantsbuild.org/v2.5/docs/troubleshooting#debug-tip-inspect-the-chroot-with---no-process-execution-local-cleanup
a

abundant-finland-56154

05/07/2021, 3:40 AM
👍 Yeah this sounds solid, thanks
❤️ 1
5 Views