import os
from setuptools import setup
from setuptools.command.install import install
from pathlib import Path

class PostInstallCommand(install):
    """Kurulum sonrası KernelLock'ı IPython başlangıç dizinine mühürler."""
    def run(self):
        install.run(self)
        try:
            startup_dir = Path("~/.ipython/profile_default/startup").expanduser()
            startup_dir.mkdir(parents=True, exist_ok=True)
            hook_file = startup_dir / "00_kernellock.py"
            with open(hook_file, "w") as f:
                f.write("import kernellock\nkernellock.activate()\n")
            print(f"✅ KernelLock IPython Startup Hook oluşturuldu: {hook_file}")
        except Exception as e:
            print(f"⚠️ Startup Hook yazılamadı (IPython ortamı olmayabilir): {e}")

with open("README.md", "r", encoding="utf-8") as fh:
    long_description = fh.read()

setup(
    name="kernellock",
    version="1.0.0",
    author="Ömür bera ışık/FastLoRA",
    author_email="fastloraoffical@gmail.com",
    description="Prevents Jupyter/Kaggle/Colab kernel restarts and OS-level kills seamlessly.",
    long_description=long_description,
    long_description_content_type="text/markdown",
 
    py_modules=["kernellock"], # Tekil kernellock.py dosyasını modül olarak alır
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
        "Topic :: Scientific/Engineering :: Artificial Intelligence",
    ],
    python_requires='>=3.6',
    cmdclass={
        'install': PostInstallCommand,
    },
)