fresh-cat-90827
04/17/2024, 12:24 PMfresh-cat-90827
04/17/2024, 12:24 PM$ pants list ::
//:_python-default_lockfile
//:reqs
//:reqs#ansicolors
//:reqs#pytest
//:reqs#setuptools
//:reqs#types-setuptools
//python-default.lock:_python-default_lockfile
//requirements.txt:reqs
helloworld:lib
helloworld:pex_binary
helloworld/__init__.py:lib
helloworld/main.py:lib
helloworld/greet:lib
helloworld/greet:tests
helloworld/greet:translations
helloworld/greet/__init__.py:lib
helloworld/greet/greeting.py:lib
helloworld/greet/greeting_test.py:tests
helloworld/translator:dist
helloworld/translator:lib
helloworld/translator:tests
helloworld/translator/__init__.py:lib
helloworld/translator/translator.py:lib
helloworld/translator/translator_test.py:tests
say I want to exclude helloworld/greet:lib as if it doesn't exist at all:
-python_sources(
- name="lib",
- dependencies=[":translations"],
-)
now if I run the test goal I do get an error since the python_sources do not exist any longer:
$ pants test helloworld/greet
13:22:30.32 [ERROR] Completed: Run Pytest - helloworld/greet/greeting_test.py:tests - failed (exit code 2).
...
Traceback:
/usr/lib64/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
helloworld/greet/greeting_test.py:4: in <module>
from helloworld.greet.greeting import Greeter
E ModuleNotFoundError: No module named 'helloworld.greet.greeting'
- generated xml file: /tmp/pants-sandbox-6oBsCG/helloworld.greet.greeting_test.py.tests.xml -
=========================== short test summary info ============================
ERROR helloworld/greet/greeting_test.py
โ helloworld/greet/greeting_test.py:tests failed in 0.29s.
Is there a way to exclude a build target like this without commenting it out in the BUILD file? ๐
Using --tags would work when selecting targets, same with `--filter`; here I want to exclude it from the dependency graph as if it didn't exist at all.fresh-cat-90827
04/17/2024, 12:29 PMpants --pants-ignore="+['helloworld/greet/greeting.py']" test helloworld/greetfresh-cat-90827
04/17/2024, 12:31 PMpants --exclude="+['helloworld/greet:lib']" test helloworld/greetfresh-cat-90827
04/17/2024, 12:34 PM--pants-ignore="+['helloworld/greet/greeting.py']" won't work if there's a python_source build target with the exact path:
python_source(name="foo", source="helloworld/greet/greeting.py")
as Pants correctly complains about InvalidFieldException - a build target with the source must point to an existing file on diskcurved-television-6568
04/17/2024, 1:07 PM!!helloworld/greet:lib (on the dependencies field) ought to exclude it from being part of the distribution..fresh-cat-90827
04/17/2024, 8:02 PMcurved-television-6568
04/18/2024, 6:47 AMBUILD.ephemeral file (or something else if it needs to not hit the default pattern of BUILD.*), then tweak the https://www.pantsbuild.org/2.19/reference/global-options#build_patterns to include/exclude this file as needed.curved-television-6568
04/18/2024, 6:48 AMfresh-cat-90827
04/18/2024, 4:35 PMfresh-cat-90827
04/18/2024, 4:35 PMfresh-cat-90827
04/18/2024, 4:38 PM