I'm wondering what solution(s) folks have arrived ...
# general
b
I'm wondering what solution(s) folks have arrived at for needing to run a
pex_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?
h
Good question! Generally, I believe
./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 properly
c
Following this. We currently run
makemigrations
in a super hacky way.
h
./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.
A possible general-purpose solution is to optionally allow
./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.
h
A 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 example
c
@happy-kitchen-89482 would it be possible to have
run
discover newly created files in the tempdir and copy them back into the source tree? Right now we basically do that manually.
🤔 1
h
Hm, relevant: the tempdir approach already fails pretty badly with opening up loose files: https://github.com/pantsbuild/pants/issues/11109