We have a repo with - A folder with a Django proj...
# general
p
We have a repo with • A folder with a Django project • Other folders with flask/fastAPI projects And a top-level pants.toml which we are trying to incrementally adopt. We got really far with the flask ones which are small but the Django app is large and has lots of quirks that make pytest fail when using pants but succeed otherwise. Is there a way to instruct a top level BUILD file in that Django folder so that it still treats it as a monolith and runs all tests in a single bang instead of trying to split them into different pex files by their dependencies? We would like to adopt pants, have it run our pytest tests and incrementally decouple the code inside that monolith.
c
you should be able to do that by setting the
sources
field to include a recursive glob, and then add a manual dependency. something like
Copy code
python_sources(
  name="django_sources",
  sources=["django/**/*.py", "!django/**/*_test.py"],
)

python_tests(
  name="django_tests",
  sources=["django/**/*_test.py"],
  dependencies=[":django_sources"],
)
for example, given these files
pants list ::
Copy code
//django/s0.py
//django/s1.py
//django/t0_test.py
//django/t1_test.py
the dependencies show like
pants dependencies django/t0_test.py
Copy code
//django/s0.py:../django_sources
//django/s1.py:../django_sources
p
I started something like that but not recursive, adding the application module as a dependency to tests. I will keep trying, I think this is crucial for easily adopting pants as soon as possible, later decoupling. Thanks!
👍 1