Page MenuHomePhabricator

[libc++][test] Replace platform.linux_distribution by distro.linux_distribution
Needs RevisionPublic

Authored by aaronpuchert on Dec 3 2019, 3:59 PM.

Details

Summary

Since Python 3.5, platform.linux_distribution is deprecated [1], and in
Python 3.8 it has been removed entirely. The supposed replacement is
from the package distro. Unfortunately this adds another dependency to
the tests, but only on Linux (I think).

[1] https://docs.python.org/3.5/library/platform.html#platform.linux_distribution

Event Timeline

aaronpuchert created this revision.Dec 3 2019, 3:59 PM

An alternative would be to assume that any distribution new enough to have Python 3.8 also has /etc/os-release, so we fall back to parsing that if platform.linux_distribution isn't there. Or the other way around: we check for /etc/os-release and fall back to platform.linux_distribution.

ldionne requested changes to this revision.Dec 10 2019, 1:40 PM

Is import distro supported in Python 2.x?

This revision now requires changes to proceed.Dec 10 2019, 1:40 PM

Is import distro supported in Python 2.x?

It is supported on 2.7, see https://pypi.org/project/distro/.

An alternative to this change would be to assume that distributions recent enough to have Python 3.8 also have /etc/os-release, which has become somewhat of a standard. So we could check if that file exists, then use it if it does and fallback to platform.linux_distribution() if it doesn't. Then we wouldn't need an additional dependency.