Skip to content

Commit ad9ce52

Browse files
committed
Drop Python 2.6 support (niklasf#126)
First introduced 2 years ago in af72d5a, when it was already 2 years dead, but easy to support. Now dependencies dropped support and I don't want to add further workarounds.
1 parent aa87cc6 commit ad9ce52

12 files changed

Lines changed: 81 additions & 170 deletions

File tree

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: python
22
dist: trusty
33
sudo: false
44
python:
5-
- "2.6"
65
- "2.7"
76
- "3.3"
87
- "3.4"

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ python-chess:
6767
Features
6868
--------
6969

70-
* Supports Python 2.6+, Python 3.3+ and PyPy.
70+
* Supports Python 2.7, Python 3.3+ and PyPy.
7171

7272
* IPython/Jupyter Notebook integration.
7373
`SVG rendering docs <https://python-chess.readthedocs.io/en/latest/svg.html>`_.

chess/__init__.py

Lines changed: 17 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@
2828

2929
__version__ = "0.21.2"
3030

31+
import collections
3132
import copy
3233
import re
3334
import itertools
3435

35-
try:
36-
import backport_collections as collections
37-
except ImportError:
38-
import collections
39-
4036
COLORS = [WHITE, BLACK] = [True, False]
4137
COLOR_NAMES = ["black", "white"]
4238

@@ -165,58 +161,23 @@ def square_mirror(square):
165161
BB_BACKRANKS = BB_RANK_1 | BB_RANK_8
166162

167163

168-
try:
169-
# Added in Python 2.7 and 3.1, respectively.
170-
int.bit_length
171-
except AttributeError:
172-
def _lsb_table():
173-
table = [0 for _ in range(64)]
174-
for square, bb in enumerate(BB_SQUARES):
175-
index = (((bb ^ (bb - 1)) * 0x3f79d71b4cb0a89) & 0xffffffffffffffff) >> 58
176-
table[index] = square
177-
return table
178-
179-
def lsb(bb, _table=_lsb_table()):
180-
return _table[(((bb ^ (bb - 1)) * 0x3f79d71b4cb0a89) & 0xffffffffffffffff) >> 58]
181-
182-
def scan_forward(bb, _bin=bin, _len=len):
183-
string = _bin(bb)
184-
l = _len(string)
185-
r = string.rfind("1")
186-
while r != -1:
187-
yield l - r - 1
188-
r = string.rfind("1", 0, r)
189-
190-
def msb(bb, _bin=bin, _len=len):
191-
string = _bin(bb)
192-
return _len(string) - 1 - string.find("1")
193-
194-
def scan_reversed(bb, _bin=bin, _len=len):
195-
string = _bin(bb)
196-
l = _len(string)
197-
r = string.find("1")
198-
while r != -1:
199-
yield l - r - 1
200-
r = string.find("1", r + 1)
201-
else:
202-
def lsb(bb):
203-
return (bb & -bb).bit_length() - 1
204-
205-
def scan_forward(bb):
206-
while bb:
207-
r = bb & -bb
208-
yield r.bit_length() - 1
209-
bb ^= r
210-
211-
def msb(bb):
212-
return bb.bit_length() - 1
213-
214-
def scan_reversed(bb, _BB_SQUARES=BB_SQUARES):
215-
while bb:
216-
r = bb.bit_length() - 1
217-
yield r
218-
bb ^= _BB_SQUARES[r]
164+
def lsb(bb):
165+
return (bb & -bb).bit_length() - 1
166+
167+
def scan_forward(bb):
168+
while bb:
169+
r = bb & -bb
170+
yield r.bit_length() - 1
171+
bb ^= r
172+
173+
def msb(bb):
174+
return bb.bit_length() - 1
219175

176+
def scan_reversed(bb, _BB_SQUARES=BB_SQUARES):
177+
while bb:
178+
r = bb.bit_length() - 1
179+
yield r
180+
bb ^= _BB_SQUARES[r]
220181

221182
def popcount(b, _bin=bin):
222183
return _bin(b).count("1")

chess/engine.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,19 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import collections
1920
import logging
2021
import threading
2122
import os
2223
import sys
2324
import signal
2425
import platform
2526

26-
try:
27-
import backport_collections as collections
28-
except ImportError:
29-
import collections
3027

3128
try:
32-
import queue
29+
import queue # Python 3
3330
except ImportError:
34-
import Queue as queue
31+
import Queue as queue # Python 2
3532

3633
if os.name == "posix" and sys.version_info[0] < 3:
3734
try:

chess/gaviota.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# You should have received a copy of the GNU General Public License
1818
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1919

20+
import collections
2021
import ctypes
2122
import ctypes.util
2223
import fnmatch
@@ -26,11 +27,6 @@
2627
import struct
2728
import chess
2829

29-
try:
30-
import backport_collections as collections
31-
except ImportError:
32-
import collections
33-
3430

3531
LOGGER = logging.getLogger(__name__)
3632

chess/pgn.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

1919
import chess
20+
import collections
2021
import itertools
2122
import re
2223
import logging
2324

24-
try:
25-
import backport_collections as collections
26-
except ImportError:
27-
import collections
28-
2925

3026
LOGGER = logging.getLogger(__name__)
3127

chess/polyglot.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

1919
import chess
20+
import collections
2021
import struct
2122
import os
2223
import mmap
2324
import random
2425

25-
try:
26-
import backport_collections as collections
27-
except ImportError:
28-
import collections
2926

3027
ENTRY_STRUCT = struct.Struct(">QHHI")
3128

chess/svg.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@
2323
from __future__ import division
2424

2525
import chess
26+
import collections
2627
import math
2728

2829
import xml.etree.ElementTree as ET
2930

30-
try:
31-
import backport_collections as collections
32-
except ImportError:
33-
import collections
34-
3531

3632
SQUARE_SIZE = 45
3733

chess/uci.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import chess
20+
1921
from chess.engine import EngineTerminatedException
2022
from chess.engine import EngineStateException
2123
from chess.engine import MockProcess
@@ -28,16 +30,10 @@
2830
from chess.engine import _popen_engine
2931
from chess.engine import _spur_spawn_engine
3032

31-
import chess
32-
33+
import collections
3334
import concurrent.futures
3435
import threading
3536

36-
try:
37-
import backport_collections as collections
38-
except ImportError:
39-
import collections
40-
4137

4238
class Score(collections.namedtuple("Score", "cp mate")):
4339
"""A *cp* (centipawns) or *mate* score sent by an UCI engine."""

setup.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@ def read_description():
5353
return description
5454

5555

56-
def dependencies():
57-
deps = []
58-
59-
if sys.version_info < (2, 7):
60-
deps.append("backport_collections")
61-
62-
return deps
63-
64-
6556
def extra_dependencies():
6657
extras = {}
6758

@@ -78,9 +69,6 @@ def extra_dependencies():
7869

7970
extras["test"] = extras["engine"] + extras.get("gaviota", [])
8071

81-
if sys.version_info < (2, 7):
82-
extras["test"].append("unittest2")
83-
8472
if platform.python_implementation() == "CPython":
8573
extras["test"].append("spur")
8674

@@ -99,8 +87,7 @@ def extra_dependencies():
9987
url="https://github.com/niklasf/python-chess",
10088
packages=["chess"],
10189
test_suite="test",
102-
python_requires=">=2.6,!=3.0.*,!=3.1.*,!=3.2.*",
103-
install_requires=dependencies(),
90+
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*",
10491
extras_require=extra_dependencies(),
10592
tests_require=extra_dependencies().get("test"),
10693
classifiers=[
@@ -111,7 +98,6 @@ def extra_dependencies():
11198
"Operating System :: OS Independent",
11299
"Programming Language :: Python",
113100
"Programming Language :: Python :: 2",
114-
"Programming Language :: Python :: 2.6",
115101
"Programming Language :: Python :: 2.7",
116102
"Programming Language :: Python :: 3",
117103
"Programming Language :: Python :: 3.3",

0 commit comments

Comments
 (0)