-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose a way to exclude deps - option 2 #663
Conversation
@@ -203,11 +216,24 @@ def simple_combine(reqs): | |||
continue | |||
|
|||
base_line = line.split('#')[0].strip() | |||
name_match = REQ_NAME_RE.match(base_line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some additional care is probably required here. This will have issues currently with things like:
- URLs (
git+...
,https://...
) -r extra-requirements.txt
or any other random pip flag
In this case, we probably just need to skip the exclude checks. But we can't have it both ways, in that we can't ignore requirements parsing, and still do requirements parsing, so URLs and such just wouldn't be supported. 🙂
The regex is also using the pep503 info, but I can't think of reasons it wouldn't work with RPM package names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may not actually be a problem with -r
but would still apply to URLs
if base_line in consolidated: | ||
i = consolidated.index(base_line) | ||
fancy_lines[i] += f', {collection}' | ||
if not name_only: | ||
fancy_lines[i] += f', {collection}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to kill off fancy lines, and just spit back out a concatenation, but not consolidate duplicates.
base_collections_path = '/usr/share/ansible/collections' | ||
logger = logging.getLogger(__name__) | ||
|
||
# https://peps.python.org/pep-0503/#normalized-names | ||
REQ_NORM_RE = re.compile(r'[-_.]+') | ||
REQ_NAME_RE = re.compile(r'^([-\w.]+)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REQ_NAME_RE = re.compile(r'^([-\w.]+)') | |
REQ_NAME_RE = re.compile(r'^([^-][-\w.]+)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the best approach that seems the least likely to break existing usages, while still allowing for various "escape hatch" impls... Probably a few more bits to implement to fully close the loop:
- A
from_collection
key forexclude
, to allow a list of one or more collection names from which to completely ignore all deps. It's a big hammer, but would make things like "I only want to get my deps from downstream-packaged sources" at least possible without requiring EE creators to manually merge and exclude all the deps using thepython/system/galaxy
keys. - A docs note that Python requirements in collections should be limited to features defined by PEP508, and that any deviation from that will be considered undefined/unsupported behavior, even if it happens to work today.
- A suggestion to partner eng that PEP508-only requirements validation might be a good candidate for a certification gate (they could easily base such a thing off Drop requirements-parser in favor of pep508 #645).
except ValueError as e: | ||
raise DefinitionError(f"Schema version not an integer: {ee_def['version']}") from e | ||
|
||
if schema_version not in (1, 2, 3): | ||
if schema_version not in (1, 2, 3, 3.1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're abusing a combination of other tools in the absence of a first-class YAML "schema" for EE definitions , it's probably better to just support this in the existing version 3 schema, along with a small docs note that the exclude feature requires Builder >= 3.1 (and will be an error on < 3.1).
Based on #647
TODO:
NOTES: