spdlog-python
spdlog-python copied to clipboard
Making the package detect an existing installation of spdlog
It would be good if, instead of relying on a submodule, this package could detect an existing installation of spdlog. Such an installation can be detected for instance using Python's pkgconfig package, with something like the following:
try:
import pkgconfig
spdlog_pkgconfig = pkgconfig.parse('spdlog')
except:
spdlog_pkgconfig = None
if spdlog_pkgconfig is None:
spdlog_include_dirs = ['spdlog/include']
spdlog_library_dirs = []
spdlog_libraries = []
headers_to_install = include_dir_files('spdlog/include/spdlog')
else:
spdlog_include_dirs = spdlog_pkgconfig['include_dirs']
spdlog_library_dirs = spdlog_pkgconfig['library_dirs']
spdlog_libraries = spdlog_pkgconfig['libraries']
headers_to_install = []
And updating the setup
function as follows:
setup(
name='spdlog',
version='2.0.0',
author='Gergely Bod',
author_email='[email protected]',
description='python wrapper around C++ spdlog logging library (https://github.com/bodgergely/spdlog-python)',
license='MIT',
long_description='python wrapper (https://github.com/bodgergely/spdlog-python) around C++ spdlog (http://github.com/gabime/spdlog.git) logging library.',
setup_requires=['pytest-runner'],
install_requires=['pybind11>=2.2'],
tests_require=['pytest'],
ext_modules=[
Extension(
'spdlog',
['src/pyspdlog.cpp'],
include_dirs = spdlog_include_dirs + [
get_pybind_include(),
get_pybind_include(user=True)
],
library_dirs = spdlog_library_dirs,
libraries = spdlog_libraries + ['stdc++'],
extra_compile_args=["-std=c++11", "-v"],
language='c++11'
)
],
headers=headers_to_install,
cmdclass={'install_headers': install_headers_subdir},
zip_safe=False,
)
Right now this is not fully functional, as it seems spdlog-python uses spdlog 1.3.1. I have tried with spdlog 1.4.1 but I get build errors so it would seem the spdlog API has changed between 1.3.1 and 1.4.1.