Camais03 commited on
Commit
64981cc
·
verified ·
1 Parent(s): 9ae9d32

Upload setup.py

Browse files

Python Version Incompatability

Files changed (1) hide show
  1. camie-tagger/app/setup.py +57 -5
camie-tagger/app/setup.py CHANGED
@@ -4,6 +4,23 @@ Setup script for the Image Tagger application.
4
  This script checks and installs all required dependencies.
5
  """
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  import os
8
  import sys
9
  import subprocess
@@ -67,7 +84,7 @@ def print_colored(text, color):
67
  print(f"{color}{text}{Colors.ENDC}")
68
 
69
  def check_python_version():
70
- """Check if Python version is 3.8 or higher"""
71
  print_colored("Checking Python version...", Colors.BLUE)
72
 
73
  version = sys.version_info
@@ -78,10 +95,44 @@ def check_python_version():
78
 
79
  print_colored(f"[OK] Python {version.major}.{version.minor}.{version.micro} detected", Colors.GREEN)
80
 
81
- # Add specific warning for Python 3.12+ about distutils
82
- if version.major == 3 and version.minor >= 12:
83
- print_colored("Notice: Python 3.12+ detected. distutils is no longer included in the standard library.", Colors.WARNING)
84
- print_colored("This script will install setuptools-distutils to address this.", Colors.WARNING)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
  return True
87
 
@@ -399,6 +450,7 @@ def main():
399
  """Main setup function"""
400
  print_colored("=" * 60, Colors.HEADER)
401
  print_colored(" Image Tagger - Setup Script", Colors.HEADER)
 
402
  print_colored("=" * 60, Colors.HEADER)
403
 
404
  # Check Python version
 
4
  This script checks and installs all required dependencies.
5
  """
6
 
7
+ # Python 3.12+ compatibility patch for pkgutil.ImpImporter
8
+ import sys
9
+ if sys.version_info >= (3, 12):
10
+ import pkgutil
11
+ import importlib.machinery
12
+
13
+ # Add ImpImporter as a compatibility shim for older packages
14
+ if not hasattr(pkgutil, 'ImpImporter'):
15
+ class ImpImporter:
16
+ def __init__(self, path=None):
17
+ self.path = path
18
+
19
+ def find_module(self, fullname, path=None):
20
+ return None
21
+
22
+ pkgutil.ImpImporter = ImpImporter
23
+
24
  import os
25
  import sys
26
  import subprocess
 
84
  print(f"{color}{text}{Colors.ENDC}")
85
 
86
  def check_python_version():
87
+ """Check if Python version is 3.8 or higher, recommend 3.11.9 specifically"""
88
  print_colored("Checking Python version...", Colors.BLUE)
89
 
90
  version = sys.version_info
 
95
 
96
  print_colored(f"[OK] Python {version.major}.{version.minor}.{version.micro} detected", Colors.GREEN)
97
 
98
+ # Recommend Python 3.11.9 specifically
99
+ if version.major == 3 and (version.minor != 11 or version.micro != 9):
100
+ recommended = False
101
+ warning_color = Colors.WARNING
102
+
103
+ # Extra warning for Python 3.12+ due to known compatibility issues
104
+ if version.major == 3 and version.minor >= 12:
105
+ print_colored("WARNING: Python 3.12+ has known compatibility issues with this application.", Colors.FAIL)
106
+ print_colored("The application has been tested and works reliably with Python 3.11.9.", Colors.FAIL)
107
+ warning_color = Colors.FAIL
108
+ recommended = True
109
+ elif version.major == 3 and version.minor == 11 and version.micro != 9:
110
+ print_colored("Note: This application has been tested with Python 3.11.9 specifically.", Colors.WARNING)
111
+ recommended = True
112
+ else:
113
+ print_colored("Note: This application is recommended to use Python 3.11.9.", Colors.WARNING)
114
+ recommended = True
115
+
116
+ if recommended:
117
+ print_colored("Download Python 3.11.9:", warning_color)
118
+ if sys.platform == "win32":
119
+ print_colored(" https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe", warning_color)
120
+ elif sys.platform == "darwin": # macOS
121
+ print_colored(" https://www.python.org/ftp/python/3.11.9/python-3.11.9-macos11.pkg", warning_color)
122
+ else: # Linux
123
+ print_colored(" https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz", warning_color)
124
+ print_colored(" Or use your distribution's package manager", warning_color)
125
+
126
+ if version.major == 3 and version.minor >= 12:
127
+ # For Python 3.12+, we'll still continue but with a confirmation
128
+ print_colored("\nDo you want to continue with the current Python version? (y/n)", Colors.BLUE)
129
+ response = input().strip().lower()
130
+ if response != 'y' and response != 'yes':
131
+ print_colored("Setup aborted. Please install Python 3.11.9 and try again.", Colors.FAIL)
132
+ return False
133
+ print_colored("Continuing with current Python version. Some features may not work correctly.", Colors.WARNING)
134
+ else:
135
+ print_colored("[PERFECT] Python 3.11.9 detected - this is the recommended version!", Colors.GREEN)
136
 
137
  return True
138
 
 
450
  """Main setup function"""
451
  print_colored("=" * 60, Colors.HEADER)
452
  print_colored(" Image Tagger - Setup Script", Colors.HEADER)
453
+ print_colored(" (Recommended: Python 3.11.9)", Colors.HEADER)
454
  print_colored("=" * 60, Colors.HEADER)
455
 
456
  # Check Python version