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

remove packaging<22 cap #6463

Closed
wants to merge 3 commits into from

Conversation

smackesey
Copy link

@smackesey smackesey commented Dec 20, 2022

resolves #6461

Description

This PR removes the version cap on packaging. This cap was preventing dbt-core from being installed in the same environment as tox 4. It also did not appear to be necessary-- the main breaking change from packaging <22 to 22+ is the drop of LegacyVersion (which used to be a possible return from packaging.parse). dbt-core did not contain any direct references to LegacyVersion, and AFAICT does not depend on any functionality specifically in packaging<22, but I might be wrong.

Checklist

@smackesey smackesey requested review from a team as code owners December 20, 2022 13:11
@cla-bot cla-bot bot added the cla:yes label Dec 20, 2022
@jtcohen6 jtcohen6 added Team:Language ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering labels Jan 2, 2023
Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

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

dbt Core does actually use LegacyVersion under the covers in that the version code falls back to legacy version if the version method doesn't work. So switching to later versions of packaging might break version strings that are currently accepted. Which is why a number of the test cases are currently failing.

If you could identify some versions which succeed currently and would fail under a later version of packaging, we could make a decision about whether this is a change that we want to do at this point.

@gshank
Copy link
Contributor

gshank commented Jan 5, 2023

Another alternative might be to use our own version function. I haven't really looked into how feasible that is though. Pinning this forever is certainly not optimal.

Comment on lines +145 to +148
if packaging_version.parse(a) > packaging_version.parse(b):
return 1
elif packaging_version.parse(a) < packaging_version.parse(b):
return -1
Copy link
Contributor

@jtcohen6 jtcohen6 Jan 9, 2023

Choose a reason for hiding this comment

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

adapted from Slack: @jtcohen6 + @gshank on 6 Jan

There are two things at play here, leading to failures in test/unit/test_semver.py:

  1. This logic is not quite right! We're passing just part of a version string into packaging.version.parse(), rather than the whole string. This is the cause of some of the failing tests.
  2. Unfortunately, there are also some real discrepancies between PEP 440 and SemVer, and packaging==22.0 lands firmly on the side of PEP 440. This is the cause of the rest of the failing tests.

These versions are still supported by packaging==22.0. (Although PEP 440 says not to use a hyphen, and SemVer says to use a hyphen.) The failure is because we're trying to parse just the prerelease identifier (a1, b2) as if it's an entire version string:

  • '1.2.0a1'
  • '1.2.0-a1'
  • '1.2.0b2'
  • '1.2.0-b2'

These are valid per SemVer, but they are not valid per PEP 440, and so they fail on packaging.version.parse() starting with packaging==22.0:

  • '2.2.0-fishtown-beta'
  • '2.2.0asdf'

https://peps.python.org/pep-0440/#pre-releases

The pre-release segment consists of an alphabetical identifier for the pre-release phase, along with a non-negative integer value. Pre-releases for a given release are ordered first by phase (alpha, beta, release candidate) and then by the numerical component within that phase.

https://semver.org/#spec-item-9

A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. Identifiers MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-].

@gshank

It would be nice to not pin "packaging" because of it... Maybe at this point we should defer this to a re-write

@dbeatty10
Copy link
Contributor

@smackesey we couldn't easily lift the upper bound from packaging without a re-write of how we compare prerelease versions. We ended up doing that re-write in #6838 which supersedes this PR.

Thank you for opening the original issue in #6461, drafting this PR, and spawning the discussion in #6495 -- we appreciate all of them!

@dbeatty10 dbeatty10 closed this Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-1688] [Feature] Remove packaging <22 version cap
4 participants