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

Python full version in pipfile #5387

Merged
merged 4 commits into from
Oct 5, 2022
Merged
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
1 change: 1 addition & 0 deletions news/5345.behavior.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New pipfiles show python_full_version under [requires] if specified. Previously creating a new pipenv project would only specify in the Pipfile the major and minor version, i.e. "python_version = 3.7". Now if you create a new project with a fully named python version it will record both in the Pipfile. So: "python_version = 3.7" and "python_full_version = 3.7.2"
4 changes: 3 additions & 1 deletion pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,10 @@ def create_pipfile(self, python=None):
else:
required_python = self.which("python")
version = python_version(required_python) or self.s.PIPENV_DEFAULT_PYTHON_VERSION
if version and len(version.split(".")) > 2:
if version:
data["requires"] = {"python_version": ".".join(version.split(".")[:2])}
if python and version and len(version.split(".")) > 2:
data["requires"].update({"python_full_version": version})
self.write_toml(data)

@classmethod
Expand Down
18 changes: 17 additions & 1 deletion tests/integration/test_install_basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
import os, sys
from pathlib import Path
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -372,6 +372,22 @@ def test_install_creates_pipfile(pipenv_instance_pypi):
c = p.pipenv("install")
assert c.returncode == 0
assert os.path.isfile(p.pipfile_path)
python_version = str(sys.version_info.major) + "." + str(sys.version_info.minor)
assert p.pipfile["requires"] == {'python_version': python_version}


@pytest.mark.basic
@pytest.mark.install
def test_create_pipfile_requires_python_full_version(pipenv_instance_pypi):
with pipenv_instance_pypi(chdir=True) as p:
python_version = str(sys.version_info.major) + "." + str(sys.version_info.minor)
python_full_version = python_version + "." + str(sys.version_info.micro)
c = p.pipenv(f"--python {python_full_version}")
assert c.returncode == 0
assert p.pipfile["requires"] == {
'python_full_version': python_full_version,
'python_version': python_version
}


@pytest.mark.basic
Expand Down