Skip to content

Commit 08e65bd

Browse files
authored
Merge extension modules (#314)
There were `_packer.so` and `_unpacker.so`. But single module is simpler than double module. Merge extension module into single `_msgpack.so`.
2 parents 91ec9e1 + 9d11249 commit 08e65bd

File tree

6 files changed

+17
-22
lines changed

6 files changed

+17
-22
lines changed

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ matrix:
2121
install:
2222
- pip install -U pip
2323
- pip install cython
24-
- cython --cplus msgpack/_packer.pyx msgpack/_unpacker.pyx
24+
- make cython
2525
- docker pull $DOCKER_IMAGE
2626
script:
2727
- docker run --rm -v `pwd`:/io -w /io $DOCKER_IMAGE /io/docker/runtests.sh
@@ -34,19 +34,19 @@ matrix:
3434
install:
3535
- pip install -e .
3636
script:
37-
- py.test -v test
37+
- pytest -v test
3838

3939

4040
install:
4141
- pip install -U pip
4242
- pip install cython
43-
- cython --cplus msgpack/_packer.pyx msgpack/_unpacker.pyx
43+
- make cython
4444
- pip install -e .
4545

4646
script:
4747
- python -c 'import sys; print(hex(sys.maxsize))'
48-
- python -c 'from msgpack import _packer, _unpacker'
49-
- py.test -v test
50-
- MSGPACK_PUREPYTHON=x py.test -v test
48+
- python -c 'from msgpack import _msgpack'
49+
- pytest -v test
50+
- MSGPACK_PUREPYTHON=x pytest -v test
5151

5252
# vim: sw=2 ts=2

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ all: cython
44

55
.PHONY: cython
66
cython:
7-
cython --cplus msgpack/*.pyx
7+
cython --cplus msgpack/_msgpack.pyx
88

99
.PHONY: test
1010
test:
@@ -18,8 +18,7 @@ serve-doc: all
1818
.PHONY: clean
1919
clean:
2020
rm -rf build
21-
rm -f msgpack/_packer.cpp
22-
rm -f msgpack/_unpacker.cpp
21+
rm -f msgpack/_msgpack.cpp
2322
rm -rf msgpack/__pycache__
2423
rm -rf test/__pycache__
2524

docker/runtests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ for V in cp36-cp36m cp35-cp35m cp27-cp27m cp27-cp27mu; do
88
$PYBIN/pip install pytest
99
pushd test # prevent importing msgpack package in current directory.
1010
$PYBIN/python -c 'import sys; print(hex(sys.maxsize))'
11-
$PYBIN/python -c 'from msgpack import _packer, _unpacker'
11+
$PYBIN/python -c 'from msgpack import _msgpack' # Ensure extension is available
1212
$PYBIN/pytest -v .
1313
popd
1414
done

msgpack/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ def __new__(cls, code, data):
2222
from msgpack.fallback import Packer, unpackb, Unpacker
2323
else:
2424
try:
25-
from msgpack._packer import Packer
26-
from msgpack._unpacker import unpackb, Unpacker
25+
from msgpack._msgpack import Packer, unpackb, Unpacker
2726
except ImportError:
2827
from msgpack.fallback import Packer, unpackb, Unpacker
2928

msgpack/_msgpack.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# coding: utf-8
2+
#cython: embedsignature=True, c_string_encoding=ascii
3+
include "_packer.pyx"
4+
include "_unpacker.pyx"

setup.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def build_extension(self, ext):
6868
if have_cython:
6969
class Sdist(sdist):
7070
def __init__(self, *args, **kwargs):
71-
for src in glob('msgpack/*.pyx'):
72-
cythonize(src)
71+
cythonize('msgpack/_msgpack.pyx')
7372
sdist.__init__(self, *args, **kwargs)
7473
else:
7574
Sdist = sdist
@@ -85,14 +84,8 @@ def __init__(self, *args, **kwargs):
8584

8685
ext_modules = []
8786
if not hasattr(sys, 'pypy_version_info'):
88-
ext_modules.append(Extension('msgpack._packer',
89-
sources=['msgpack/_packer.cpp'],
90-
libraries=libraries,
91-
include_dirs=['.'],
92-
define_macros=macros,
93-
))
94-
ext_modules.append(Extension('msgpack._unpacker',
95-
sources=['msgpack/_unpacker.cpp'],
87+
ext_modules.append(Extension('msgpack._msgpack',
88+
sources=['msgpack/_msgpack.cpp'],
9689
libraries=libraries,
9790
include_dirs=['.'],
9891
define_macros=macros,

0 commit comments

Comments
 (0)