This is an archive of the discontinued LLVM Phabricator instance.

[libc++][test] Replace platform.linux_distribution by distro.linux_distribution
AbandonedPublic

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.

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.

@ldionne, what do you think about this ^^?

I'm not really happy about the additional dependency myself and have actually just removed the code in openSUSE to unblock the Python 3.8 update, because we have no blacklisted tests. That's not upstreamable of course.

But checking for /etc/os-release and falling back to platform.linux_distribution() seems like it could solve the problem.

Do we have a list of dependencies required for running the tests? If so, it might not be unreasonable to add distro. If not, or if that list is empty (i.e. we only need a base Python installation), then I think adding a new dependency has a higher bar and I would go for your other solution.

On openSUSE we're running the llvm, clang, and libc++ test suite with just python3-base as dependency. This doesn't include the distro package, so it would be the first dependency outside of the Python standard library.

On openSUSE we're running the llvm, clang, and libc++ test suite with just python3-base as dependency. This doesn't include the distro package, so it would be the first dependency outside of the Python standard library.

In that case, I suggest we avoid adding an additional dependency.

aaronpuchert abandoned this revision.Mar 4 2020, 4:24 PM

Already solved via D72501, not as I proposed, but it should be fine.