Skip to content

Commit f6f9597

Browse files
committed
Merge extension module
There were `_packer.so` and `_unpacker.so`. But single module is simpler than double module. Merge extension module into single `_msgpack.so`.
1 parent 91ec9e1 commit f6f9597

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

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

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)