Spaces:
Running
Running
File size: 1,189 Bytes
3d207f4 ef64d6b 6102449 ef64d6b 9264e00 6102449 9264e00 ef64d6b 3d207f4 ef64d6b 3d207f4 9a06845 6102449 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
FROM python:3.9-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
python3-dev \
libeigen3-dev \
python3-pybind11 \
&& rm -rf /var/lib/apt/lists/*
# Copy files
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy C++ source and app
COPY cubic_cpp.cpp app.py ./
# Get Python and pybind11 include paths directly
RUN PYTHON_INCLUDE_PATH=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))") && \
PYBIND11_INCLUDE_PATH=$(python3 -c "import pybind11; print(pybind11.get_include())") && \
NUMPY_INCLUDE_PATH=$(python3 -c "import numpy; print(numpy.get_include())") && \
# Compile the C++ module directly to a shared library
g++ -O3 -Wall -shared -std=c++11 -fPIC \
$(python3-config --includes) \
-I${PYBIND11_INCLUDE_PATH} \
-I${NUMPY_INCLUDE_PATH} \
cubic_cpp.cpp \
-o cubic_cpp$(python3-config --extension-suffix) && \
# Verify the module was created
ls -la && \
# Test the import
python3 -c "import cubic_cpp; print('C++ module imported successfully')"
# Run the application
CMD ["streamlit", "run", "app.py"] |