Closed Bug 1766085 Opened 3 years ago Closed 2 years ago

check_binary.py triggers "DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives"

Categories

(Firefox Build System :: General, defect, P3)

defect

Tracking

(firefox102 fixed)

RESOLVED FIXED
102 Branch
Tracking Status
firefox102 --- fixed

People

(Reporter: dholbert, Assigned: RyanVM)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

When building Firefox with ./mach build, I now see some deprecation warnings about distutils in my output, like so (newlines added by me for readability):

 0:05.29 browser/app/firefox
 0:05.42 /scratch/work/builds/mozilla-central/mozilla/python/mozbuild/mozbuild/action/check_binary.py:13:
DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12.
Use setuptools or check PEP 632 for potential alternatives
 0:05.42   from distutils.version import StrictVersion as Version

[...]
 0:08.98 toolkit/library/build/libxul.so
 0:10.58     Finished dev [unoptimized + debuginfo] target(s) in 1.59s
 0:21.81 /scratch/work/builds/mozilla-central/mozilla/python/mozbuild/mozbuild/action/check_binary.py:13:
DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12.
Use setuptools or check PEP 632 for potential alternatives
 0:21.81   from distutils.version import StrictVersion as Version

It looks like we'll need to address this somehow before Python 3.12 is released, or else people with that version might run into trouble.

(I just updated to Ubuntu 22.04 which probably updated my python version as well; I'm guessing that's why I've just started to see this. python --version tells me that I've now got Python 3.10.4

Looks like the warning is pointing to this line:

from distutils.version import StrictVersion as Version

...which glandium added here in bug 1470127:
https://hg.mozilla.org/mozilla-central/rev/9f4d1a4296ba#l3.16

Tentatively tagging glandium for needinfo on suggested next-steps here.

Depends on: 1470127
Flags: needinfo?(mh+mozilla)

Note, the warning's "PEP 632" is a reference to https://peps.python.org/pep-0632/ which has some migration advice, including this note that might (?) be useful to us here:

distutils.version — use the packaging package

You should be able to use packaging directly from that script as it's already vendored.
See this patch for a solution to a similar problem in mozboot.

Priority: -- → P3

(In reply to Daniel Holbert [:dholbert] from comment #0)

It looks like we'll need to address this somehow before Python 3.12 is released, or else people with that version might run into trouble.

BTW: according to https://en.wikipedia.org/wiki/History_of_Python#Table_of_versions , Python 3.12 will be released in October 2023. So we've got a little while before this actually causes problems, but it'd be nice to fix the build-spew (and avoid issues with people using future affected development versions of Python) sooner than that.

Severity: -- → S3

I didn't change all the instances in-tree, but this cleans up a lot of them and fixes the warning reported in this bug. Green on Try:
https://treeherder.mozilla.org/jobs?repo=try&group_state=expanded&revision=420f26decd5bf9894ba1172ba14853a50e3cfc1b

Assignee: nobody → ryanvm
Status: NEW → ASSIGNED
Flags: needinfo?(mh+mozilla)
Pushed by rvandermeulen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cf1a478cc4eb Replace some uses of distutils.version with packaging.version. r=glandium
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch
Regressions: 1769735
Blocks: 1743785
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: