Repository: pypa/pipenv

Issue:
using conda python to create pipenv adds both python_version and python_full_version to pipfile
Hello, 

If I use a miniconda environment's python for creating a pipenv environment, it adds BOTH, a python_version and python_full_version (e.g. 3.9 and 3.9.13) to  the pipfile, and that throws an error.

System details:

I am using Ubuntu 22.04 via WSL. 
System python is: 3.10.6
Pip version is: 22.2.2
Pipenv installed via pip (outside of any environment): 2022.10.9
Conda version is: 22.9.0
All are the latest right now


Steps to reproduce the error:

(mlzoomcamp is a conda environment with python 3.9.13 (but I also used a conda env with python 3.10 and the same issue persisted)) 

```
(base) mona@Memoona-PC:~$ pipenv --python=/home/mona/miniconda3/envs/mlzoomcamp/bin/python
# runs fine, but when I install something:
(base) mona@Memoona-PC:~/extra$ pipenv install numpy
```

It installs numpy correctly, but then throws this error: 

```
Installing numpy...
Adding numpy to Pipfile's [packages]...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Traceback (most recent call last):
  File "/home/mona/.local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/cli/options.py", line 57, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/cli/command.py", line 236, in install
    do_install(
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/core.py", line 2389, in do_install
    do_init(
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/core.py", line 1303, in do_init
    do_lock(
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/core.py", line 1070, in do_lock
    lockfile = project._lockfile(categories=lockfile_categories)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/project.py", line 581, in _lockfile
    plette.Pipfile.load(pf), categories=categories
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/pipfiles.py", line 59, in load
    return cls(data)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/models/base.py", line 49, in __init__
    self.validate(data)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/pipfiles.py", line 43, in validate
    klass.validate(data[key])
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/models/base.py", line 81, in validate
    return validate(cls, data)
  File "/home/mona/.local/lib/python3.10/site-packages/pipenv/vendor/plette/models/base.py", line 38, in validate
    raise ValidationError(data, v)
pipenv.vendor.plette.models.base.ValidationError: {'python_version': '3.9', 'python_full_version': '3.9.13'}
python_full_version: 'python_version' must not be present with 'python_full_version'
python_version: 'python_full_version' must not be present with 'python_version'
```

The pipenv file at this time looks like this:

```
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
numpy = "*"

[dev-packages]

[requires]
python_version = "3.9"
python_full_version = "3.9.13"
```

I looked at the pipfile before the install command, and it has already added the 2 versions as soon as the environment was created.

I did find a fix, to manually remove the python_version line from pipfile. 

Also, if I use the system python to create an environment, this issue doesn't happen, so this is most likely a conda issue. Do I have to manually remove the python_version each time from the pipfile? 




Discussion:
If a full_python_version is specified when the project is installed it will be added in the [requires] section of the Pipfile in addition to the python_version. But this is just a recently added feature.
@oz123 should I take a look at refactor to have only `python_version` or `python_full_version` gets written, but not both?
@jerempy can you please submit this patch upstream in Plette?
https://github.com/sarugaku/plette/blob/master/src/plette/models/sections.py#L20
![image](https://user-images.githubusercontent.com/1083045/194898121-b6ca95c7-9aad-4a0f-b834-012a22bc82c7.png)

IMHO the rule should be [oneof](https://docs.python-cerberus.org/en/stable/validation-rules.html#oneof), but I am not familiar with 
Cerberus. To say for 100%.

when you have a moment @oz123 : https://github.com/sarugaku/plette/pull/31
Thanks for the quick response! I made a comment there.
FYI: We're seeing the same issue with vanilla (i.e not conda) Python.  2022.9.24 works fine.

Resolving patch:
diff --git a/pipenv/vendor/plette/__init__.py b/pipenv/vendor/plette/__init__.py
--- a/pipenv/vendor/plette/__init__.py
+++ b/pipenv/vendor/plette/__init__.py
@@ -3,7 +3,7 @@
     "Lockfile", "Pipfile",
 ]
 
-__version__ = '0.4.1'
+__version__ = '0.4.2'
 
 from .lockfiles import Lockfile
 from .pipfiles import Pipfile
diff --git a/pipenv/vendor/plette/models/sections.py b/pipenv/vendor/plette/models/sections.py
--- a/pipenv/vendor/plette/models/sections.py
+++ b/pipenv/vendor/plette/models/sections.py
@@ -18,16 +18,14 @@ class SourceCollection(DataViewSequence):
 
 
 class Requires(DataView):
-    """Representation of the `[requires]` section in a Pipfile.
-    """
+    """Representation of the `[requires]` section in a Pipfile."""
+
     __SCHEMA__ = {
         "python_version": {
             "type": "string",
-            "excludes": ["python_full_version"],
         },
         "python_full_version": {
             "type": "string",
-            "excludes": ["python_version"],
         },
     }
 
@@ -54,8 +52,8 @@ def python_full_version(self):
 
 
 class Meta(DataView):
-    """Representation of the `_meta` section in a Pipfile.lock.
-    """
+    """Representation of the `_meta` section in a Pipfile.lock."""
+
     __SCHEMA__ = {
         "hash": {"type": "dict", "required": True},
         "pipfile-spec": {"type": "integer", "required": True, "min": 0},


Test patch: