big-fall-51153
05/20/2021, 1:48 PMpex_binary
against the source code and modify the filesystem in-place. Specifically, I need to be able to run django
management commands like ./pants run manage.py -- makemigrations
that writes out migrations files. I'm thinking the answer is that if I need to run side-effecting code like that that i need to do it via a pants plugin like other codegen tools?hundreds-father-404
05/20/2021, 1:52 PM./pants run
should work for mutating the build root - we do that in pantsbuild/pants, e.g. our generate_github_workflows.py
script
But for the sake of Django itself, @happy-kitchen-89482 has been working on creating an example Django repo and he is recommending running manage.py
directly, at least for now. I don't yet totally understand why he came to this recommendation, but see https://github.com/pantsbuild/example-django/pull/2#discussion_r635578267 and I think a script to ensure things work properlyclean-city-64472
05/20/2021, 1:53 PMmakemigrations
in a super hacky way.happy-kitchen-89482
05/20/2021, 2:14 PM./pants run
runs in a tmpdir under the chroot containing a copy of the relevant code. So makemigrations
will create the migrations files under the tmpdir, which is not helpful... ./pants run
is allowed to mutate the repo, it's just that it can't do it in the right place../pants run
to run against your actual sources. It breaks hermeticity, but for`./pants run` that is probably fine. It would allow runserver
to work as well.hundreds-father-404
05/20/2021, 2:17 PMA possible general-purpose solution is to optionally allow ./pants run to run against your actual sources.The major complication I see there is codegen (including
relocated_files
) - we don't want to put those files in the actual build root.
How was this achieved in v1? My first thought was "set the PYTHONPATH appropriately", but that doesn't work with relocated_files
for exampleclean-city-64472
05/20/2021, 2:22 PMrun
discover newly created files in the tempdir and copy them back into the source tree? Right now we basically do that manually.hundreds-father-404
05/20/2021, 2:31 PM