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

Fix broken Cython compilation due to baked C++ files #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions reppy/robots.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# cython: linetrace=True
# cython: language=c++
# distutils: define_macros=CYTHON_TRACE=1

from contextlib import closing
Expand Down
30 changes: 20 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,36 @@
'reppy/rep-cpp/deps/url-cpp/src/psl.cpp'
]

ext_opts = dict(
language='c++',
extra_compile_args=['-std=c++11'],
include_dirs=[
'reppy/rep-cpp/include',
'reppy/rep-cpp/deps/url-cpp/include'
]
)


kwargs = {}

try:
from Cython.Distutils import build_ext
print('Building from Cython')
ext_files.append('reppy/robots.pyx')
from Cython.Build import cythonize

# ensure any baked C++ code is cleaned
extra = ['reppy/robots.pyx']
ext_files += extra

for file in extra:
cythonize(file, force=True, language=ext_opts["language"])
kwargs['cmdclass'] = {'build_ext': build_ext}

except ImportError:
print('Building from C++')
ext_files.append('reppy/robots.cpp')

ext_modules = [
Extension(
'reppy.robots', ext_files,
language='c++',
extra_compile_args=['-std=c++11'],
include_dirs=[
'reppy/rep-cpp/include',
'reppy/rep-cpp/deps/url-cpp/include'])
]
ext_modules = [Extension('reppy.robots', ext_files, **ext_opts)]

setup(
name='reppy',
Expand Down