https://pantsbuild.org/ logo
#general
Title
# general
h

helpful-lunch-92084

11/24/2020, 3:40 PM
hey, i just ran into an issue running a django shell via pants run, got:
Copy code
os.write(self.fileno, b'\x1b[?1l')
OSError: [Errno 9] Bad file descriptor

If you suspect this is an IPython bug, please report it at:
    <https://github.com/ipython/ipython/issues>
or send an email to the mailing list at <mailto:ipython-dev@python.org|ipython-dev@python.org>
@jolly-midnight-72759 told me to pass
--no-pantsd
to avoid this and pointed me to the ticket here: https://github.com/pantsbuild/pants/issues/9939 just thought i’d mention that this happens on a pants run and not just a pants repl. but it makes sense since it’s a general issue relating to ttys and pantsd it seems
h

hundreds-father-404

11/24/2020, 3:49 PM
Oh hm, it’s happening even without pantsd? What pants version is this on? Thanks for reporting this
h

helpful-lunch-92084

11/24/2020, 3:50 PM
no,
--no-pantsd
workaround works
h

hundreds-father-404

11/24/2020, 3:52 PM
Oh I see, you’re saying that this issue also impacts
./pants run
if it’s a Django shell
h

helpful-lunch-92084

11/24/2020, 3:52 PM
yah
h

hundreds-father-404

11/24/2020, 3:53 PM
That makes sense, but yeah this is a major issue and common gotcha. Stu has been porting some of our exception handling and Pantsd code to rust, and I’m hoping that will make this issue easier to fix Thanks for reporting it!
👍 1
h

happy-kitchen-89482

11/24/2020, 4:46 PM
BTW I've been meaning to write a "best practices for using Pants with Django" doc, so if you have any good tips on that, would love to hear them! So far the greatest difficulty seems to be getting
manage.py runserver
to work, afaict you have to use
--noreload
(which is OK since autoreloading won't work anyway right now, since the code
pants run
actually runs is a copy of the code from your repo, so it won't see your edits until you rerun pants). We're looking into using Pants's own autoreload ability (pantsd watches the filesystem) for this.
💯 1
h

helpful-lunch-92084

11/24/2020, 6:24 PM
yah, we sort of hacked around that noreload stuff by modifying PYTHONPATH but it is something we would like to see natively supported in pants
i think we sidestepped the manage.py constraint by creating a target with an entrypoint ala
Copy code
430 pex_binary(
431     name="django-admin",
432     entry_point="django.core.management:execute_from_command_line",
433     dependencies=[
and then we have a wrapper script that does this to be able to run
./bin/djangofly-manage shell
Copy code
# TODO: Enable pantsd after bug is squashed: <https://github.com/pantsbuild/pants/issues/9939>
(cd $BUILDROOT && ./pants --no-pantsd run //:django-admin -- $cmd --pythonpath=$BUILDROOT $@)
i wouldn’t say it’s best practice, but it works for us
6 Views