Skip to content

Remove Python 2 code from setup #10470

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

Merged
merged 4 commits into from
Feb 19, 2018
Merged

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Feb 15, 2018

PR Summary

A bit of a follow up to #10425. Use @anntzer's suggestion to exit earlier (and thus require Python 2 compatibility for fewer files), and then drop the Python 2 stuff from setupext.py.

PR Checklist

  • [N/A] Has Pytest style unit tests
  • Code is PEP 8 compliant
  • [N/A] New features are documented, with examples if plot related
  • [N/A] Documentation is sphinx and numpydoc compliant
  • [N/A] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • [N/A] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@QuLogic QuLogic added this to the v3.0 milestone Feb 15, 2018
setupext.py Outdated
msgs += ['using mock %s' % mock.__version__]
except ImportError:
msgs += [msg_template.format(package='mock')]
msgs += ['using unittest.mock']
Copy link
Contributor

@anntzer anntzer Feb 15, 2018

Choose a reason for hiding this comment

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

would not even bother with the message, it's just a boring regular stdlib module now

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

minor suggested change, but not blocking merge

@QuLogic QuLogic changed the title Remote Python 2 code from setup Remove Python 2 code from setup Feb 15, 2018
@QuLogic
Copy link
Member Author

QuLogic commented Feb 15, 2018

Fixed your comment and also found a couple more instances of try:-type back-compat code.

@QuLogic
Copy link
Member Author

QuLogic commented Feb 15, 2018

I also moved the check in __init__.py up, because I noticed in #10439 you want to import pathlib, but the check would be too late for that.

if sys.version_info < (3, 5): # noqa: E402
raise ImportError("""
Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
Beginning with Matplotlib 3.0, Python 3.5 and above is required.
Copy link
Member

Choose a reason for hiding this comment

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

Both lines -> "Matplotlib 3.0+ requires Python 3.5 or above."

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the same as before and it's being explicit on purpose, as it's following IPython's lead.

Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
Beginning with Matplotlib 3.0, Python 3.5 and above is required.

See Matplotlib `INSTALL.rst` file for more information:
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't fit on a line nicely.

@@ -14,6 +14,17 @@

import sys

if sys.version_info < (3, 5):
error = """
Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
Copy link
Member

Choose a reason for hiding this comment

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

See above.


Make sure you have pip >= 9.0.1.
"""
sys.exit(error)
Copy link
Member

Choose a reason for hiding this comment

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

How does this behave if installed as a dependency of something via pip? Modern pip should never try, but what do old versions of pip do?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, that's why we error out and the message suggests that you install a new pip.

Copy link
Member Author

Choose a reason for hiding this comment

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

In a normal install, it does this:

$ pip install -e .
Obtaining file:///.../matplotlib
    Complete output from command python setup.py egg_info:
    
    Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
    Beginning with Matplotlib 3.0, Python 3.5 and above is required.
    
    This may be due to an out of date pip.
    
    Make sure you have pip >= 9.0.1.
    
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in .../matplotlib/

I'm not sure how to test it out as a dependency, but I'd guess you get a similar error.

This reduces the number of files we need to keep Python 2 compatible.
This will allow us to import anything new things from the standard
library without breaking Python 2.
@QuLogic
Copy link
Member Author

QuLogic commented Feb 17, 2018

Rebased due to conflicts.

@QuLogic QuLogic added the Build label Feb 17, 2018
@QuLogic QuLogic added the Py3k label Feb 18, 2018
@tacaswell tacaswell merged commit 2a45b53 into matplotlib:master Feb 19, 2018
@QuLogic QuLogic deleted the py3-setup branch February 19, 2018 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants