Skip to content

Commit 6ffc058

Browse files
authored
Merge pull request #21720 from mvdbeek/strip_line_comments
[25.1] Strip inline comments in conditional requirements
2 parents 5d36524 + 0ab9d63 commit 6ffc058

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/galaxy/dependencies/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import os
6+
import re
67
import sys
78
from os.path import (
89
dirname,
@@ -337,6 +338,12 @@ def check_huggingface_hub(self):
337338
return "huggingface" in self.file_sources
338339

339340

341+
def strip_comment(line):
342+
# lifted from https://github.com/tox-dev/tox/commit/3c6b4f204e89852c4b7536b246a66d20be6d39ec
343+
# xref https://github.com/pyupio/dparse/issues/34
344+
return re.sub(r"\s+#.*", "", line).strip()
345+
346+
340347
def optional(config_file=None):
341348
if not config_file:
342349
config_file = find_config_file(["galaxy", "universe_wsgi"], include_samples=True)
@@ -347,5 +354,5 @@ def optional(config_file=None):
347354
conditional = ConditionalDependencies(config_file)
348355
for dependency in conditional.conditional_reqs:
349356
if conditional.check(dependency.name):
350-
rval.append(dependency.line)
357+
rval.append(strip_comment(dependency.line))
351358
return rval

0 commit comments

Comments
 (0)