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

Test with Cython 0.29 and 3.0 #201

Merged
merged 11 commits into from
Jan 24, 2024
15 changes: 8 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,30 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
cython-version: ["0.29.37", "3.0.7"]
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "pypy3.6"
- "3.12"
- "pypy3.7"
- "pypy3.8"
# - "pypy3.9"
# - "pypy3.10"
- "pypy3.9"
- "pypy3.10"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install cython pytest
pip install cython==${{ matrix.cython-version }} pytest
pip install git+https://github.com/pytoolz/toolz.git
python setup.py build_ext --inplace --with-cython
pip install -e .
Expand Down
68 changes: 34 additions & 34 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
# # PyPy may have issues. Intermittent failures have been seen on:
# # pp37-manylinux_aarch64 pp38-win_amd64
#
# pys = ['cp36', 'cp37', 'cp38', 'cp39', 'cp310', 'cp311']
# pys_arm = ['cp38', 'cp39', 'cp310', 'cp311']
# pys = ['cp37', 'cp38', 'cp39', 'cp310', 'cp311', 'cp312']
# pys_arm = ['cp38', 'cp39', 'cp310', 'cp311', 'cp312']
# pypys = ['pp37', 'pp38', 'pp39', 'pp310']
# SKIP = set() # {"pp37-manylinux_aarch64", "pp38-win_amd64"}
# combos = []
Expand Down Expand Up @@ -60,10 +60,9 @@ jobs:
# combos.append(('windows', f'{py}-win_amd64', 'AMD64'))
#
# # Sort, filter, and print combinations
# for os, build, arch in sorted(combos, key=lambda x: (x[0], x[1].replace('310', '390').replace('311', '391'), x[2])):
# for os, build, arch in sorted(combos, key=lambda x: (x[0], x[1].replace('310', '390').replace('311', '391').replace('312', '392'), x[2])):
# skip = "# " if build in SKIP else ""
# print(f' {skip}- {{"os": "{os}", "build": "{build}", "arch": "{arch}"}}')
- {"os": "macos", "build": "cp36-macosx_x86_64", "arch": "x86_64"}
- {"os": "macos", "build": "cp37-macosx_x86_64", "arch": "x86_64"}
- {"os": "macos", "build": "cp38-macosx_arm64", "arch": "arm64"}
- {"os": "macos", "build": "cp38-macosx_x86_64", "arch": "x86_64"}
Expand All @@ -73,20 +72,12 @@ jobs:
- {"os": "macos", "build": "cp310-macosx_x86_64", "arch": "x86_64"}
- {"os": "macos", "build": "cp311-macosx_arm64", "arch": "arm64"}
- {"os": "macos", "build": "cp311-macosx_x86_64", "arch": "x86_64"}
- {"os": "macos", "build": "cp312-macosx_arm64", "arch": "arm64"}
- {"os": "macos", "build": "cp312-macosx_x86_64", "arch": "x86_64"}
- {"os": "macos", "build": "pp37-macosx_x86_64", "arch": "x86_64"}
- {"os": "macos", "build": "pp38-macosx_x86_64", "arch": "x86_64"}
# - {"os": "macos", "build": "pp39-macosx_x86_64", "arch": "x86_64"}
# - {"os": "macos", "build": "pp310-macosx_x86_64", "arch": "x86_64"}
- {"os": "ubuntu", "build": "cp36-manylinux_aarch64", "arch": "aarch64"}
- {"os": "ubuntu", "build": "cp36-manylinux_i686", "arch": "i686"}
- {"os": "ubuntu", "build": "cp36-manylinux_ppc64le", "arch": "ppc64le"}
- {"os": "ubuntu", "build": "cp36-manylinux_s390x", "arch": "s390x"}
- {"os": "ubuntu", "build": "cp36-manylinux_x86_64", "arch": "x86_64"}
- {"os": "ubuntu", "build": "cp36-musllinux_aarch64", "arch": "aarch64"}
- {"os": "ubuntu", "build": "cp36-musllinux_i686", "arch": "i686"}
- {"os": "ubuntu", "build": "cp36-musllinux_ppc64le", "arch": "ppc64le"}
- {"os": "ubuntu", "build": "cp36-musllinux_s390x", "arch": "s390x"}
- {"os": "ubuntu", "build": "cp36-musllinux_x86_64", "arch": "x86_64"}
- {"os": "macos", "build": "pp39-macosx_x86_64", "arch": "x86_64"}
- {"os": "macos", "build": "pp310-macosx_x86_64", "arch": "x86_64"}
- {"os": "ubuntu", "build": "cp37-manylinux_aarch64", "arch": "aarch64"}
- {"os": "ubuntu", "build": "cp37-manylinux_i686", "arch": "i686"}
- {"os": "ubuntu", "build": "cp37-manylinux_ppc64le", "arch": "ppc64le"}
Expand Down Expand Up @@ -137,21 +128,28 @@ jobs:
- {"os": "ubuntu", "build": "cp311-musllinux_ppc64le", "arch": "ppc64le"}
- {"os": "ubuntu", "build": "cp311-musllinux_s390x", "arch": "s390x"}
- {"os": "ubuntu", "build": "cp311-musllinux_x86_64", "arch": "x86_64"}
# Intermittent segfault on pp37-manylinux_aarch64 in test_dicttoolz.py:test_merge_with
- {"os": "ubuntu", "build": "cp312-manylinux_aarch64", "arch": "aarch64"}
- {"os": "ubuntu", "build": "cp312-manylinux_i686", "arch": "i686"}
- {"os": "ubuntu", "build": "cp312-manylinux_ppc64le", "arch": "ppc64le"}
- {"os": "ubuntu", "build": "cp312-manylinux_s390x", "arch": "s390x"}
- {"os": "ubuntu", "build": "cp312-manylinux_x86_64", "arch": "x86_64"}
- {"os": "ubuntu", "build": "cp312-musllinux_aarch64", "arch": "aarch64"}
- {"os": "ubuntu", "build": "cp312-musllinux_i686", "arch": "i686"}
- {"os": "ubuntu", "build": "cp312-musllinux_ppc64le", "arch": "ppc64le"}
- {"os": "ubuntu", "build": "cp312-musllinux_s390x", "arch": "s390x"}
- {"os": "ubuntu", "build": "cp312-musllinux_x86_64", "arch": "x86_64"}
- {"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"}
- {"os": "ubuntu", "build": "pp38-manylinux_i686", "arch": "i686"}
- {"os": "ubuntu", "build": "pp38-manylinux_x86_64", "arch": "x86_64"}
# - {"os": "ubuntu", "build": "pp39-manylinux_aarch64", "arch": "aarch64"}
# - {"os": "ubuntu", "build": "pp310-manylinux_aarch64", "arch": "aarch64"}
# - {"os": "ubuntu", "build": "pp39-manylinux_i686", "arch": "i686"}
# - {"os": "ubuntu", "build": "pp310-manylinux_i686", "arch": "i686"}
# - {"os": "ubuntu", "build": "pp39-manylinux_x86_64", "arch": "x86_64"}
# - {"os": "ubuntu", "build": "pp310-manylinux_x86_64", "arch": "x86_64"}
- {"os": "windows", "build": "cp36-win32", "arch": "x86"}
- {"os": "windows", "build": "cp36-win_amd64", "arch": "AMD64"}
- {"os": "ubuntu", "build": "pp39-manylinux_aarch64", "arch": "aarch64"}
- {"os": "ubuntu", "build": "pp39-manylinux_i686", "arch": "i686"}
- {"os": "ubuntu", "build": "pp39-manylinux_x86_64", "arch": "x86_64"}
- {"os": "ubuntu", "build": "pp310-manylinux_aarch64", "arch": "aarch64"}
- {"os": "ubuntu", "build": "pp310-manylinux_i686", "arch": "i686"}
- {"os": "ubuntu", "build": "pp310-manylinux_x86_64", "arch": "x86_64"}
- {"os": "windows", "build": "cp37-win32", "arch": "x86"}
- {"os": "windows", "build": "cp37-win_amd64", "arch": "AMD64"}
- {"os": "windows", "build": "cp38-win32", "arch": "x86"}
Expand All @@ -162,27 +160,29 @@ jobs:
- {"os": "windows", "build": "cp310-win_amd64", "arch": "AMD64"}
- {"os": "windows", "build": "cp311-win32", "arch": "x86"}
- {"os": "windows", "build": "cp311-win_amd64", "arch": "AMD64"}
- {"os": "windows", "build": "cp312-win32", "arch": "x86"}
- {"os": "windows", "build": "cp312-win_amd64", "arch": "AMD64"}
- {"os": "windows", "build": "pp37-win_amd64", "arch": "AMD64"}
- {"os": "windows", "build": "pp38-win_amd64", "arch": "AMD64"}
# - {"os": "windows", "build": "pp39-win_amd64", "arch": "AMD64"}
# - {"os": "windows", "build": "pp310-win_amd64", "arch": "AMD64"}
- {"os": "windows", "build": "pp39-win_amd64", "arch": "AMD64"}
- {"os": "windows", "build": "pp310-win_amd64", "arch": "AMD64"}

steps:
- name: Setup QEMU
if: ${{ matrix.os == 'ubuntu' }}
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Build wheels
uses: pypa/cibuildwheel@v2.14.1
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_BUILD: ${{ matrix.build }}
CIBW_ARCHS: ${{ matrix.arch }}
Expand All @@ -204,11 +204,11 @@ jobs:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Install build dependencies
Expand Down Expand Up @@ -237,7 +237,7 @@ jobs:
run: |
ls -al dist/
- name: Publish to PyPI
uses: pypa/[email protected].8
uses: pypa/[email protected].11
if: startsWith(github.ref, 'refs/tags/')
with:
user: __token__
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Install
Dependencies
------------

``cytoolz`` supports Python 3.6+ with a common codebase.
``cytoolz`` supports Python 3.7+ with a common codebase.
It is developed in Cython, but requires no dependecies other than CPython
and a C compiler. Like ``toolz``, it is a light weight dependency.

Expand All @@ -72,7 +72,7 @@ Community
See our `mailing list <https://groups.google.com/forum/#!forum/pytoolz>`__.
We're friendly.

.. |Build Status| image:: https://travis-ci.org/pytoolz/cytoolz.svg?branch=master
:target: https://travis-ci.org/pytoolz/cytoolz
.. |Build Status| image:: https://github.com/pytoolz/cytoolz/actions/workflows/test.yml/badge.svg?branch=master
:target: https://github.com/pytoolz/cytoolz/actions
.. |Version Status| image:: https://badge.fury.io/py/cytoolz.svg
:target: http://badge.fury.io/py/cytoolz
2 changes: 1 addition & 1 deletion cytoolz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
functoolz._sigs.update_signature_registry()

# What version of toolz does cytoolz implement?
__toolz_version__ = '0.12.0'
__toolz_version__ = '0.12.1'

from ._version import get_versions

Expand Down
30 changes: 21 additions & 9 deletions cytoolz/tests/test_functoolz.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
import sys
import cytoolz
from cytoolz.functoolz import (thread_first, thread_last, memoize, curry,
compose, compose_left, pipe, complement, do, juxt,
Expand All @@ -7,6 +8,12 @@
from cytoolz.utils import raises
from functools import partial

IS_PYPY_GE_39 = (
sys.implementation.name == "pypy"
and sys.version_info.major == 3
and sys.version_info.minor >= 9
)


def iseven(x):
return x % 2 == 0
Expand Down Expand Up @@ -253,7 +260,8 @@ def f(x, y):
return x

g = curry(f)
assert g.__doc__ == f.__doc__
if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property
assert g.__doc__ == f.__doc__
assert str(g) == str(f)
assert f(1, 2) == g(1, 2)

Expand Down Expand Up @@ -582,14 +590,16 @@ def g(a):

composed = compose(f, g)
assert composed.__name__ == 'f_of_g'
assert composed.__doc__ == 'lambda *args, **kwargs: f(g(*args, **kwargs))'
if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property
assert composed.__doc__ == 'lambda *args, **kwargs: f(g(*args, **kwargs))'

# Create an object with no __name__.
h = object()

composed = compose(f, h)
assert composed.__name__ == 'Compose'
assert composed.__doc__ == 'A composition of functions'
if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property
assert composed.__doc__ == 'A composition of functions'

assert repr(composed) == 'Compose({!r}, {!r})'.format(f, h)

Expand Down Expand Up @@ -760,9 +770,10 @@ def handler(e):
assert excepting(3) == -1

assert excepting.__name__ == 'idx_excepting_ValueError'
assert 'idx docstring' in excepting.__doc__
assert 'ValueError' in excepting.__doc__
assert 'handler docstring' in excepting.__doc__
if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property
assert 'idx docstring' in excepting.__doc__
assert 'ValueError' in excepting.__doc__
assert 'handler docstring' in excepting.__doc__

def getzero(a):
"""getzero docstring
Expand All @@ -776,9 +787,10 @@ def getzero(a):
assert excepting({0: 1}) == 1

assert excepting.__name__ == 'getzero_excepting_IndexError_or_KeyError'
assert 'getzero docstring' in excepting.__doc__
assert 'return_none' in excepting.__doc__
assert 'Returns None' in excepting.__doc__
if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property
assert 'getzero docstring' in excepting.__doc__
assert 'return_none' in excepting.__doc__
assert 'Returns None' in excepting.__doc__

def raise_(a):
"""A function that raises an instance of the exception type given.
Expand Down
25 changes: 25 additions & 0 deletions cytoolz/tests/test_itertoolz.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,34 @@ def test_unique():


def test_isiterable():
# objects that have a __iter__() or __getitem__() method are iterable
# https://docs.python.org/3/library/functions.html#iter
class IterIterable:
def __iter__(self):
return iter(["a", "b", "c"])

class GetItemIterable:
def __getitem__(self, item):
return ["a", "b", "c"][item]

# "if a class sets __iter__() to None, the class is not iterable"
# https://docs.python.org/3/reference/datamodel.html#special-method-names
class NotIterable:
__iter__ = None

class NotIterableEvenWithGetItem:
__iter__ = None

def __getitem__(self, item):
return ["a", "b", "c"][item]

assert isiterable([1, 2, 3]) is True
assert isiterable('abc') is True
assert isiterable(IterIterable()) is True
assert isiterable(GetItemIterable()) is True
assert isiterable(5) is False
assert isiterable(NotIterable()) is False
assert isiterable(NotIterableEvenWithGetItem()) is False


def test_isdistinct():
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@
'Programming Language :: Cython',
'Programming Language :: Python',
'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 :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Scientific/Engineering',
Expand All @@ -132,6 +132,6 @@
],
install_requires=['toolz >= 0.8.0'],
extras_require={'cython': ['cython']},
python_requires=">=3.6",
python_requires=">=3.7",
zip_safe=False,
)