-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Patch revision specification in pyproject.toml breaks creating new venv #4136
Comments
Hello @tigerhawkvok, can you show the out of fin swimmer |
|
Seems like instead of a string comparison, following PEP 440 Poetry should use something like
Pulling the first two tuple elements in |
I propose something like this: from packaging.version import parse as parsePyVersion
from packaging.version import VERSION_PATTERN
from platform import python_version
import re
def validPyVersion(required:str, debug:bool= False) -> bool:
"""
Compare a match string to the running Python version
"""
required = str(required)
# Our running version
CURRENT_VERSION = parsePyVersion(python_version())
# The package minimum required version
versionMatch = re.search(r"^[\^=~]*([0-9](?:\.\d*)?(?:\.[a-z\d]*)?)$", required.strip(), re.IGNORECASE | re.DOTALL | re.MULTILINE)
if not versionMatch:
raise ValueError("Invalid version string")
versionString = versionMatch.group(1)
versionParts = versionString.split(".")
COMPARE_VERSION = parsePyVersion(versionString)
# The next revision up, for the package's specificity
try:
if len(versionParts) == 1:
raise IndexError
versionSpecificity = versionParts.copy().pop() if len(versionParts) < 3 else versionParts[:-1].pop()
versionStub = [versionParts[0]]
except IndexError:
versionSpecificity = versionString
versionStub = []
try:
nextVersion = int(versionSpecificity) + 1
except TypeError:
thisDigitMatch = re.search(r"^(\d+)", versionSpecificity, re.IGNORECASE | re.DOTALL | re.MULTILINE)
thisDigit = 0 if thisDigitMatch is None else thisDigitMatch.group(0)
nextVersion = int(thisDigit) + 1
PACKAGE_LESS_THAN_VERSION = parsePyVersion('.'.join([str(x) for x in versionStub + [nextVersion]]))
# tidy the match type. Remove `=` as to play nice with
# some version strings that have extra `=` in them, like pip
matchType = required.strip().replace(versionString, '')
if len(matchType) > 1:
matchType = matchType.replace('=', '')
if len(matchType) == 0:
matchType = '=' if len(versionParts) == 3 else "~"
comparisonMapper = {
'=': COMPARE_VERSION == CURRENT_VERSION,
'^': CURRENT_VERSION >= COMPARE_VERSION,
'~': (CURRENT_VERSION >= COMPARE_VERSION) and (CURRENT_VERSION < PACKAGE_LESS_THAN_VERSION),
}
if debug:
return comparisonMapper[matchType], COMPARE_VERSION, PACKAGE_LESS_THAN_VERSION, CURRENT_VERSION, matchType
return comparisonMapper[matchType] |
Hello @tigerhawkvok, I guess your suggestion refers to this line in the poetry executable?
This is only needed to tell poetry where it can find it's vendored dependencies. And this location depends on the currently activate python minor version. This has nothing to do with comparing version requirements for dependencies. So it's still unclear why poetry believes you are using python 3.7.0. Can you show the output of fin swimmer |
I'm closing this because we haven't receive no more information for a long time now. Feel free to leave a comment if you disagree. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
Similar to #1735 .
I only have one version of Python on this machine, 3.7.8; but the requirement
^3.7.1
throws an error:This can be corrected by removing the patch revision, then later updating pyproject.toml doesn't cause further poetry commands to fail.
The text was updated successfully, but these errors were encountered: