Ctrl K
ComunidadGuías…

setup.py

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
#!/usr/bin/env python3

import re
from setuptools import setup, find_packages
from setuptools.command.bdist_wheel import bdist_wheel
import os
from pathlib import Path
import subprocess
import sys
import atexit

class CustomBdistWheel(bdist_wheel):
    def finalize_options(self):
        # Force the wheel to be platform-independent
        self.root_is_pure = True
        # Ensure the wheel is tagged as py3-none-any
        self.plat_name_supplied = True
        self.plat_name = "any"
        bdist_wheel.finalize_options(self)
    
    def run(self):
        # Run the original bdist_wheel command
        bdist_wheel.run(self)
        
        # Register the post-build hook to run when the script exits
        atexit.register(run_post_build)

def run_post_build():
    """Run the post-build script after the build is complete."""
    # Find the post-build script
    script_path = os.path.join('scripts', 'post_build.py')
    
    if os.path.exists(script_path):
        print(f"\nRunning post-build script: {script_path}")
        subprocess.run([sys.executable, script_path], check=True)
        print("Post-build script completed successfully")
    else:
        print(f"\nERROR: Post-build script not found at {script_path}")


def _read_version() -> str:
    """Read version from pyproject.toml — single source of truth."""
    pyproject = Path(__file__).parent / "pyproject.toml"
    content = pyproject.read_text(encoding="utf-8")
    match = re.search(r'^version\s*=\s*"([^"]+)"', content, re.MULTILINE)
    if not match:
        raise RuntimeError("Could not find version in pyproject.toml")
    return match.group(1)


# setup.py exists solely for the custom bdist_wheel command class.
# Version is read from pyproject.toml to avoid duplication.
setup(
    name="ziya",
    version=_read_version(),
    author="Dan Cohn, Vishnu Krishnaprasad",
    author_email="chroma@gmail.com",
    packages=find_packages(include=["app", "app.*", "mcp_servers", "app.mcp_servers.*"]),
    include_package_data=True,
    zip_safe=False,
    python_requires=">=3.10,<3.15",
    cmdclass={
        'bdist_wheel': CustomBdistWheel,
    },
)