@@ -1671,37 +1671,12 @@ def create_requirements_json(
16711671 package_list = list (set (list (_flatten (package_list ))))
16721672 package_list = cls .remove_standard_library_packages (package_list )
16731673 package_and_version = cls .get_local_package_version (package_list )
1674+
16741675 # Identify packages with missing versions
16751676 missing_package_versions = [
16761677 item [0 ] for item in package_and_version if not item [1 ]
16771678 ]
16781679
1679- IMPORT_TO_INSTALL_MAPPING = {
1680- # Data Science & ML Core
1681- "sklearn" : "scikit-learn" ,
1682- "skimage" : "scikit-image" ,
1683- "cv2" : "opencv-python" ,
1684- "PIL" : "Pillow" ,
1685- # Data Formats & Parsing
1686- "yaml" : "PyYAML" ,
1687- "bs4" : "beautifulsoup4" ,
1688- "docx" : "python-docx" ,
1689- "pptx" : "python-pptx" ,
1690- # Date & Time Utilities
1691- "dateutil" : "python-dateutil" ,
1692- # Database Connectors
1693- "MySQLdb" : "MySQL-python" ,
1694- "psycopg2" : "psycopg2-binary" ,
1695- # System & Platform
1696- "win32api" : "pywin32" ,
1697- "win32com" : "pywin32" ,
1698- # Scientific Libraries
1699- "Bio" : "biopython" ,
1700- }
1701-
1702- package_list = [
1703- IMPORT_TO_INSTALL_MAPPING .get (name , name ) for name in package_list
1704- ]
17051680
17061681 if create_requirements_txt :
17071682 requirements_txt = ""
@@ -1777,11 +1752,37 @@ def package_not_found_output(package_name, package_versions):
17771752 package_versions .append ([package_name , None ])
17781753 return package_versions
17791754
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+
17801779 package_and_version = []
17811780
17821781 for package in package_list :
17831782 try :
17841783 name = importlib .import_module (package )
1784+ package = IMPORT_TO_INSTALL_MAPPING .get (package , package )
1785+
17851786 try :
17861787 package_and_version .append ([package , name .__version__ ])
17871788 except AttributeError :
0 commit comments