Hi I'm trying to run a Django database management...
# general
f
Hi I'm trying to run a Django database management command (specifically,
make_migration
) in a Pants repository. I need to do this outside of the sandbox, since they generate some new files for the codebase. Looking at #12129 and previous discussions, it seems people were working on adding a
run_in_sandbox
flag to
pex_binary
, but it got reverted in #15849. What would be the recommended way to do this now?
s
A replacement flag was added to the
python_source
target
r
According to this excellent article:
At this point we need to run
makemigrations
. Unfortunately there isn’t a great path for this on Pants as of writing. What I found worked best was the following.
Copy code
./pants run src:manage -- makemigrations --dry-run --verbosity 3 polls
This command prints the proposed migration files to stdout. You then need to write this output to
src/polls/migrations/0001_initial.py
.
b
Yup! Everything whose
source
is a Python file is now automatically runnable (albeit in a sandbox). Then you can either set the `run_goal_use_sandbox`flag on the target or the
[python].default_run_goal_use_sandbox
to change the entire repo. Setting it to false runs the source in your repo tree directly. Eventually this will be the default behavior
r
If I understand correctly, this flag is only available from version 2.13?
f
Thank you for the replies, temporarily setting
default_run_goal_use_sandbox
to false seems to work, albeit as a workaround. If I can set the flag in
./pants run
, that would be great! E.g.,
./pants run --run_in_sandbox=false
.
b
@rhythmic-glass-66959 yup
@fierce-keyboard-91032 all options are also flags!
./pants --no-python-default-run-in-sandbox
❤️ 1
👀 1