Skip to content
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

Update msgpack vendor to v1.1.0 #114

Merged
merged 5 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 2 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- os: windows-2019
python_version: "3.6"
- os: ubuntu-20.04
python_version: "3.6"
os: [ubuntu-latest, windows-latest]
python_version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
catalogue>=2.0.3,<2.1.0
# Development requirements
cython>=0.29.1,<0.30.0
cython>=0.29.1
pytest>=4.6.5
pytest-timeout>=1.3.3
mock>=2.0.0,<3.0.0
Expand Down
8 changes: 3 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ classifiers =
Operating System :: Microsoft :: Windows
Programming Language :: Cython
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Topic :: Scientific/Engineering

[options]
zip_safe = true
include_package_data = true
python_requires = >=3.6
python_requires = >=3.9
setup_requires =
cython>=0.29.1,<0.30.0
cython>=0.29.1
install_requires =
catalogue>=2.0.3,<2.1.0

Expand Down
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
Options.docstrings = True


PACKAGE_DATA = {"": ["*.pyx", "*.pxd", "*.c", "*.h"]}
PACKAGE_DATA = {"": ["*.pyx", "*.pxd", "*.c", "*.h", "*.cpp"]}
PACKAGES = find_packages()
MOD_NAMES = ["srsly.msgpack._unpacker", "srsly.msgpack._packer"]
# msgpack has this whacky build where it only builds _cmsgpack which textually includes
# _packer and _unpacker. I refactored this.
MOD_NAMES = ["srsly.msgpack._epoch", "srsly.msgpack._packer", "srsly.msgpack._unpacker"]
COMPILE_OPTIONS = {
"msvc": ["/Ox", "/EHsc"],
"mingw32": ["-O2", "-Wno-strict-prototypes", "-Wno-unused-function"],
Expand Down Expand Up @@ -94,7 +96,7 @@ def setup_package():
exec(f.read(), about)

with chdir(str(root)):
include_dirs = [get_path("include"), "."]
include_dirs = [get_path("include"), ".", "srsly"]
ext_modules = []
for name in MOD_NAMES:
mod_path = name.replace(".", "/") + ".pyx"
Expand Down Expand Up @@ -122,7 +124,9 @@ def setup_package():
)
)
print("Cythonizing sources")
ext_modules = cythonize(ext_modules, compiler_directives=COMPILER_DIRECTIVES, language_level=2)
ext_modules = cythonize(
ext_modules, compiler_directives=COMPILER_DIRECTIVES, language_level=2
)

setup(
name="srsly",
Expand Down
12 changes: 9 additions & 3 deletions srsly/msgpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
import functools
import catalogue

# These need to be imported before packer and unpacker
from ._epoch import utc, epoch # noqa

from ._version import version
from .exceptions import *

# In msgpack-python these are put under a _cmsgpack module that textually includes
# them. I dislike this so I refactored it.
from ._packer import Packer as _Packer
from ._unpacker import unpackb as _unpackb
from ._unpacker import unpack as _unpack
from ._unpacker import Unpacker as _Unpacker
from ._ext_type import ExtType
from .ext import ExtType
from ._msgpack_numpy import encode_numpy as _encode_numpy
from ._msgpack_numpy import decode_numpy as _decode_numpy

Expand Down Expand Up @@ -64,7 +69,8 @@ def unpack(stream, **kwargs):
for decoder in msgpack_decoders.get_all().values():
object_hook = functools.partial(decoder, chain=object_hook)
kwargs["object_hook"] = object_hook
return _unpack(stream, **kwargs)
data = stream.read()
return _unpackb(data, **kwargs)


def unpackb(packed, **kwargs):
Expand Down
7 changes: 7 additions & 0 deletions srsly/msgpack/_epoch.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from cpython.datetime cimport import_datetime, datetime_new

import_datetime()
import datetime

utc = datetime.timezone.utc
epoch = datetime_new(1970, 1, 1, 0, 0, 0, 0, tz=utc)
14 changes: 0 additions & 14 deletions srsly/msgpack/_ext_type.py

This file was deleted.

Loading
Loading