from setuptools import setup, find_packages
import os
import xml.etree.ElementTree as ET

def get_version_from_pom():
    """Parse version from pom.xml"""
    here = os.path.abspath(os.path.dirname(__file__))
    pom_path = os.path.join(here, 'thrift_model', 'pom.xml')
    tree = ET.parse(pom_path)
    root = tree.getroot()
    
    # XML namespaces
    ns = {'mvn': 'http://maven.apache.org/POM/4.0.0'}
    
    version = root.find('mvn:version', ns).text
    if version.endswith('-SNAPSHOT'):
        version = version.replace('-SNAPSHOT', '.dev0')
    return version

setup(
    name='yt_ops_services',
    version=get_version_from_pom(),
    # find_packages() will now discover 'pangramia' via the symlink.
    # 'server_fix' is excluded as it's no longer needed.
    packages=find_packages(exclude=['tests*', 'server_fix']),
    # package_data is not needed for pom.xml as it's only used at build time.
    include_package_data=True,
    # Add all dependencies from requirements.txt
    install_requires=[
        'thrift>=0.16.0,<=0.20.0',
        'python-dotenv>=1.0.0',
        'psutil',
        'flask',
        'waitress',
        'yt_dlp>=2025.3.27',
        'yt-dlp-get-pot==0.3.0',
        'requests>=2.31.0',
        'ffprobe3',
        'redis',
        'PySocks',
    ],
    python_requires='>=3.9',
)
