https://pantsbuild.org/ logo
l

loud-laptop-17949

11/23/2021, 11:06 PM
I am trying to figure out how to port our django translations generation code to a pants-based build system. I assume the way I would need to do this is a codegen plugin? Is there a more straightforward way?
h

happy-kitchen-89482

11/24/2021, 12:20 AM
cc @clean-city-64472 who probably has thoughts/ideas here
How does it work now? Does it run
manage.py
?
l

loud-laptop-17949

11/24/2021, 12:23 AM
yeah manage.py
c

clean-city-64472

11/24/2021, 12:23 AM
I think we run compilemessages on the server during deploy. Makemessages is like migrations. Haven't looked at it in a long time so not super helpful here and I don't think our solution was very elegant in the end.
l

loud-laptop-17949

11/24/2021, 12:23 AM
yeah my challenge right now is that I need makemessages to run before tests run
(I think)
c

clean-city-64472

11/24/2021, 12:25 AM
I think we might have a pytest fixture that runs it
👍 1
Will check when I'm on my laptop
l

loud-laptop-17949

11/24/2021, 12:27 AM
ah interesting
h

happy-kitchen-89482

11/24/2021, 12:36 AM
The issue with makemigrations is that it writes the migration files relative to the models source files, which means if you run
./pants run path/to/manage.py makemigrations
it writes them in the sandbox, and not the source tree. I imagine something similar might happen for makemessages.
So it might be time for a django-aware plugin that can handle this
2
c

clean-city-64472

11/24/2021, 1:36 AM
Copy code
import pytest

from django.core.management import call_command


@pytest.fixture(scope="session")
def translations():
    call_command("makemessages", "--all")
    call_command("compilemessages")
@loud-laptop-17949
👍 1
🎉 1
2 Views