mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-12-08 06:09:49 +00:00
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`.
This commit is contained in:
commit
08e65bdd03
6 changed files with 17 additions and 22 deletions
12
.travis.yml
12
.travis.yml
|
|
@ -21,7 +21,7 @@ matrix:
|
||||||
install:
|
install:
|
||||||
- pip install -U pip
|
- pip install -U pip
|
||||||
- pip install cython
|
- pip install cython
|
||||||
- cython --cplus msgpack/_packer.pyx msgpack/_unpacker.pyx
|
- make cython
|
||||||
- docker pull $DOCKER_IMAGE
|
- docker pull $DOCKER_IMAGE
|
||||||
script:
|
script:
|
||||||
- docker run --rm -v `pwd`:/io -w /io $DOCKER_IMAGE /io/docker/runtests.sh
|
- docker run --rm -v `pwd`:/io -w /io $DOCKER_IMAGE /io/docker/runtests.sh
|
||||||
|
|
@ -34,19 +34,19 @@ matrix:
|
||||||
install:
|
install:
|
||||||
- pip install -e .
|
- pip install -e .
|
||||||
script:
|
script:
|
||||||
- py.test -v test
|
- pytest -v test
|
||||||
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- pip install -U pip
|
- pip install -U pip
|
||||||
- pip install cython
|
- pip install cython
|
||||||
- cython --cplus msgpack/_packer.pyx msgpack/_unpacker.pyx
|
- make cython
|
||||||
- pip install -e .
|
- pip install -e .
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- python -c 'import sys; print(hex(sys.maxsize))'
|
- python -c 'import sys; print(hex(sys.maxsize))'
|
||||||
- python -c 'from msgpack import _packer, _unpacker'
|
- python -c 'from msgpack import _msgpack'
|
||||||
- py.test -v test
|
- pytest -v test
|
||||||
- MSGPACK_PUREPYTHON=x py.test -v test
|
- MSGPACK_PUREPYTHON=x pytest -v test
|
||||||
|
|
||||||
# vim: sw=2 ts=2
|
# vim: sw=2 ts=2
|
||||||
|
|
|
||||||
5
Makefile
5
Makefile
|
|
@ -4,7 +4,7 @@ all: cython
|
||||||
|
|
||||||
.PHONY: cython
|
.PHONY: cython
|
||||||
cython:
|
cython:
|
||||||
cython --cplus msgpack/*.pyx
|
cython --cplus msgpack/_msgpack.pyx
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
|
|
@ -18,8 +18,7 @@ serve-doc: all
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
rm -f msgpack/_packer.cpp
|
rm -f msgpack/_msgpack.cpp
|
||||||
rm -f msgpack/_unpacker.cpp
|
|
||||||
rm -rf msgpack/__pycache__
|
rm -rf msgpack/__pycache__
|
||||||
rm -rf test/__pycache__
|
rm -rf test/__pycache__
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ for V in cp36-cp36m cp35-cp35m cp27-cp27m cp27-cp27mu; do
|
||||||
$PYBIN/pip install pytest
|
$PYBIN/pip install pytest
|
||||||
pushd test # prevent importing msgpack package in current directory.
|
pushd test # prevent importing msgpack package in current directory.
|
||||||
$PYBIN/python -c 'import sys; print(hex(sys.maxsize))'
|
$PYBIN/python -c 'import sys; print(hex(sys.maxsize))'
|
||||||
$PYBIN/python -c 'from msgpack import _packer, _unpacker'
|
$PYBIN/python -c 'from msgpack import _msgpack' # Ensure extension is available
|
||||||
$PYBIN/pytest -v .
|
$PYBIN/pytest -v .
|
||||||
popd
|
popd
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,7 @@ if os.environ.get('MSGPACK_PUREPYTHON'):
|
||||||
from msgpack.fallback import Packer, unpackb, Unpacker
|
from msgpack.fallback import Packer, unpackb, Unpacker
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
from msgpack._packer import Packer
|
from msgpack._msgpack import Packer, unpackb, Unpacker
|
||||||
from msgpack._unpacker import unpackb, Unpacker
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from msgpack.fallback import Packer, unpackb, Unpacker
|
from msgpack.fallback import Packer, unpackb, Unpacker
|
||||||
|
|
||||||
|
|
|
||||||
4
msgpack/_msgpack.pyx
Normal file
4
msgpack/_msgpack.pyx
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
# coding: utf-8
|
||||||
|
#cython: embedsignature=True, c_string_encoding=ascii
|
||||||
|
include "_packer.pyx"
|
||||||
|
include "_unpacker.pyx"
|
||||||
13
setup.py
13
setup.py
|
|
@ -68,8 +68,7 @@ if len(version) > 3 and version[3] != 'final':
|
||||||
if have_cython:
|
if have_cython:
|
||||||
class Sdist(sdist):
|
class Sdist(sdist):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
for src in glob('msgpack/*.pyx'):
|
cythonize('msgpack/_msgpack.pyx')
|
||||||
cythonize(src)
|
|
||||||
sdist.__init__(self, *args, **kwargs)
|
sdist.__init__(self, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
Sdist = sdist
|
Sdist = sdist
|
||||||
|
|
@ -85,14 +84,8 @@ else:
|
||||||
|
|
||||||
ext_modules = []
|
ext_modules = []
|
||||||
if not hasattr(sys, 'pypy_version_info'):
|
if not hasattr(sys, 'pypy_version_info'):
|
||||||
ext_modules.append(Extension('msgpack._packer',
|
ext_modules.append(Extension('msgpack._msgpack',
|
||||||
sources=['msgpack/_packer.cpp'],
|
sources=['msgpack/_msgpack.cpp'],
|
||||||
libraries=libraries,
|
|
||||||
include_dirs=['.'],
|
|
||||||
define_macros=macros,
|
|
||||||
))
|
|
||||||
ext_modules.append(Extension('msgpack._unpacker',
|
|
||||||
sources=['msgpack/_unpacker.cpp'],
|
|
||||||
libraries=libraries,
|
libraries=libraries,
|
||||||
include_dirs=['.'],
|
include_dirs=['.'],
|
||||||
define_macros=macros,
|
define_macros=macros,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue