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

Expand the pipenv resolver to be more customizable for what python version is specified and how markers should evaluate. #5931

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ test = "pytest -vvs"

[pipenv]
allow_prereleases = true

[resolver]
Copy link
Contributor

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?

Copy link
Member Author

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"
Copy link
Contributor

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?

Copy link
Member Author

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.

44 changes: 27 additions & 17 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,15 @@ def get_finder(self, pre: bool = False) -> ContextManager[PackageFinder]:
pip_options.cache_dir = self.project.s.PIPENV_CACHE_DIR
pip_options.pre = self.pipfile.get("pre", pre)
session = pip_command._build_session(pip_options)
python_version = None
resolver = self.project.parsed_pipfile.get("resolver", {})
if "finder_python" in resolver:
python_version = resolver["finder_python"]
finder = get_package_finder(
install_cmd=pip_command, options=pip_options, session=session
install_cmd=pip_command,
options=pip_options,
session=session,
python_versions=python_version,
)
yield finder

Expand Down
23 changes: 1 addition & 22 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
proper_case,
)
from pipenv.utils.locking import atomic_open_for_write
from pipenv.utils.project import get_default_pyproject_backend
from pipenv.utils.requirements import normalize_name
from pipenv.utils.shell import (
find_requirements,
Expand Down Expand Up @@ -93,6 +92,7 @@
NON_CATEGORY_SECTIONS = {
"pipenv",
"requires",
"resolver",
"scripts",
"source",
}
Expand Down Expand Up @@ -707,27 +707,6 @@ def _parse_pipfile(
# Fallback to toml parser, for large files.
return toml.loads(contents)

def _read_pyproject(self) -> None:
pyproject = self.path_to("pyproject.toml")
if os.path.exists(pyproject):
self._pyproject = toml.load(pyproject)
build_system = self._pyproject.get("build-system", None)
if not os.path.exists(self.path_to("setup.py")):
if not build_system or not build_system.get("requires"):
build_system = {
"requires": ["setuptools>=40.8.0", "wheel"],
"build-backend": get_default_pyproject_backend(),
}
self._build_system = build_system

@property
def build_requires(self) -> list[str]:
return self._build_system.get("requires", ["setuptools>=40.8.0", "wheel"])

@property
def build_backend(self) -> str:
return self._build_system.get("build-backend", get_default_pyproject_backend())

@property
def settings(self) -> tomlkit.items.Table | dict[str, str | bool]:
"""A dictionary of the settings added to the Pipfile."""
Expand Down
Loading
Loading