10000 Drop Python 2 support from _cmsgpack by methane · Pull Request #376 · msgpack/msgpack-python · GitHub
[go: up one dir, main page]

Skip to content

Drop Python 2 support from _cmsgpack #376

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
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Drop Python 2 support from _cmsgpack
  • Loading branch information
methane committed Nov 27, 2019
commit cfdf119c740e3d3d8637aca463e65f7c37e6a2f9
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ python:
# Available Python (PyPy) can be listed by:
#
# $ aws s3 ls s3://travis-python-archives/binaries/ubuntu/16.04/x86_64/
- "2.7"
- "3.4"
- "3.5"
- "3.6"
Expand Down Expand Up @@ -41,7 +40,14 @@ matrix:
- pip install -e .
script:
- pytest -v test

- name: "Python 2 (fallback)"
python: "2.7"
install:
- pip install -U pip
- pip install -U pytest
- pip install .
script:
- pytest -v test

install:
- pip install -U pip
Expand Down
2 changes: 0 additions & 2 deletions docker/shared.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ PYTHON_VERSIONS=(
cp37-cp37m
cp36-cp36m
cp35-cp35m
cp27-cp27m
cp27-cp27mu
)
5 changes: 3 additions & 2 deletions msgpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from ._version import version
from .exceptions import *

import os
import sys
from collections import namedtuple


Expand All @@ -17,8 +19,7 @@ def __new__(cls, code, data):
return super(ExtType, cls).__new__(cls, code, data)


import os
if os.environ.get('MSGPACK_PUREPYTHON'):
if os.environ.get('MSGPACK_PUREPYTHON') or sys.version_info[0] == 2:
from .fallback import Packer, unpackb, Unpacker
else:
try:
Expand Down
5 changes: 2 additions & 3 deletions msgpack/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
import warnings


if sys.version_info[0] == 2:
PY2 = True
PY2 = sys.version_info[0] == 2
if PY2:
int_types = (int, long)
def dict_iteritems(d):
return d.iteritems()
else:
PY2 = False
int_types = int
unicode = str
xrange = range
Expand Down
20 changes: 11 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

from distutils.command.build_ext import build_ext


PYPY = hasattr(sys, "pypy_version_info")
PY2 = sys.version_info[0] == 2


# for building transitional package.
TRANSITIONAL = False

Expand Down Expand Up @@ -64,14 +69,11 @@ def build_extension(self, ext):
if len(version) > 3 and version[3] != 'final':
version_str += version[3]

# take care of extension modules.
if have_cython:
class Sdist(sdist):
def __init__(self, *args, **kwargs):
cythonize('msgpack/_cmsgpack.pyx')
sdist.__init__(self, *args, **kwargs)
else:
Sdist = sdist
# Cython is required for sdist
class Sdist(sdist):
def __init__(self, *args, **kwargs):
cythonize('msgpack/_cmsgpack.pyx')
sdist.__init__(self, *args, **kwargs)

libraries = []
if sys.platform == 'win32':
Expand All @@ -83,7 +85,7 @@ def __init__(self, *args, **kwargs):
macros = [('__LITTLE_ENDIAN__', '1')]

ext_modules = []
if not hasattr(sys, 'pypy_version_info'):
if not PYPY and not PY2:
ext_modules.append(Extension('msgpack._cmsgpack',
sources=['msgpack/_cmsgpack.cpp'],
libraries=libraries,
Expand Down
0