Hey Pants Team, we are upgrading to 2.20.1 and cam...
# general
r
Hey Pants Team, we are upgrading to 2.20.1 and came across a something during the upgrade with dependencies around django. We are getting
pants.backend.python.dependency_inference.rules.UnownedDependencyError
for libs like
django-mongoengine
. To fix it I have to add it as a module mapping. So far I have
Copy code
"django-mongoengine": ("django_mongoengine",),
        "django-otp": ("django_otp",),
but this is happening for all django thridparty dependencies. Any reason this is happening on the new version where it did not happen in previous ones?
c
what are you upgrading from? we shouldn't have changed that part of the module-mappings, and there should be a case to map django modules
r
this is 2.18.3 -> 2.20.1
c
probably https://github.com/pantsbuild/pants/commit/a8a96d489934701dab5cb7322f063776e390ef95 , which landed in 2.19 . The logic assumes that
django-my-module
maps to
my_module
, not
django_my_module
. Seems that pattern was used by all the Django modules we had listed. In hindsight, ofcourse we only had the exceptions that were not mapped by the simple
.lower().replace("-", "_")
. Since simple packages like "django-otp" match the regex, we attempt the mapping as just
otp
.
👍 1
I'm not familiar with the Django ecosystem, do you know how common each form is? if it's just a few modules we can add them explicitly; if it's more common we can add the simple mapper when computing default mappings.
r
yeah it's pretty inconsistent for django packages, for example here's our module mappings
Copy code
"django-mongoengine": ("django_mongoengine",),
        "django-otp": ("django_otp",),
        "django-model-changes": ("django_model_changes",),
        "django-rest-framework-mongoengine": ("rest_framework_mongoengine",),
        "django-oauth-toolkit": ("oauth2_provider",),
        "django-storages": ("storages",),
        "django-ipware": ("ipware",),
        "django-log-request-id": ("log_request_id",),
        "django-phonenumber-field": ("phonenumbers",),
the ones for
Copy code
"django-mongoengine": ("django_mongoengine",),
        "django-otp": ("django_otp",),
        "django-model-changes": ("django_model_changes",),
were added during our recent version upgrade. It would be sufficient to map them under the condition
.lower().replace("-", "_")