Skip to content

Commit 56b5c3a

Browse files
authored
[CI] Fix parsing of dev_requirements with comments (#33734)
Encountered some issues with the generation.py script when comments are in the dev_requirements.txt file. This change correctly parses them. Signed-off-by: Paul Van Eck <[email protected]>
1 parent a53defc commit 56b5c3a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/azure-sdk-tools/ci_tools/scenario/generation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ def build_and_install_dev_reqs(file: str, pkg_root: str) -> None:
240240

241241
with open(file, "r") as f:
242242
for line in f:
243+
# Remove inline comments which are denoted by a "#".
244+
line = line.split("#")[0].strip()
245+
if not line:
246+
continue
247+
243248
args = [part.strip() for part in line.split() if part and not part.strip() == "-e"]
244249
amended_line = " ".join(args)
245250

@@ -262,7 +267,7 @@ def build_and_install_dev_reqs(file: str, pkg_root: str) -> None:
262267
shutil.rmtree(os.path.join(pkg_root, ".tmp_whl_dir"))
263268

264269

265-
def is_relative_install_path(req: str, package_path: str) -> str:
270+
def is_relative_install_path(req: str, package_path: str) -> bool:
266271
possible_setup_path = os.path.join(package_path, req, "setup.py")
267272

268273
# blank lines are _allowed_ in a dev requirements. they should not resolve to the package_path erroneously

0 commit comments

Comments
 (0)