raksa-the-wildcats commited on
Commit
d6f01a3
·
1 Parent(s): b8b1a1f

7th commit

Browse files
Files changed (3) hide show
  1. Dockerfile +34 -0
  2. app.py +27 -0
  3. requirements.txt +6 -14
Dockerfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Install system dependencies required for Manim
4
+ RUN apt-get update && apt-get install -y \
5
+ libcairo2-dev \
6
+ libpango1.0-dev \
7
+ libgirepository1.0-dev \
8
+ libxml2-dev \
9
+ libxslt1-dev \
10
+ libffi-dev \
11
+ libssl-dev \
12
+ pkg-config \
13
+ build-essential \
14
+ ffmpeg \
15
+ git \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Set working directory
19
+ WORKDIR /app
20
+
21
+ # Copy requirements first for better caching
22
+ COPY requirements.txt .
23
+
24
+ # Install Python dependencies
25
+ RUN pip install --no-cache-dir -r requirements.txt
26
+
27
+ # Copy application code
28
+ COPY . .
29
+
30
+ # Expose port
31
+ EXPOSE 7860
32
+
33
+ # Run the application
34
+ CMD ["python", "paste.txt"]
app.py CHANGED
@@ -49,9 +49,36 @@ class ManimAnimationGenerator:
49
 
50
  return True, "Code validation passed"
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  def install_manim(self):
53
  """Try to install Manim if not available"""
54
  try:
 
 
 
 
 
 
55
  subprocess.check_call([
56
  sys.executable, "-m", "pip", "install",
57
  "manim", "manimpango", "--quiet"
 
49
 
50
  return True, "Code validation passed"
51
 
52
+ def install_system_dependencies(self):
53
+ """Install required system dependencies"""
54
+ try:
55
+ # Install system dependencies for Manim
56
+ subprocess.check_call([
57
+ "apt-get", "update"
58
+ ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
59
+
60
+ subprocess.check_call([
61
+ "apt-get", "install", "-y",
62
+ "libcairo2-dev", "libpango1.0-dev", "libgirepository1.0-dev",
63
+ "libxml2-dev", "libxslt1-dev", "libffi-dev", "libssl-dev",
64
+ "pkg-config", "build-essential"
65
+ ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
66
+
67
+ return True, "System dependencies installed"
68
+ except subprocess.CalledProcessError as e:
69
+ return False, f"Failed to install system dependencies: {str(e)}"
70
+ except Exception as e:
71
+ return False, f"Error installing dependencies: {str(e)}"
72
+
73
  def install_manim(self):
74
  """Try to install Manim if not available"""
75
  try:
76
+ # First install system dependencies
77
+ sys_success, sys_msg = self.install_system_dependencies()
78
+ if not sys_success:
79
+ return False, sys_msg
80
+
81
+ # Then install Manim
82
  subprocess.check_call([
83
  sys.executable, "-m", "pip", "install",
84
  "manim", "manimpango", "--quiet"
requirements.txt CHANGED
@@ -1,14 +1,6 @@
1
- ffmpeg
2
- libcairo2-dev
3
- libpango1.0-dev
4
- libgdk-pixbuf2.0-dev
5
- libffi-dev
6
- build-essential
7
- pkg-config
8
- libpangocairo-1.0-0
9
- libcairo-gobject2
10
- libpango-1.0-0
11
- libgdk-pixbuf2.0-0
12
- libharfbuzz0b
13
- libfribidi0
14
- libfontconfig1
 
1
+ gradio>=4.0.0
2
+ manim
3
+ manimpango
4
+ numpy
5
+ matplotlib
6
+ Pillow