-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat: Support multiple extras in requirements constraint advertisement #379
Conversation
Update the base template's setup.py to support the full syntax of package extras. - Support commas and whitespace inside extras declarations, e.g. `some_package[extra_one, extra_two]` - Raise exception if we spell packages differently in requirement and constraint files, including presence/absence of extras.
289531b
to
554dbc7
Compare
I should figure out how to do automated testing of this. For now, some manual testing:
|
f'Encountered both "{seen_spelling}" and "{package}" in requirements ' | ||
'and constraints files; please use just one or the other.' | ||
) | ||
|
||
requirements = {} | ||
constraint_files = set() | ||
|
||
# groups "pkg<=x.y.z,..." into ("pkg", "<=x.y.z,...") |
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.
can we update the comment to include how the regex treats [] ? it's a pretty hard regex to read
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.
How would you feel about using verbose mode? Not something I think I've ever used before, but I agree that this regex is... pretty dense.
requirement_line_regex = re.compile(
r"""
(
# The base name of the package
[%s]+
# Optionally, an extras section, as in `some-package[extra-one, extra-two]`
(?:
\[[%s,\s]+\]
)?
)
# Optionally, a version constraint like `>=3.0`
(
[<>=][^#\s]+
)?
"""
% (re_package_name_base_chars, re_package_name_base_chars),
re.VERBOSE
)
Or even using a raw format-string, which is apparently a thing you can do? And maybe adding some spaces inside some of the more confusing character classes:
requirement_line_regex = re.compile(
fr"""
(
# The base name of the package
[ {re_package_name_base_chars} ]+
# Optionally, an extras section, as in `some-package[extra-one, extra-two]`
(?:
\[ [{re_package_name_base_chars},\s]+ \]
)?
)
# Optionally, a version constraint like `>=3.0`
(
[<>=][^#\s]+
)?
""",
re.VERBOSE
)
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.
(I've pushed up a far simpler option. Verbose mode is cool but... probably overkill here.)
@@ -36,17 +36,43 @@ def load_requirements(*requirements_paths): | |||
with -c in the requirements files. | |||
Returns a list of requirement strings. | |||
""" | |||
by_canonical_name = {} |
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.
A comment here with an example entry would be helpful. It took me a minute to figure out how it was being used.
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.
Sure, maybe something like this:
# e.g. {"django": "Django", "openedx-events": "openedx_events"}
CHANGELOG.rst
Outdated
======= | ||
|
||
- In setup.py, support advertising constraints on packages with multiple extras | ||
- Fail packaging if requirements are spelled differently in different places |
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.
- Fail packaging if requirements are spelled differently in different places | |
- Fail packaging if requirements are named differently in different places or have different extras added |
""" | ||
Raise exception if package is spelled different ways. | ||
|
||
This ensures that packages are spelled consistently so we can match |
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.
It's not really spelling.
This ensures that packages are spelled consistently so we can match | |
This ensures that packages are named consistently so we can match |
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.
One suggestion for comment, otherwise LGTM
@@ -36,17 +36,45 @@ def load_requirements(*requirements_paths): | |||
with -c in the requirements files. | |||
Returns a list of requirement strings. | |||
""" | |||
# e.g. {"django": "Django", "openedx-events": "openedx_events"} |
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.
Just to be super de dooper clear
# e.g. {"django": "Django", "openedx-events": "openedx_events"} | |
# e.g. {"django": "Django", "openedx-events": "openedx_events", "confluent-kafka":"confluent-kafka[avro]"} |
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.
The quality checks will probably yell about line length. Maybe I'll use confluent_kafka[avro]
to demonstrate both underscore and extras?
Update the base template's setup.py to support the full syntax of package extras.
some_package[extra_one, extra_two]
Merge checklist:
Check off if complete or not applicable: