Opened 4 years ago

Closed 4 years ago

#31808 closed Uncategorized (invalid)

Django causes latest setuptools to issue "UserWarning: Distutils was imported before Setuptools."

Reported by: Luc Saffre Owned by: nobody
Component: Core (Other) Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The latest change in setuptools 49.2 (released 2020-07-12, https://setuptools.readthedocs.io/en/latest/history.html) "now warns the user when setuptools is imported after distutils modules have been loaded (exempting PyPy for 3.6), directing the users of packages to import setuptools first."
That warning is a problem for me because it causes our doctests to fail. I might of course filter it out, but the proper solution would be to do what the warning asks. I don't import distutils myself. Is it possible that Django itself is misbehaving? Has anybody seen this warning as well?

Change History (3)

comment:1 by Luc Saffre, 4 years ago

Here is how to filter the warning:

import warnings
warnings.filterwarnings(
    "ignore", "Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.",  UserWarning, "setuptools.distutils_patch")

But that code must run before importing django in every manage.py file, so it is not easy to disable in my test suite. Another workaround is to install "setuptools<49.2".

comment:2 by Luc Saffre, 4 years ago

The problem does not occur in a virgin new django project, so the culprit might be some of the apps I use. I will report here if I find more relevant information.

comment:3 by Mariusz Felisiak, 4 years ago

Component: UncategorizedCore (Other)
Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top