File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 22
33try :
44 with open ("installed.json" ) as f :
5- installed = {pkg ["name" ].lower (): pkg ["version" ] for pkg in json .load (f )}
5+ # Only store package names for comparison, ignore versions
6+ installed = {pkg ["name" ].lower () for pkg in json .load (f )}
67except (json .JSONDecodeError , FileNotFoundError ):
7- installed = {}
8+ installed = set ()
89
9- with open ("requirements.txt" ) as f :
10+ print ("Installed packages:" )
11+ print ("\n " .join (sorted (installed )) if installed else "No installed packages found" )
12+ print ("\n " + "=" * 50 + "\n " )
13+
14+ with open ("cve/requirements.txt" ) as f :
1015 requirements = [
1116 line .strip () for line in f if line .strip () and not line .startswith ("#" )
1217 ]
1318
19+ print ("Requirements from requirements.txt:" )
20+ print ("\n " .join (requirements ) if requirements else "No requirements found" )
21+ print ("\n " + "=" * 50 + "\n " )
22+
1423filtered = []
1524for req in requirements :
25+ # Only get package name for comparison
1626 pkg_name = req .split ("==" )[0 ].strip ().lower ()
1727 if pkg_name in installed :
28+ # Add the full original requirement (including version)
1829 filtered .append (req )
1930
31+ print ("Filtered requirements (matching installed packages):" )
32+ print ("\n " .join (filtered ) if filtered else "No matching packages found" )
33+ print ("\n " + "=" * 50 + "\n " )
34+
2035with open ("filtered-requirements.txt" , "w" ) as f :
2136 f .write ("\n " .join (filtered ))
Original file line number Diff line number Diff line change 11pymysql == 1.1.1
2+ jinja2 == 3.1.5
3+ idna == 3.7
4+ webob == 1.8.8
5+ virtualenv == 20.26.6
You can’t perform that action at this time.
0 commit comments