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

incalculable-hydrogen-44003

09/20/2022, 5:54 PM
Hi guys. we are on week 4 of trying to get our Django app to working pants. We are now trying to figure out how to get local development to work. At the moment, none of the
admin.py
files are getting pulled in (as well as other magic dependencies). Does anybody have any tips on how to solve this?
s

sparse-lifeguard-95737

09/20/2022, 6:20 PM
you’ll have to manually mark dependencies for all the “magic” files so Pants knows to include them in the various sandboxes. in our repo we wrote a macro that creates dependencies from
apps.py
to
admin.py
etc.
as part of ^^^ we internally enforce that each app has an
apps.py
and that our
INSTALLED_APPS
settings refer to the fully-qualified
AppConfig
subclasses within each of those files, so dependency inference can find them. if you use the short-hand references for
INSTALLED_APPS
then Pants won’t know to pull in the
apps.py
files
i

incalculable-hydrogen-44003

09/20/2022, 6:33 PM
Thanks Dan. I took a look at your macro, how are you guys including
/admin
folders?
s

sparse-lifeguard-95737

09/20/2022, 6:38 PM
we don’t have any of those at the moment - if it came up I’d handle it the ~same way as we handle
models.py
vs.
models/
i

incalculable-hydrogen-44003

09/20/2022, 6:56 PM
got it. thank you
h

happy-kitchen-89482

09/20/2022, 7:14 PM
Yeah, if there is no
import
, or at least a setting.py-style “string import” then you have to manually add the relevant deps, since there is nothing to infer them from
i

incalculable-hydrogen-44003

09/20/2022, 7:25 PM
yup. After manually adding each django app to dependencies, things seem to be working
(minus Jupiter notebooks which seems to throw a
psutil module not found
error even when we add it to the dependencies
s

sparse-lifeguard-95737

09/20/2022, 7:27 PM
@happy-kitchen-89482 even string imports don’t save you on this one - the magic is all tucked away inside of 3rd-party packages installed via Django settings 🤢
i

incalculable-hydrogen-44003

09/20/2022, 7:27 PM
yup. it is the worst
Migrating a large existing Django app isn't the easiest thing
1
s

sparse-lifeguard-95737

09/20/2022, 7:30 PM
I have been meaning to submit some PRs to the example django repo to make it a little more gnarly / realistic
❤️ 1
might prioritize that this week 🤔
i

incalculable-hydrogen-44003

09/20/2022, 7:31 PM
That would be amazing
h

happy-kitchen-89482

09/20/2022, 8:20 PM
A pants plugin for django that understood django layout and applied dep inference appropriately would be awesome
💯 2
h

hundreds-father-404

09/21/2022, 6:03 PM
agreed. I don't think we have a tracking issue for better first-class Django support, if anyone wants to open an issue -- it's fine to not know everything it should do yet. We can start adding new ideas to it
5 Views