Skip to content

Conversation

@xadupre
Copy link
Member

@xadupre xadupre commented Jan 3, 2023

Description

Uses setuptools instead of distutils.

Motivation and Context

Fixes #14107.

@xadupre xadupre requested a review from thiagocrepaldi January 3, 2023 19:06
setup.py Outdated
import platform
import subprocess
import sys
from distutils import log as logger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as said in the warning "make sure that setuptools is always imported before distutils." do we need update this distutils on line 10 as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into setuptools code to see how to replace it. I found setuptools is also using distutils log: https://github.com/pypa/setuptools/blob/main/setuptools/logging.py#L4. I moved distutils import.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since distutils is going to disappear, I replaced the logger by its implementation I found here: https://github.com/pypa/distutils/blob/main/distutils/_log.py.

@chengchen666
Copy link
Contributor

I applied this change, but warning still exists. This change can only fix the warning when run setup.py, but the real warning caused by import onnxruntime is not from here. I digged a bit further, the warning might come from /usr/local/lib64/python3/dist-packages/onnxruntime/capi/training/__init__.py in my environment.

@xadupre
Copy link
Member Author

xadupre commented Jan 4, 2023

distutils was used to compare version. I replaced it with packaging. setup.py import distutils to log. The warning should disappear.


try:
from packaging.version import Version as LooseVersion
except ImportError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why we need this try catch?

pengwa
pengwa previously approved these changes Jan 4, 2023
@chengchen666
Copy link
Contributor

I applied all you changes in my environment, now the warning is gone. Thank you so much for your help. @xadupre

@xadupre xadupre merged commit 79dc396 into microsoft:main Jan 9, 2023
@xadupre xadupre deleted the setuptools branch January 13, 2023 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Training] UserWarning casued from Setuptools

3 participants