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

Making the package detect an existing installation of spdlog #19

Open
mdorier opened this issue Dec 15, 2019 · 0 comments
Open

Making the package detect an existing installation of spdlog #19

mdorier opened this issue Dec 15, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mdorier
Copy link

mdorier commented Dec 15, 2019

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.

@bodgergely bodgergely added the enhancement New feature or request label Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants