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

Import setuptools at init #448

Closed
ahartikainen opened this issue Sep 9, 2020 · 4 comments
Closed

Import setuptools at init #448

ahartikainen opened this issue Sep 9, 2020 · 4 comments

Comments

@ahartikainen
Copy link
Contributor

Our package needs setuptools. And recently there have been warnings that setuptools should be imported before the distutils.

.../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.

Following our import path (from app.py) there is import for webargs, which imports distutils in their init.

https://github.com/marshmallow-code/webargs/blob/dev/src/webargs/__init__.py

To fix this issue, I suggest that we import setuptools at __init__.py and delete it after import

import setuptools
del setuptools

This procedure makes sure that our library will import setuptools first and then distutils. It is not foolproof, but at least works when used normally.

@riddell-stan
Copy link
Contributor

riddell-stan commented Sep 9, 2020 via email

@ahartikainen
Copy link
Contributor Author

Yeah, this hack is not nice.

They have this

from distutils.version import LooseVersion

also, this problem doesn't affect them, because they don't use setuptools (at runtime).

@riddell-stan
Copy link
Contributor

Perhaps webargs could be persuaded to switch to setuptools's distutils's LooseVersion.

Removing the dependency on webargs would be great though. Getting rid of marshmallow will take work. Getting rid of webargs might be much easier.

@riddell-stan
Copy link
Contributor

I suspect this is going to be resolved somehow. Lots of people are affected by this. See pypa/setuptools#2230

If it doesn't get resolved, let's open a new issue to remove the dependency on webargs.

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

No branches or pull requests

2 participants