From 87ffe6543367b90a2120e97c017736a0d2fa2834 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Sun, 10 Jul 2022 14:53:59 -0500 Subject: [PATCH 1/5] Update to latest toolz: make juxt a class with .funcs --- cytoolz/__init__.pxd | 2 +- cytoolz/functoolz.pxd | 5 +---- cytoolz/functoolz.pyx | 42 ++++++++++++++++++------------------------ 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/cytoolz/__init__.pxd b/cytoolz/__init__.pxd index 471f464..6b5c098 100644 --- a/cytoolz/__init__.pxd +++ b/cytoolz/__init__.pxd @@ -7,7 +7,7 @@ from cytoolz.itertoolz cimport ( from cytoolz.functoolz cimport ( - c_compose, c_juxt, memoize, c_pipe, c_thread_first, c_thread_last, + c_compose, memoize, c_pipe, c_thread_first, c_thread_last, complement, curry, do, identity, excepts, flip) diff --git a/cytoolz/functoolz.pxd b/cytoolz/functoolz.pxd index 260cba9..5425c8b 100644 --- a/cytoolz/functoolz.pxd +++ b/cytoolz/functoolz.pxd @@ -48,13 +48,10 @@ cdef class complement: cdef object func -cdef class _juxt_inner: +cdef class juxt: cdef public tuple funcs -cdef object c_juxt(object funcs) - - cpdef object do(object func, object x) diff --git a/cytoolz/functoolz.pyx b/cytoolz/functoolz.pyx index df97fbc..ea5d0e3 100644 --- a/cytoolz/functoolz.pyx +++ b/cytoolz/functoolz.pyx @@ -691,26 +691,9 @@ cdef class complement: return (complement, (self.func,)) -cdef class _juxt_inner: - def __cinit__(self, funcs): - self.funcs = tuple(funcs) - - def __call__(self, *args, **kwargs): - if kwargs: - return tuple(PyObject_Call(func, args, kwargs) for func in self.funcs) - else: - return tuple(PyObject_CallObject(func, args) for func in self.funcs) +cdef class juxt: + """ juxt(self, *funcs) - def __reduce__(self): - return (_juxt_inner, (self.funcs,)) - - -cdef object c_juxt(object funcs): - return _juxt_inner(funcs) - - -def juxt(*funcs): - """ Creates a function that calls several functions with the same arguments Takes several functions and returns a function that applies its arguments @@ -726,9 +709,19 @@ def juxt(*funcs): >>> juxt([inc, double])(10) (11, 20) """ - if len(funcs) == 1 and not PyCallable_Check(funcs[0]): - funcs = funcs[0] - return c_juxt(funcs) + def __cinit__(self, *funcs): + if len(funcs) == 1 and not PyCallable_Check(funcs[0]): + funcs = funcs[0] + self.funcs = tuple(funcs) + + def __call__(self, *args, **kwargs): + if kwargs: + return tuple(PyObject_Call(func, args, kwargs) for func in self.funcs) + else: + return tuple(PyObject_CallObject(func, args) for func in self.funcs) + + def __reduce__(self): + return (juxt, (self.funcs,)) cpdef object do(object func, object x): @@ -796,7 +789,8 @@ cpdef object return_none(object exc): cdef class excepts: - """ + """ excepts(self, exc, func, handler=return_none) + A wrapper around a function to catch exceptions and dispatch to a handler. @@ -825,7 +819,7 @@ cdef class excepts: 1 """ - def __init__(self, exc, func, handler=return_none): + def __cinit__(self, exc, func, handler=return_none): self.exc = exc self.func = func self.handler = handler From 712630ef97fd0f7cc1122889e183f7a849d7621c Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Sun, 10 Jul 2022 15:05:26 -0500 Subject: [PATCH 2/5] Well that didn't take long for wheels to break. Try this. --- .github/workflows/wheels.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 0915dea..b2ca18b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -1,6 +1,7 @@ name: Build wheels on: + pull_request: push: branches: - master @@ -189,9 +190,7 @@ jobs: with: python-version: "3.8" - name: Install build dependencies - run: | - python -m pip install --upgrade pip - python -m pip install setuptools wheel cython + run: python -m pip install setuptools wheel cython - name: Build sdist run: python setup.py sdist - name: Upload sdist From 84df1c1f7e9a501b0b687fa7c6fecbb8b0a3a155 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Sun, 10 Jul 2022 15:22:57 -0500 Subject: [PATCH 3/5] Note to self: don't modify versioneer things --- .github/workflows/wheels.yml | 4 +++- cytoolz/__init__.py | 7 ++++++- cytoolz/_version.py | 7 ------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index b2ca18b..3f9eec0 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -190,7 +190,9 @@ jobs: with: python-version: "3.8" - name: Install build dependencies - run: python -m pip install setuptools wheel cython + run: | + python -m pip install --upgrade pip + python -m pip install setuptools wheel cython - name: Build sdist run: python setup.py sdist - name: Upload sdist diff --git a/cytoolz/__init__.py b/cytoolz/__init__.py index b35aa46..a45c165 100644 --- a/cytoolz/__init__.py +++ b/cytoolz/__init__.py @@ -23,5 +23,10 @@ functoolz._sigs.update_signature_registry() -from ._version import __version__, __toolz_version__ +# What version of toolz does cytoolz implement? +__toolz_version__ = '0.12.0' +from ._version import get_versions + +__version__ = get_versions()['version'] +del get_versions diff --git a/cytoolz/_version.py b/cytoolz/_version.py index 9aaadac..ccd19ba 100644 --- a/cytoolz/_version.py +++ b/cytoolz/_version.py @@ -18,10 +18,6 @@ import functools -# What version of toolz does cytoolz implement? Placed here compatibility. -__toolz_version__ = '0.12.0' - - def get_keywords(): """Get the keywords needed to look up the version information.""" # these strings will be replaced by git during git-archive. @@ -659,6 +655,3 @@ def get_versions(): return {"version": "0+unknown", "full-revisionid": None, "dirty": None, "error": "unable to compute version", "date": None} - - -__version__ = get_versions()['version'] From fdd00e1c20afc041ad0b7f1cee10be90b7ae9b62 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Sun, 10 Jul 2022 15:57:58 -0500 Subject: [PATCH 4/5] I think we're good; don't build wheels in PRs by default, but make it easy to enable --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 171e331..174b5bd 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -1,7 +1,7 @@ name: Build wheels on: - pull_request: + # pull_request: # Uncomment to debug wheel building in a PR push: branches: - master From 3719f6d32c5257f2200d66982edd9e021600846b Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Sun, 10 Jul 2022 19:23:53 -0500 Subject: [PATCH 5/5] Hmm, PyPy wheels may have intermittent failures --- .github/workflows/wheels.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 174b5bd..fbb40cf 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -24,10 +24,13 @@ jobs: # # Archs: https://cibuildwheel.readthedocs.io/en/stable/options/#archs # # This probably isn't the preferred way to do things :shrug: # + # # PyPy may have issues. Intermittent failures have been seen on: + # # pp37-manylinux_aarch64 pp38-win_amd64 + # # pys = ['cp36', 'cp37', 'cp38', 'cp39', 'cp310'] # pys_arm = ['cp38', 'cp39', 'cp310'] # pypys = ['pp37', 'pp38', 'pp39'] - # SKIP = {"pp37-manylinux_aarch64"} + # SKIP = set() # {"pp37-manylinux_aarch64", "pp38-win_amd64"} # combos = [] # # # Linux @@ -121,8 +124,8 @@ jobs: - {"os": "ubuntu", "build": "cp310-musllinux_ppc64le", "arch": "ppc64le"} - {"os": "ubuntu", "build": "cp310-musllinux_s390x", "arch": "s390x"} - {"os": "ubuntu", "build": "cp310-musllinux_x86_64", "arch": "x86_64"} - # Segfault in test_dicttoolz.py:test_merge_with - # - {"os": "ubuntu", "build": "pp37-manylinux_aarch64", "arch": "aarch64"} + # Intermittent segfault on pp37-manylinux_aarch64 in test_dicttoolz.py:test_merge_with + - {"os": "ubuntu", "build": "pp37-manylinux_aarch64", "arch": "aarch64"} - {"os": "ubuntu", "build": "pp37-manylinux_i686", "arch": "i686"} - {"os": "ubuntu", "build": "pp37-manylinux_x86_64", "arch": "x86_64"} - {"os": "ubuntu", "build": "pp38-manylinux_aarch64", "arch": "aarch64"}