Skip to content
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

Improve PEP-440 support for versions #140

Merged
merged 6 commits into from
Mar 27, 2021
Merged

Conversation

abn
Copy link
Member

@abn abn commented Mar 19, 2021

This is a broad change aligning poetry.core.semver.version.Version implementation to be closer to PEP-440 that to semver. This adds the foundation for improved dev and local tag support in poetry managed version as well as fix ordering bugs that existed due to the differences between semantic versioning specification and PEP-440.

Further, previously used inline copy of packaging.version.Version implementation has now been removed in favour of
poetry.core.version.pep440.PEP440Version implementation.

Note: This change contains minor breaking changes that will require minimal changes downstream in poetry. (see python-poetry/poetry#3831)

References:

Relates-to: python-poetry/poetry#2543
Relates-to: python-poetry/poetry#1151
Relates-to: python-poetry/poetry#892

@abn abn force-pushed the semver/lark branch 2 times, most recently from 8da58ad to 4c3e46b Compare March 20, 2021 00:24
@abn abn requested a review from a team March 20, 2021 00:24
@abn abn marked this pull request as ready for review March 20, 2021 00:35
abn added 2 commits March 23, 2021 00:01
This is a broad change aligning `poetry.core.semver.version.Version`
implementation to be closer to PEP-440 that to semver. This adds the
foundation for improved dev and local tag support in poetry managed
version as well as fix ordering bugs that existed due to the
differences between semantic versioning specification and PEP-440.

Further, previously used inline copy of `packaging.version.Version`
implementation has now been removed in favour of
`poetry.core.version.pep440.PEP440Version` implementation.
kasteph
kasteph previously approved these changes Mar 26, 2021
@abn abn merged commit c11cb9a into python-poetry:master Mar 27, 2021
@abn abn deleted the semver/lark branch March 27, 2021 19:28
Comment on lines -12 to -26
class Parser:
def __init__(self, grammar: str) -> None:
self._grammar = grammar
self._parser: Optional["Lark"] = None
# Parser: PEP 508 Constraints
PARSER_PEP_508_CONSTRAINTS = Lark.open(
GRAMMAR_DIR / "pep508.lark", parser="lalr", debug=False
)

def parse(self, string: str) -> "Tree":
from lark import Lark

if self._parser is None:
self._parser = Lark.open(
os.path.join(os.path.dirname(__file__), f"{self._grammar}.lark"),
parser="lalr",
)

return self._parser.parse(string)
Copy link
Member

@sdispater sdispater Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this class to lazily load grammars, otherwise the performance of Poetry will be severely degraded.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the changes to add it back?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don't think this is the right place to instantiate the parsers.

@shadycuz
Copy link

shadycuz commented Oct 1, 2022

@abn Is there a way to make poetry version go back to outputing alpha instead of a?

This change broke my release process.

@neersighted
Copy link
Member

PEP 440 mandates alpha is normalized to a -- this is also not the right venue to discuss it. Please use GitHub Discussions or Discord if you have questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants