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

Fix setuptools's Python 2 deprecation warning with Python linters #9131

Merged

Conversation

Eric-Arellano
Copy link
Contributor

Setuptools 45.x is the last to support Python 2. It has an incredibly noisy stderr message to make sure users are aware of this:

/private/var/folders/sx/pdpbqz4x5cscn9hhfpbsbqvm0000gn/T/process-executionUnBXvi/pex_root/install/setuptools-45.2.0-py2-none-any.whl.91f9e7e571716e18411266133f3db5a0212dfa92/setuptools-45.2.0-py2-none-any.whl/pkg_resources/py2_warn.py:22: UserWarning: Setuptools will stop working on Python 2
************************************************************
You are running Setuptools on Python 2, which is no longer
supported and
>>> SETUPTOOLS WILL STOP WORKING <<<
in a subsequent release (no sooner than 2020-04-20).
Please ensure you are installing
Setuptools using pip 9.x or later or pin to `setuptools<45`
in your environment.
If you have done those things and are still encountering
this message, please comment in
https://github.com/pypa/setuptools/issues/1458
about the steps that led to this unsupported combination.
************************************************************
  sys.version_info < (3,) and warnings.warn(pre + "*" * 60 + msg + "*" * 60)

By tweaking our default versions, we can make sure our users don't get this noise when running ./pants fmt2 and ./pants lint2.

@Eric-Arellano Eric-Arellano force-pushed the fix-setuptools-warnings branch from 035463c to b5e174e Compare February 14, 2020 06:39
It's unclear why it's hanging
@asherf
Copy link
Member

asherf commented Feb 14, 2020

I don't follow.... Why are we running those tools (bandit, flake8) under a python2 interpreter ?
Even if they check/run on a python 2 code base, we don't have to run them in a python 2 interpreter....

@Eric-Arellano
Copy link
Contributor Author

I don't follow.... Why are we running those tools (bandit, flake8) under a python2 interpreter ?
Even if they check/run on a python 2 code base, we don't have to run them in a python 2 interpreter....

For Bandit and Flake8, Pants figures out the interpreter constraints first based off of the specific target's compatibility field, then --python-setup-interpreter-constraints. It's possible to run those tools on Python 2 targets, and we need to keep that support so long as those tools keep Python 2 support.

For isort, we tell Pex to use whatever the default_interpreter_constraints are, which are hardcoded by Pants but can also be configured via --isort-interpreter-constraints. Originally in this PR I tried setting isort to always use Python 3.6 per #9131 (comment) because it doesn't matter what version we use for isort. But, CI kept hanging so I'm trying out if setting setuptools<45 and still allowing Python 2 fixes things. In isort 5.0, it will drop support for Python 2 so we'll able to remove this workaround.

@Eric-Arellano
Copy link
Contributor Author

Weird. Confirmed that removing the interpreter constraints from isort and setting setuptools<45 does fix the hang in CI. I have no idea why that is, but we'll handle the issue once we upgrade to isort 5.0 I suppose.

@Eric-Arellano Eric-Arellano merged commit 2126ce5 into pantsbuild:master Feb 14, 2020
@Eric-Arellano Eric-Arellano deleted the fix-setuptools-warnings branch February 14, 2020 23:43
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.

3 participants