v1.1.0
This commit is contained in:
193
setup.py
193
setup.py
@@ -6,12 +6,7 @@ from setuptools.command.install import install
|
||||
from setuptools.command.develop import develop
|
||||
from setuptools.command.build_ext import build_ext
|
||||
|
||||
|
||||
def compile_wrapper():
|
||||
"""
|
||||
Compila libbaloo_wrapper.so forzando la ruta de inclusión profunda
|
||||
detectada para KFileMetaData en KF6.
|
||||
"""
|
||||
base_path = os.path.abspath(os.path.dirname(__file__))
|
||||
source_file = os.path.join(base_path, 'baloo_wrapper', 'baloo_wrapper.cpp')
|
||||
output_lib = os.path.join(base_path, 'libbaloo_wrapper.so')
|
||||
@@ -20,37 +15,22 @@ def compile_wrapper():
|
||||
print(f"✘ Error: Source file not found at {source_file}")
|
||||
sys.exit(1)
|
||||
|
||||
# Paquetes para pkg-config (nombres comunes en KF6)
|
||||
packages = [
|
||||
'KF6Baloo',
|
||||
'KF6BalooEngine',
|
||||
'KF6FileMetadata',
|
||||
'KF6CoreAddons',
|
||||
'Qt6Core'
|
||||
]
|
||||
|
||||
packages = ['KF6Baloo', 'KF6BalooEngine', 'KF6FileMetadata', 'KF6CoreAddons', 'Qt6Core']
|
||||
cflags = []
|
||||
libs = []
|
||||
|
||||
print("Detecting KF6 dependencies...")
|
||||
for pkg in packages:
|
||||
try:
|
||||
cf = subprocess.check_output(['pkg-config', '--cflags', pkg],
|
||||
text=True).split()
|
||||
lb = subprocess.check_output(['pkg-config', '--libs', pkg],
|
||||
text=True).split()
|
||||
cf = subprocess.check_output(['pkg-config', '--cflags', pkg], text=True).split()
|
||||
lb = subprocess.check_output(['pkg-config', '--libs', pkg], text=True).split()
|
||||
cflags.extend(cf)
|
||||
libs.extend(lb)
|
||||
print(f" [OK] {pkg}")
|
||||
except subprocess.CalledProcessError:
|
||||
print(f" [!] Warning: pkg-config could not find {pkg}")
|
||||
|
||||
# CONFIGURACIÓN DE RUTAS SEGÚN TU SISTEMA:
|
||||
# Añadimos el nivel intermedio para que <KFileMetaData/ExtractorCollection>
|
||||
# se encuentre en /usr/include/KF6/KFileMetaData/KFileMetaData/
|
||||
extra_includes = [
|
||||
'-I/usr/include/KF6',
|
||||
'-I/usr/include/KF6/KFileMetaData', # Permite resolver KFileMetaData/
|
||||
'-I/usr/include/KF6/KFileMetaData',
|
||||
'-I/usr/include/qt6',
|
||||
'-I/usr/include/qt6/QtCore'
|
||||
]
|
||||
@@ -58,7 +38,6 @@ def compile_wrapper():
|
||||
cflags = list(set(cflags + extra_includes))
|
||||
libs = list(set(libs))
|
||||
|
||||
# Comando de compilación C++17 replicando tu CMakeLists.txt [cite: 1, 2]
|
||||
compile_cmd = [
|
||||
'g++', '-shared', '-o', output_lib,
|
||||
'-fPIC', '-std=c++17',
|
||||
@@ -68,60 +47,158 @@ def compile_wrapper():
|
||||
try:
|
||||
print(f"Executing compilation:\n{' '.join(compile_cmd)}")
|
||||
subprocess.check_call(compile_cmd)
|
||||
|
||||
if os.path.exists(output_lib):
|
||||
print(f"✔ Successfully compiled: {output_lib}")
|
||||
else:
|
||||
raise FileNotFoundError("Compilation finished but .so file is missing.")
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"\n✘ Compilation failed (Exit code {e.returncode}).")
|
||||
print(f"\n✘ Compilation failed.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class CustomInstall(install):
|
||||
def run(self):
|
||||
compile_wrapper()
|
||||
super().run()
|
||||
|
||||
|
||||
class CustomDevelop(develop):
|
||||
def run(self):
|
||||
compile_wrapper()
|
||||
super().run()
|
||||
|
||||
|
||||
class CustomBuildExt(build_ext):
|
||||
def run(self):
|
||||
compile_wrapper()
|
||||
super().run()
|
||||
|
||||
|
||||
# Solo dejamos cmdclass, el resto se lee de pyproject.toml
|
||||
setup(
|
||||
name="bagheerasearch",
|
||||
version="1.0.0",
|
||||
author="Ignacio Serantes",
|
||||
description="Bagheera Search Tool & Lib (KF6/C++17)",
|
||||
py_modules=["bagheerasearch"],
|
||||
package_dir={
|
||||
"": ".",
|
||||
"bagheera_query_parser_lib": "bagheera_query_parser_lib",
|
||||
"bagheera_search_lib": "bagheera_search_lib",
|
||||
"baloo_tools": "baloo_tools",
|
||||
},
|
||||
packages=[
|
||||
"bagheera_query_parser_lib",
|
||||
"bagheera_search_lib",
|
||||
"baloo_tools"
|
||||
],
|
||||
install_requires=["lmdb"],
|
||||
entry_points={'console_scripts': ['bagheerasearch=bagheerasearch:main']},
|
||||
cmdclass={
|
||||
'install': CustomInstall,
|
||||
'develop': CustomDevelop,
|
||||
'build_ext': CustomBuildExt,
|
||||
},
|
||||
data_files=[('lib', ['libbaloo_wrapper.so'])],
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
}
|
||||
)
|
||||
|
||||
# import os
|
||||
# import subprocess
|
||||
# import sys
|
||||
# from setuptools import setup
|
||||
# from setuptools.command.install import install
|
||||
# from setuptools.command.develop import develop
|
||||
# from setuptools.command.build_ext import build_ext
|
||||
#
|
||||
#
|
||||
# def compile_wrapper():
|
||||
# """
|
||||
# Compila libbaloo_wrapper.so forzando la ruta de inclusión profunda
|
||||
# detectada para KFileMetaData en KF6.
|
||||
# """
|
||||
# base_path = os.path.abspath(os.path.dirname(__file__))
|
||||
# source_file = os.path.join(base_path, 'baloo_wrapper', 'baloo_wrapper.cpp')
|
||||
# output_lib = os.path.join(base_path, 'libbaloo_wrapper.so')
|
||||
#
|
||||
# if not os.path.exists(source_file):
|
||||
# print(f"✘ Error: Source file not found at {source_file}")
|
||||
# sys.exit(1)
|
||||
#
|
||||
# # Paquetes para pkg-config (nombres comunes en KF6)
|
||||
# packages = [
|
||||
# 'KF6Baloo',
|
||||
# 'KF6BalooEngine',
|
||||
# 'KF6FileMetadata',
|
||||
# 'KF6CoreAddons',
|
||||
# 'Qt6Core'
|
||||
# ]
|
||||
#
|
||||
# cflags = []
|
||||
# libs = []
|
||||
#
|
||||
# print("Detecting KF6 dependencies...")
|
||||
# for pkg in packages:
|
||||
# try:
|
||||
# cf = subprocess.check_output(['pkg-config', '--cflags', pkg],
|
||||
# text=True).split()
|
||||
# lb = subprocess.check_output(['pkg-config', '--libs', pkg],
|
||||
# text=True).split()
|
||||
# cflags.extend(cf)
|
||||
# libs.extend(lb)
|
||||
# print(f" [OK] {pkg}")
|
||||
# except subprocess.CalledProcessError:
|
||||
# print(f" [!] Warning: pkg-config could not find {pkg}")
|
||||
#
|
||||
# # CONFIGURACIÓN DE RUTAS SEGÚN TU SISTEMA:
|
||||
# # Añadimos el nivel intermedio para que <KFileMetaData/ExtractorCollection>
|
||||
# # se encuentre en /usr/include/KF6/KFileMetaData/KFileMetaData/
|
||||
# extra_includes = [
|
||||
# '-I/usr/include/KF6',
|
||||
# '-I/usr/include/KF6/KFileMetaData', # Permite resolver KFileMetaData/
|
||||
# '-I/usr/include/qt6',
|
||||
# '-I/usr/include/qt6/QtCore'
|
||||
# ]
|
||||
#
|
||||
# cflags = list(set(cflags + extra_includes))
|
||||
# libs = list(set(libs))
|
||||
#
|
||||
# # Comando de compilación C++17 replicando tu CMakeLists.txt [cite: 1, 2]
|
||||
# compile_cmd = [
|
||||
# 'g++', '-shared', '-o', output_lib,
|
||||
# '-fPIC', '-std=c++17',
|
||||
# source_file
|
||||
# ] + cflags + libs
|
||||
#
|
||||
# try:
|
||||
# print(f"Executing compilation:\n{' '.join(compile_cmd)}")
|
||||
# subprocess.check_call(compile_cmd)
|
||||
#
|
||||
# if os.path.exists(output_lib):
|
||||
# print(f"✔ Successfully compiled: {output_lib}")
|
||||
# else:
|
||||
# raise FileNotFoundError("Compilation finished but .so file is missing.")
|
||||
#
|
||||
# except subprocess.CalledProcessError as e:
|
||||
# print(f"\n✘ Compilation failed (Exit code {e.returncode}).")
|
||||
# sys.exit(1)
|
||||
#
|
||||
#
|
||||
# class CustomInstall(install):
|
||||
# def run(self):
|
||||
# compile_wrapper()
|
||||
# super().run()
|
||||
#
|
||||
#
|
||||
# class CustomDevelop(develop):
|
||||
# def run(self):
|
||||
# compile_wrapper()
|
||||
# super().run()
|
||||
#
|
||||
#
|
||||
# class CustomBuildExt(build_ext):
|
||||
# def run(self):
|
||||
# compile_wrapper()
|
||||
# super().run()
|
||||
#
|
||||
#
|
||||
# setup(
|
||||
# name="bagheerasearch",
|
||||
# version="1.0.0",
|
||||
# author="Ignacio Serantes",
|
||||
# description="Bagheera Search Tool & Lib (KF6/C++17)",
|
||||
# py_modules=["bagheerasearch"],
|
||||
# package_dir={
|
||||
# "": ".",
|
||||
# "bagheera_query_parser_lib": "bagheera_query_parser_lib",
|
||||
# "bagheera_search_lib": "bagheera_search_lib",
|
||||
# "baloo_tools": "baloo_tools",
|
||||
# },
|
||||
# packages=[
|
||||
# "bagheera_query_parser_lib",
|
||||
# "bagheera_search_lib",
|
||||
# "baloo_tools"
|
||||
# ],
|
||||
# install_requires=["lmdb"],
|
||||
# entry_points={'console_scripts': ['bagheerasearch=bagheerasearch:main']},
|
||||
# cmdclass={
|
||||
# 'install': CustomInstall,
|
||||
# 'develop': CustomDevelop,
|
||||
# 'build_ext': CustomBuildExt,
|
||||
# },
|
||||
# data_files=[('lib', ['libbaloo_wrapper.so'])],
|
||||
# include_package_data=True,
|
||||
# zip_safe=False,
|
||||
# )
|
||||
|
||||
Reference in New Issue
Block a user