Remind me, <@UHVF9QEPP>, when we run Django's make...
# general
h
Remind me, @polite-garden-50641, when we run Django's makemigrations command internally, we don't do it via
./pants run
, right?
Because then the migrations would end up in the tmpdir, not the real source tree?
b
p
yup. we don't. However, I think it will work, we do use
./pants run
since when the pex file runs it is like running a python script (the only process that runs in isolation is the pex build) once the code runs it is not isolated and it has access to the local file system whatever the cwd is. I don't use it since it is faster for me to just use the underlying VE which I already have rather than wait for pants to build the pex file and run it.
but I just checked, running makemigrations using pants run works just fine.
b
and it has access to the local file system whatever the cwd is.
How does Django know to ouput relative to CWD, then and not the caller's
__file__
which will be in the tempdir? This seems like shouldn't work, so thats surprising
p
the way I see it, and I might be wrong, doing
./pants run
is just like doing
./pants package
and then just running the pex file (
./dist/my_script.pex
)
b
Spiritually, that is true. However the point stands that in your Python code doing
__file__
will not give you the sandbox path, which isn't relative to CWD (at least not in a meaningful way). So I'm not sure how Django can remedy that fact in a meaningful way. I guess, what's the full command/code look like? Maybe I'm missing something?
p
Screen Shot 2022-05-26 at 10.22.51 AM.png
šŸ¤·ā€ā™‚ļø
b
Ah, yeah specifically the issue here is if it did need to make changes. It wouldn't write them to the repo. Try making a DB change and running the command
(or whatever triggers Django to make a migration script, it's been a while since I've done Django)
p
naa..it works...
ahh.. u are right... it doesn't...
b
....doens't that screenshot show it doesnt work? The migrations file is not in repo. It's in the tempdir
p
look where it wrote the migration script... ok. I stand corrected.
šŸ¤¦ā€ā™‚ļø
b
So the good news is I'm not taking crazy pills (I mean, I suppose I could be, we just can't prove it here). The bad news is we still can't codegenerate files easily in Pants šŸ˜›
I think @happy-kitchen-89482ā€™s question though was how y'all do it internally in the Toolchain codebase because of this issue
p
yes. so as I mentioned, I used our virtualenv since it is faster... I am very impatient and won't wait for computers... I also find the fastest way to do things for my workflow...
b
Generally speaking. I think if users are reaching outside of Pants (especially into a virtualenv) it's a signal we're doing something wrong.
p
I agree.. pants can do many things better and faster.
and the team knows about it... I keep letting them know every so often.
šŸ™Œ 1
b
Good šŸ˜ˆ
p
case in point (pants run not using a cached pex) https://github.com/pantsbuild/pants/issues/10513
h
Yeah, OK, so no crazy pills, and no workaround, so we probably want to do that ticket
b
Your latest comment is 100% valid though, and I expect to see that as a stumbling block. Not sure if there's a way to "win" here šŸ˜•