Skip to content

Commit

Permalink
Merge pull request #1756 from sopel-irc/py2-warning-update
Browse files Browse the repository at this point in the history
Prepare Sopel to adapt its output when py2 officially dies
  • Loading branch information
dgw authored Dec 7, 2019
2 parents b024bf3 + bc2975d commit f4db54f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Sopel requires ``backports.ssl_match_hostname`` to be installed. Use
``yum install python-backports.ssl_match_hostname`` to install it, or download
and install it manually `from PyPI <https://pypi.org/project/backports.ssl_match_hostname>`_.

Note: Python 2.x is near end of life. Sopel support at that point is TBD.
Note: Python 2.x is near end of life. Sopel will drop support in version 8.0.

In the source directory (whether cloned or from the tarball) run
``setup.py install``. You can then run ``sopel`` to configure and start the
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import unicode_literals, absolute_import, print_function, division

import sys
import time

try:
from setuptools import setup, __version__ as setuptools_version
Expand Down Expand Up @@ -38,7 +39,11 @@
# this fucking question, and if you get here you should go RTGDMFM.
raise ImportError('Sopel requires Python 2.7+ or 3.3+.')
if sys.version_info.major == 2:
print('Warning: Python 2.x is near end of life. Sopel support at that point is TBD.', file=sys.stderr)
if time.time() >= 1577836800: # 2020-01-01 00:00:00 UTC
state = 'is near end of life'
else:
state = 'has reached end of life and will receive no further updates'
print('Warning: Python 2.x %s. Sopel will drop support in version 8.0.' % state, file=sys.stderr)


def read_reqs(path):
Expand Down
6 changes: 5 additions & 1 deletion sopel/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
tools.stderr('Error: Requires Python 2.7 or later. Try python2.7 sopel')
sys.exit(1)
if sys.version_info.major == 2:
tools.stderr('Warning: Python 2.x is near end of life. Sopel support at that point is TBD.')
if time.time() >= 1577836800: # 2020-01-01 00:00:00 UTC
state = 'is near end of life'
else:
state = 'has reached end of life and will receive no further updates'
tools.stderr('Warning: Python 2.x %s. Sopel will drop support in version 8.0.' % state)
if sys.version_info.major == 3 and sys.version_info.minor < 3:
tools.stderr('Error: When running on Python 3, Python 3.3 is required.')
sys.exit(1)
Expand Down

0 comments on commit f4db54f

Please sign in to comment.