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

Provide the ability to link to system simdjson #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
68 changes: 37 additions & 31 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,53 +27,59 @@
os.environ.setdefault('MACOSX_DEPLOYMENT_TARGET', '10.14')
extra_compile_args.append('-std=c++11')

if os.getenv('BUILD_WITH_CYTHON') and not CYTHON_AVAILABLE:
build_with_cython = os.getenv('BUILD_WITH_CYTHON')
if build_with_cython and not CYTHON_AVAILABLE:
print(
'BUILD_WITH_CYTHON environment variable is set, but cython'
' is not available. Falling back to pre-cythonized version if'
' available.'
)
build_with_cython = False

if os.getenv('BUILD_WITH_CYTHON') and CYTHON_AVAILABLE:
macros = []
compiler_directives = {
'embedsignature': True
}
build_with_system_lib = os.getenv('BUILD_WITH_SYSTEM_LIB')

macros = []
compiler_directives = {}
libraries = []
sources = [
'simdjson/errors.cpp',
]

if build_with_system_lib:
libraries.append('simdjson')
else:
sources.append('simdjson/simdjson.cpp')

if build_with_cython:
compiler_directives['embedsignature'] = True

if os.getenv('BUILD_FOR_DEBUG'):
# Enable line tracing, which also enables support for coverage
# reporting.
macros = [
macros += [
('CYTHON_TRACE', 1),
('CYTHON_TRACE_NOGIL', 1)
]
compiler_directives['linetrace'] = True

extensions = cythonize([
Extension(
'csimdjson',
[
'simdjson/simdjson.cpp',
'simdjson/errors.cpp',
'simdjson/csimdjson.pyx'
],
define_macros=macros,
extra_compile_args=extra_compile_args
)
], compiler_directives=compiler_directives)
sources.append('simdjson/csimdjson.pyx')
else:
extensions = [
Extension(
'csimdjson',
[
'simdjson/simdjson.cpp',
'simdjson/errors.cpp',
'simdjson/csimdjson.cpp'
],
extra_compile_args=extra_compile_args,
language='c++'
)
]
sources.append('simdjson/csimdjson.cpp')


extensions = [
Extension(
'csimdjson',
sources,
define_macros=macros,
extra_compile_args=extra_compile_args,
libraries=libraries,
language='c++',
)
]

if build_with_cython:
extensions = cythonize(extensions, compiler_directives=compiler_directives)

setup(
name='pysimdjson',
Expand Down