euler314 commited on
Commit
3d207f4
·
verified ·
1 Parent(s): 250a80c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -20
Dockerfile CHANGED
@@ -1,36 +1,37 @@
1
- FROM python:3.9
2
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
- cmake \
9
  python3-dev \
10
  libeigen3-dev \
11
  python3-pybind11 \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Debug: List installed packages
15
- RUN python -m pip list
16
-
17
- # Copy all files at once to maintain relationships
18
- COPY . .
19
-
20
- # Install Python dependencies
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
- # Build the C++ extension with verbose output
24
- RUN python -m pip install -e . --verbose
25
-
26
- # Verify the extension exists after building
27
- RUN python -c "import os; print('Contents of directory:'); print(os.listdir('.')); \
28
- print('Looking for .so files:'); print([f for f in os.listdir('.') if f.endswith('.so')]); \
29
- print('Python path:'); import sys; print(sys.path)"
30
-
31
- # Check if the module can be imported
32
- RUN python -c "try: import cubic_cpp; print('✓ Successfully imported cubic_cpp'); \
33
- except ImportError as e: print(f'✗ Import failed: {e}')"
 
 
 
 
 
 
 
34
 
35
  # Run the application
36
  CMD ["streamlit", "run", "app.py"]
 
1
+ FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
 
8
  python3-dev \
9
  libeigen3-dev \
10
  python3-pybind11 \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Copy files
14
+ COPY requirements.txt .
 
 
 
 
 
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
+ # Copy C++ source and app
18
+ COPY cubic_cpp.cpp app.py ./
19
+
20
+ # Get Python and pybind11 include paths directly
21
+ RUN PYTHON_INCLUDE_PATH=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))") && \
22
+ PYBIND11_INCLUDE_PATH=$(python3 -c "import pybind11; print(pybind11.get_include())") && \
23
+ NUMPY_INCLUDE_PATH=$(python3 -c "import numpy; print(numpy.get_include())") && \
24
+ # Compile the C++ module directly to a shared library
25
+ g++ -O3 -Wall -shared -std=c++11 -fPIC \
26
+ $(python3-config --includes) \
27
+ -I${PYBIND11_INCLUDE_PATH} \
28
+ -I${NUMPY_INCLUDE_PATH} \
29
+ cubic_cpp.cpp \
30
+ -o cubic_cpp$(python3-config --extension-suffix) && \
31
+ # Verify the module was created
32
+ ls -la && \
33
+ # Test the import
34
+ python3 -c "import cubic_cpp; print('C++ module imported successfully')"
35
 
36
  # Run the application
37
  CMD ["streamlit", "run", "app.py"]