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

abundant-analyst-12845

01/11/2023, 8:47 AM
Hi again, am trying to introduce pants slowly to an existing project and have set up separate folder structure to help with moving of the files over. have set up a basic hello world file and test but getting the following error when I run
./pants test ::
Copy code
./pants test ::  
08:44:38.18 [WARN] Failed to generate JUnit XML data for lambdas/hello_world/tests/test_hello_world.py.
08:44:38.18 [ERROR] Completed: Run Pytest - lambdas/hello_world/tests/test_hello_world.py failed (exit code 4).
ERROR: usage: pex [options] [file_or_dir] [file_or_dir] [...]
pex: error: unrecognized arguments: --report-skipped=
  inifile: /tmp/pants-sandbox-q5Tr08/tox.ini
  rootdir: /tmp/pants-sandbox-q5Tr08
here is my pants.toml file
Copy code
[GLOBAL]
pants_version = "2.14.0"
backend_packages.add = [
    "pants.backend.python",
#    "pants.backend.awslambda.python",
#    "pants.backend.python.lint.docformatter",
#    "pants.backend.python.lint.black",
    #    "pants.backend.python.lint.flake8",
#    "pants.backend.python.lint.isort",
#    "pants.backend.python.typecheck.mypy",
]


[anonymous-telemetry]
enabled = false

[source]
root_patterns = [
    "/lambdas/hello_world"
]

[python]
interpreter_constraints = ["==3.9.*"]
enable_resolves = true
default_resolve = "common"

[python.resolves]
common = "3rdparty/python/common.lock"

[tailor]
ignore_paths = [
    "backend/**",
    "bootstrap/**",
    "scripts/**",
    "terraform/**",
]
image.png
r

refined-addition-53644

01/11/2023, 9:09 AM
Could you try
ignore_path.add
instead of just
ignore_path
.
Also first try running the
./pants test <path-to-some-test-file>
Sorry it’s not
ignore_paths.add
but inside [GLOBAL] add
pants_ignore.add
to completely ignore any pants related activity https://www.pantsbuild.org/docs/reference-global#pants_ignore
a

abundant-analyst-12845

01/11/2023, 9:17 AM
sorry I don't follow
r

refined-addition-53644

01/11/2023, 9:19 AM
Copy code
[GLOBAL]
pants_ignore.add = [    
    "backend/**",
    "bootstrap/**",
    "scripts/**",
    "terraform/**",]
I am just trying to check if with
::
pants isn’t running things where it’s not supposed to yet.
a

abundant-analyst-12845

01/11/2023, 9:23 AM
so I added
Copy code
pants_ignore.add = [
    "/tox.ini"
]
I think the link in question was this
Copy code
x: error: unrecognized arguments: --report-skipped=
  inifile: /tmp/pants-sandbox-q5Tr08/tox.ini
which is an empty tox.ini at the root of the project
r

refined-addition-53644

01/11/2023, 9:24 AM
yeah pants is reading some weird things here. That’s I would run just the single test file and see if that’s working or not.
Copy code
./pants test <single_test_file_path>
a

abundant-analyst-12845

01/11/2023, 9:24 AM
are you suggesting to use pants_ignore.add instead fo the tailor ignore part
ok let me try it
running the single file still generates the same error
😞 1
I think it may be related to the fact that I got a
tox.ini
file at the root of the project. which is being picked up by pants
if i add this to pants.toml
Copy code
pants_ignore.add = [
    "/tox.ini"
]
it seems to be working
is there something I should know about tox.ini in relation to pants test?
r

refined-addition-53644

01/11/2023, 9:29 AM
I don’t know actually. But the way we moved things to pants was adding everything to
pants_ignore.add
and then slowly removing things where we wanted pants to run. pants_ignore.add is like superset of tailor ignore. With tailor ignore, pants doesn’t check for any tailor specific things but might pick up things like you are experiencing. My understanding is also bit shaky though.
a

abundant-analyst-12845

01/11/2023, 9:32 AM
ok for now this is what my pants.toml looks like
Copy code
[GLOBAL]
pants_version = "2.14.0"
backend_packages.add = [
    "pants.backend.python",
#    "pants.backend.awslambda.python",
#    "pants.backend.python.lint.docformatter",
#    "pants.backend.python.lint.black",
    #    "pants.backend.python.lint.flake8",
#    "pants.backend.python.lint.isort",
#    "pants.backend.python.typecheck.mypy",
]
pants_ignore.add = [
    "/tox.ini",
    "backend/**",
    "bootstrap/**",
    "scripts/**",
    "terraform/**",
]


[anonymous-telemetry]
enabled = false

[source]
root_patterns = [
    "/lambdas/hello_world"
]

[python]
interpreter_constraints = ["==3.9.*"]
enable_resolves = true
default_resolve = "common"

[python.resolves]
common = "3rdparty/python/common.lock"

[tailor]
ignore_paths = [
    "backend/**",
    "bootstrap/**",
    "scripts/**",
    "terraform/**",
]
r

refined-addition-53644

01/11/2023, 9:35 AM
You don’t need the tailor ignore for now if the same path has been already added to GLOBAL pants_ignore. But it doesn’t matter. It’s just redundant.
a

abundant-analyst-12845

01/11/2023, 9:37 AM
ok so if I remove it it and run ./pants tailor :: it won't generate pants related files in those folders?
r

refined-addition-53644

01/11/2023, 9:38 AM
That's right that it won't generate any pants BUILD files! pants_ignore is basically telling pants to not even look inside these directory or consider any file.
Remove the glob (**) and just use
Copy code
pants_ignore.add = [
    "/tox.ini",
    "backend/",
    "bootstrap/",
    "scripts/",
    "terraform/",
]
1
a

abundant-analyst-12845

01/11/2023, 12:28 PM
that seems to have done the trick
🙌 1
am still confused why the empty
tox.ini
file generated that error
we have tox.ini files in some of the folders that are now ignored and would be introducing them again as we migrate everything over
r

refined-addition-53644

01/11/2023, 12:30 PM
yeah that’s a good question. I don’t have any idea