You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB

4 years ago
  1. import os.path
  2. import cytoolz
  3. __all__ = ['raises', 'no_default', 'include_dirs', 'consume']
  4. try:
  5. # Attempt to get the no_default sentinel object from toolz
  6. from toolz.utils import no_default
  7. except ImportError:
  8. no_default = '__no__default__'
  9. def raises(err, lamda):
  10. try:
  11. lamda()
  12. return False
  13. except err:
  14. return True
  15. def include_dirs():
  16. """ Return a list of directories containing the *.pxd files for ``cytoolz``
  17. Use this to include ``cytoolz`` in your own Cython project, which allows
  18. fast C bindinds to be imported such as ``from cytoolz cimport get``.
  19. Below is a minimal "setup.py" file using ``include_dirs``:
  20. from distutils.core import setup
  21. from distutils.extension import Extension
  22. from Cython.Distutils import build_ext
  23. import cytoolz.utils
  24. ext_modules=[
  25. Extension("mymodule",
  26. ["mymodule.pyx"],
  27. include_dirs=cytoolz.utils.include_dirs()
  28. )
  29. ]
  30. setup(
  31. name = "mymodule",
  32. cmdclass = {"build_ext": build_ext},
  33. ext_modules = ext_modules
  34. )
  35. """
  36. return os.path.split(cytoolz.__path__[0])
  37. cpdef object consume(object seq):
  38. """
  39. Efficiently consume an iterable """
  40. for _ in seq:
  41. pass