# Copyright (c) 2014-2026 Savoir-faire Linux Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from setuptools import setup, Extension, find_packages from setuptools.command.build_ext import build_ext as _build_ext import os with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.md'), 'r', encoding='utf-8') as f: long_description = f.read() extra_compile_args = { 'msvc': ['/std:c++17', '/EHsc', '/utf-8'], 'unix': ['-std=c++17'], } extra_link_args = { 'msvc': ['wsock32.lib', 'ws2_32.lib'], 'unix': ['-std=c++17'] } extra_libraries = { 'msvc': ['opendht_import', 'gnutls'], 'unix': ['opendht'] } class build_ext(_build_ext): def build_extensions(self): compile_args = extra_compile_args.get(self.compiler.compiler_type, []) link_args = extra_link_args.get(self.compiler.compiler_type, []) libraries = extra_libraries.get(self.compiler.compiler_type, ['opendht']) for ext in self.extensions: ext.extra_compile_args.extend(compile_args) ext.extra_link_args.extend(link_args) ext.libraries = libraries super().build_extensions() setup(name="opendht", version="@PACKAGE_VERSION@", description="OpenDHT: A lightweight Distributed Hash Table", long_description=long_description, long_description_content_type="text/markdown", url='https://github.com/savoirfairelinux/opendht', author="Adrien Beraud ", license="GPL-3.0-or-later", classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: System :: Distributed Computing', 'Topic :: System :: Networking', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.9', ], cmdclass=dict(build_ext=build_ext), packages=find_packages(where='@CURRENT_SOURCE_DIR@'), package_dir={"": "@CURRENT_SOURCE_DIR@"}, ext_modules=[Extension( "opendht._core", ["@CURRENT_SOURCE_DIR@/opendht.pyx"], language="c++", extra_compile_args=["-DMSGPACK_NO_BOOST", "-DMSGPACK_DISABLE_LEGACY_NIL", "-DMSGPACK_DISABLE_LEGACY_CONVERT", "-DOPENDHT_INDEXATION", "-Dopendht_EXPORTS"], libraries=["opendht", "gnutls"], include_dirs = ['@PROJECT_SOURCE_DIR@/include'@OPENDHT_PYTHON_INCLUDE_DIRS@], library_dirs = ['@CURRENT_BINARY_DIR@', '@PROJECT_BINARY_DIR@'@OPENDHT_PYTHON_LIBRARY_DIRS@] )] )