# HCFS Python Development Environment
FROM bzzz-hcfs-base:latest

LABEL maintainer="anthony@deepblack.cloud"
LABEL description="HCFS Python development environment with ML/AI tools"
LABEL language="python"
LABEL version="1.0.0"

# Install Python development tools
RUN apt-get update && apt-get install -y \
    # Python build dependencies
    python3-dev \
    python3-wheel \
    python3-setuptools \
    # Data science libraries dependencies
    libhdf5-dev \
    libnetcdf-dev \
    libopenblas-dev \
    liblapack-dev \
    gfortran \
    # ML/AI library dependencies
    libgraphviz-dev \
    graphviz \
    # Image processing
    libjpeg-dev \
    libpng-dev \
    libtiff-dev \
    # Additional development tools
    python3-ipython \
    jupyter-core \
    # Testing tools
    python3-pytest \
    && rm -rf /var/lib/apt/lists/*

# Install comprehensive Python package ecosystem
RUN pip install --no-cache-dir \
    # Core development
    ipython \
    jupyter \
    jupyterlab \
    notebook \
    # Web frameworks
    flask \
    fastapi \
    django \
    starlette \
    # Data science and ML
    numpy \
    pandas \
    scipy \
    scikit-learn \
    matplotlib \
    seaborn \
    plotly \
    # Deep learning
    torch \
    torchvision \
    transformers \
    # NLP
    nltk \
    spacy \
    sentence-transformers \
    # API and HTTP
    requests \
    httpx \
    aiohttp \
    # Database
    sqlalchemy \
    psycopg2-binary \
    sqlite3 \
    # Configuration and serialization
    pyyaml \
    toml \
    configparser \
    # CLI tools
    click \
    typer \
    rich \
    # Testing
    pytest \
    pytest-asyncio \
    pytest-cov \
    # Code quality
    black \
    flake8 \
    mypy \
    pylint \
    # Documentation
    sphinx \
    mkdocs \
    # Async programming
    asyncio \
    aiofiles \
    # Development utilities
    python-dotenv \
    tqdm \
    loguru

# Install HCFS Python SDK
COPY hcfs-python-sdk /opt/hcfs/python-sdk
RUN cd /opt/hcfs/python-sdk && pip install -e .

# Create development workspace structure
RUN sudo -u agent mkdir -p /home/agent/work/{src,tests,docs,notebooks,data,models,scripts}

# Set up Python-specific environment
ENV PYTHONPATH=/home/agent/work/src:/opt/hcfs/python-sdk:$PYTHONPATH
ENV JUPYTER_CONFIG_DIR=/home/agent/.jupyter
ENV JUPYTER_DATA_DIR=/home/agent/.local/share/jupyter

# Create Jupyter configuration
RUN sudo -u agent mkdir -p /home/agent/.jupyter && \
    sudo -u agent bash -c 'cat > /home/agent/.jupyter/jupyter_notebook_config.py << EOF
c.NotebookApp.ip = "0.0.0.0"
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
c.NotebookApp.token = ""
c.NotebookApp.password = ""
c.NotebookApp.notebook_dir = "/home/agent/work"
c.NotebookApp.allow_root = False
EOF'

# Python-specific HCFS integration script
COPY scripts/python-hcfs-init.py /opt/hcfs/scripts/
RUN chmod +x /opt/hcfs/scripts/python-hcfs-init.py

# Expose common Python development ports
EXPOSE 8888 8000 5000 8080

# Set Python as the default environment
ENV SHELL=/bin/bash
ENV PYTHON_ENV=development

# Add Python-specific entrypoint
COPY scripts/python-entrypoint.sh /opt/hcfs/
RUN chmod +x /opt/hcfs/python-entrypoint.sh

ENTRYPOINT ["/opt/hcfs/python-entrypoint.sh"]
CMD ["python"]