@@ -1677,6 +1677,34 @@ def create_requirements_json(
16771677 item [0 ] for item in package_and_version if not item [1 ]
16781678 ]
16791679
1680+
1681+ IMPORT_TO_INSTALL_MAPPING = {
1682+ # Data Science & ML Core
1683+ "sklearn" : "scikit-learn" ,
1684+ "skimage" : "scikit-image" ,
1685+ "cv2" : "opencv-python" ,
1686+ "PIL" : "Pillow" ,
1687+ # Data Formats & Parsing
1688+ "yaml" : "PyYAML" ,
1689+ "bs4" : "beautifulsoup4" ,
1690+ "docx" : "python-docx" ,
1691+ "pptx" : "python-pptx" ,
1692+ # Date & Time Utilities
1693+ "dateutil" : "python-dateutil" ,
1694+ # Database Connectors
1695+ "MySQLdb" : "MySQL-python" ,
1696+ "psycopg2" : "psycopg2-binary" ,
1697+ # System & Platform
1698+ "win32api" : "pywin32" ,
1699+ "win32com" : "pywin32" ,
1700+ # Scientific Libraries
1701+ "Bio" : "biopython" ,
1702+ }
1703+
1704+ # Map import names to their corresponding package installation names
1705+ package_and_version = [
1706+ (IMPORT_TO_INSTALL_MAPPING .get (name , name ), version ) for name , version in package_and_version
1707+ ]
16801708
16811709 if create_requirements_txt :
16821710 requirements_txt = ""
@@ -1752,37 +1780,11 @@ def package_not_found_output(package_name, package_versions):
17521780 package_versions .append ([package_name , None ])
17531781 return package_versions
17541782
1755-
1756- IMPORT_TO_INSTALL_MAPPING = {
1757- # Data Science & ML Core
1758- "sklearn" : "scikit-learn" ,
1759- "skimage" : "scikit-image" ,
1760- "cv2" : "opencv-python" ,
1761- "PIL" : "Pillow" ,
1762- # Data Formats & Parsing
1763- "yaml" : "PyYAML" ,
1764- "bs4" : "beautifulsoup4" ,
1765- "docx" : "python-docx" ,
1766- "pptx" : "python-pptx" ,
1767- # Date & Time Utilities
1768- "dateutil" : "python-dateutil" ,
1769- # Database Connectors
1770- "MySQLdb" : "MySQL-python" ,
1771- "psycopg2" : "psycopg2-binary" ,
1772- # System & Platform
1773- "win32api" : "pywin32" ,
1774- "win32com" : "pywin32" ,
1775- # Scientific Libraries
1776- "Bio" : "biopython" ,
1777- }
1778-
17791783 package_and_version = []
17801784
17811785 for package in package_list :
17821786 try :
17831787 name = importlib .import_module (package )
1784- package = IMPORT_TO_INSTALL_MAPPING .get (package , package )
1785-
17861788 try :
17871789 package_and_version .append ([package , name .__version__ ])
17881790 except AttributeError :
0 commit comments