-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Expand the pipenv resolver to be more customizable for what python version is specified and how markers should evaluate. #5931
Conversation
…ersion is specified and how markers should evaluate.
…patch but rather monkeypatch it for the lifespan of the resolver.
@@ -236,7 +236,6 @@ def _evaluate_markers(markers: List[Any], environment: Dict[str, str]) -> bool: | |||
else: | |||
lhs_value = lhs.value | |||
rhs_value = _get_env(environment, rhs.value) | |||
|
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 should undo this non-change.
@@ -99,8 +54,6 @@ def get_source_list( | |||
|
|||
|
|||
def parse_indexes(line, strict=False): | |||
from argparse import ArgumentParser |
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 don't agree with the linter here.
from argparse import ArgumentParser
Can be used locally inside a function if it's imported to be used in a different place.
Imports can be expensive (argparse isn't giant, but still...).
The linter rule here should be relaxed.
@@ -1,18 +1,11 @@ | |||
from __future__ import annotations | |||
|
|||
import re | |||
from collections.abc import Mapping | |||
from argparse import ArgumentParser |
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.
See comment below.
@@ -41,3 +41,9 @@ test = "pytest -vvs" | |||
|
|||
[pipenv] | |||
allow_prereleases = true | |||
|
|||
[resolver] |
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.
This is going to be optional for usrers?
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.
Yup -- the code still gets the default platform dictionary, this just provide a mechanism to override.
python_full_version = "3.7.13" | ||
python_version = "3.7" | ||
finder_python = "3.7" | ||
os_name = "win32" |
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 do teams that work on multiple OS can specify multiple OSs here?
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.
This is a minimal patch, so it doesn't provide a way to target multiple versions -- I went down that path initially but it involves changes in the packaging markers code, and it got too complicated for a first pass.
Might revisit later on. |
I am exploring how the resolver determines what python version its using and what markers to evaluate against.
The issue
Fixes #5908
The fix
Adds another reserved named category for pipenv and a patch to packaging, that allows overriding any of the default environment keys. Additionally, support ranges for
python_version
andpython_full_version
and apython
key to specify the base package finder python version to use for the resolver.In my example, I've added these constraints to our Pipfile to show that I can resolve the requirements that require python 3.7 using a python 3.11 version.
Also explore allowing multiple operating system markers to resolve.
Note: This branch started as me removing some unused code based on a coverage report and some extra analysis.
The checklist
news/
directory to describe this fix with the extension.bugfix.rst
,.feature.rst
,.behavior.rst
,.doc.rst
..vendor.rst
. or.trivial.rst
(this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #.