Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn the user when distutils is present #2256

Merged
merged 1 commit into from
Jul 12, 2020

Conversation

jaraco
Copy link
Member

@jaraco jaraco commented Jul 12, 2020

Discourage this usage and direct users to the recommended usage. Closes #2230.

Pull Request Checklist

  • News fragment added in changelog.d. See documentation for details

…direct users to the recommended usage. Closes #2230.
@jaraco jaraco merged commit a494597 into master Jul 12, 2020
@jaraco jaraco deleted the bugfix/2230-warn-distutils-present branch July 12, 2020 15:51
warnings.warn(
"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.")
Copy link
Member

@webknjaz webknjaz Jul 12, 2020

Choose a reason for hiding this comment

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

@jaraco I'd use stacklevel=3 arg here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, I'm seeing the warning come from setuptools, not my own code:

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/distutils_patch.py:25: UserWarning: 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.

I'd actually need stacklevel=4 for it to point to my code:

setup.py:20: UserWarning: 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.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. I've probably miscalculated the nesting :)

webknjaz added a commit to ansible/pylibssh that referenced this pull request Jul 17, 2020
mitya57 added a commit to retext-project/retext that referenced this pull request Jan 19, 2021
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.

Unexpected behavior when distutils is invoked before Setuptools
3 participants