44import os
55import sys
66
7- from pkg_resources import Requirement
8-
97from homeassistant .loader import bind_hass
108from homeassistant .requirements import async_process_requirements
119
@@ -90,19 +88,14 @@ def process_all_requirements(pyscript_folder, requirements_paths, requirements_f
9088 pkg = pkg [:i ]
9189 pkg = pkg .strip ()
9290
93- if not pkg :
91+ if not pkg or len ( pkg ) == 0 :
9492 continue
9593
9694 try :
9795 # Attempt to get version of package. Do nothing if it's found since
9896 # we want to use the version that's already installed to be safe
99- requirement = Requirement .parse (pkg )
100- pkg_name = requirement .project_name
101-
102- # Requirements must be pinned and will be skipped if they aren't
103- if len (requirement .specs ) == 1 and (
104- len (requirement .specs [0 ]) != 2 or requirement .specs [0 ][0 ] != "=="
105- ):
97+ parts = pkg .split ("==" )
98+ if len (parts ) > 2 or "," in pkg or ">" in pkg or "<" in pkg :
10699 _LOGGER .error (
107100 (
108101 "Ignoring invalid requirement '%s' specified in '%s'; if a specific version"
@@ -112,11 +105,12 @@ def process_all_requirements(pyscript_folder, requirements_paths, requirements_f
112105 pkg ,
113106 )
114107 continue
115-
116- if not requirement .specs :
108+ if len (parts ) == 1 :
117109 new_version = UNPINNED_VERSION
118110 else :
119- new_version = requirement .specs [0 ][1 ]
111+ new_version = parts [1 ]
112+ pkg_name = parts [0 ]
113+
120114 current_pinned_version = all_requirements_to_install .get (pkg_name , {}).get (ATTR_VERSION )
121115 current_sources = all_requirements_to_install .get (pkg_name , {}).get (ATTR_SOURCES , [])
122116 # If a version hasn't already been recorded, record this one
0 commit comments