feat: Support multiple extras in requirements constraint advertisement#379
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:
|
| requirements = {} | ||
| constraint_files = set() | ||
|
|
||
| # groups "pkg<=x.y.z,..." into ("pkg", "<=x.y.z,...") |
There was a problem hiding this comment.
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.
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.
(I've pushed up a far simpler option. Verbose mode is cool but... probably overkill here.)
| with -c in the requirements files. | ||
| Returns a list of requirement strings. | ||
| """ | ||
| by_canonical_name = {} |
There was a problem hiding this comment.
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.
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.
| - 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.
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 |
rgraber
left a comment
There was a problem hiding this comment.
One suggestion for comment, otherwise LGTM
| 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.
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.
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: