Skip to content

Commit

Permalink
Use Cython only if explicitly specified
Browse files Browse the repository at this point in the history
  • Loading branch information
mizvyt committed Dec 3, 2019
1 parent bbfbdcc commit 350e42f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ before_install:
- pip install cython
script:
- cd $TRAVIS_BUILD_DIR
- python setup.py test
- python setup.py test --cython
18 changes: 9 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@
"src/MurmurHash3.c",
]

# Branch out based on `--no-cython` in `argv`.
# Assume `--cython` as default to avoid having to deal with both params being there.
# Branch out based on `--cython` in `argv`.
# Assume no `--cython` as default.

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:
if "--cython" in sys.argv:
# 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'."
"source code, simply run 'python setup.py install'."
)
sys.exit(1)

ext_files.append("src/pybloomfilter.pyx")
setup_kwargs["cmdclass"] = {"build_ext": build_ext}
sys.argv.remove("--cython")
else:
# Use `pybloomfilter.c` distributed with the package.
# Note that we let the exception bubble up if `pybloomfilter.c` doesn't exist.
ext_files.append("src/pybloomfilter.c")

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

Expand Down

0 comments on commit 350e42f

Please sign in to comment.