Skip to content

Commit

Permalink
Merge pull request #11 from mizvyt/master
Browse files Browse the repository at this point in the history
Re-add compilation from C (resolves #8)
  • Loading branch information
mizvyt authored Nov 24, 2019
2 parents f9f0445 + ca3d656 commit d0bb10a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 55 deletions.
19 changes: 13 additions & 6 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The goal of `pybloomfiltermmap3` is simple: to provide a fast, simple, scalable,
## Quickstart

After you install, the interface to use is a cross between a file
interface and a ste interface. As an example:
interface and an ste interface. As an example:
```python
>>> import pybloomfilter
>>> fruit = pybloomfilter.BloomFilter(100000, 0.1, '/tmp/words.bloom')
Expand All @@ -26,24 +26,25 @@ interface and a ste interface. As an example:
True
```

To create an in-memory filter, ditch the file location.
To create an in-memory filter, simply omit the file location:
```python
>>> cakes = pybloomfilter.BloomFilter(10000, 0.1)
```
*Caveates*: It is currently not possible to persist this filter later.
*Caveat*: It is currently not possible to persist this filter later.


## Docs

Follow the *official* docs for `pybloomfiltermmap`. http://axiak.github.io/pybloomfiltermmap/
Follow the *official* docs for `pybloomfiltermmap` at: http://axiak.github.io/pybloomfiltermmap/


## Install

Please have `Cython` installed. Please note that this version is **specifically** meant for Python 3. In case you need Python 2, please see https://github.com/axiak/pybloomfiltermmap.
Please note that this version is **specifically** meant for Python 3. In case you need Python 2, please see https://github.com/axiak/pybloomfiltermmap.

To install:

```shell
$ pip install cython
$ pip install pybloomfiltermmap3
```

Expand All @@ -54,3 +55,9 @@ and you should be set.

See the LICENSE file. It's under the MIT License.


## Contributions and development

When contributing, you should set up an appropriate Python 3 environment and install the dependencies listed in `requirements-dev.txt`.
This package depends on generation of `pybloomfilter.c` and requires Cython to be packaged.

1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cython==0.29.13
104 changes: 55 additions & 49 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,71 @@

from setuptools import setup, Extension

try:
from Cython.Distutils import build_ext
except ImportError:
print("""Cannot find Cython!
Cython is required to correctly build pyBloomFilter's C extensions.
In most cases, running the following command should be sufficient:
$ pip install Cython
Exception: ImportError
""")
exit()
if sys.version_info[0] < 3:
raise SystemError("This package is for Python version 3 and above.")

here = os.path.dirname(__file__)

# Get the long description from the README file
with open(os.path.join(here, 'README.markdown'), encoding='utf-8') as fp:
long_description = fp.read()
with open(os.path.join(here, "README.markdown"), encoding="utf-8") as fp:
long_description = fp.read()

setup_kwargs = {}

ext_files = [
'src/mmapbitarray.c',
'src/bloomfilter.c',
'src/md5.c',
'src/primetester.c',
'src/MurmurHash3.c',
'src/pybloomfilter.pyx'
"src/mmapbitarray.c",
"src/bloomfilter.c",
"src/md5.c",
"src/primetester.c",
"src/MurmurHash3.c",
]

print("info: Building from Cython")
# Branch out based on `--no-cython` in `argv`.
# Assume `--cython` as default to avoid having to deal with both params being there.

ext_modules = [
Extension("pybloomfilter", ext_files, libraries=['crypto'])
]
if "--no-cython" in sys.argv:
# Use the distributed `pybloomfilter.c`.
# Note that we let the exception bubble up if `pybloomfilter.c` doesn't exist.
ext_files.append("src/pybloomfilter.c")
sys.argv.remove("--no-cython")
else:
# Cythonize `pybloomfilter.pyx`
try:
from Cython.Distutils import build_ext
except ModuleNotFoundError:
print(
"Cython module not found. Hint: to build pybloomfilter using the distributed "
"source code, run 'python setup.py install --no-cython'."
)
sys.exit(1)

if sys.version_info[0] < 3:
raise SystemError('This Package is for Python Version 3 and above.')
ext_files.append("src/pybloomfilter.pyx")
setup_kwargs["cmdclass"] = {"build_ext": build_ext}

ext_modules = [Extension("pybloomfilter", ext_files)]

setup(
name='pybloomfiltermmap3',
version="0.4.19",
author="Michael Axiak, Rob Stacey, Prashant Sinha",
author_email="[email protected]",
url="https://github.com/prashnts/pybloomfiltermmap3",
description="A Bloom filter (bloomfilter) for Python 3 built on mmap",
long_description=long_description,
long_description_content_type='text/markdown',
license="MIT License",
test_suite='tests.test_all',
install_requires=['Cython'],
ext_modules=ext_modules,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: C',
'Programming Language :: Cython',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries :: Python Modules',
],
cmdclass={'build_ext': build_ext}
name="pybloomfiltermmap3",
version="0.4.19",
author="Michael Axiak, Rob Stacey, Prashant Sinha",
author_email="[email protected]",
url="https://github.com/prashnts/pybloomfiltermmap3",
description="A fast implementation of Bloom filter for Python 3 built on mmap",
long_description=long_description,
long_description_content_type="text/markdown",
license="MIT License",
test_suite="tests.test_all",
ext_modules=ext_modules,
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: C",
"Programming Language :: Cython",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules",
],
**setup_kwargs
)

0 comments on commit d0bb10a

Please sign in to comment.