Pipenv: Feature: merge conflicts resolution

Created on 2 Feb 2018  Â·  11Comments  Â·  Source: pypa/pipenv

I suggest to consider an automatic merge conflict resolution for Pipfile.lock.
This feature is similar to this feature in yarn: https://github.com/yarnpkg/yarn/issues/2155

Describe your environment
  1. OS Type: macos
  2. Python version: $ python -V 3.6.4
  3. Pipenv version: $ pipenv --version 9.0.3
Expected result

I expect, that after I have resolved my conflicts in Pipfile, pipenv will automatically resolve merge conflicts in Pipfile.json for me.

Actual result

Cli output:

~/Desktop/test-pipenv  master|MERGING ✗                                      § 
» pipenv install mypy
Installing mypy…
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1875, in install
    c = pip_install(package_name, ignore_hashes=True, allow_global=system, no_deps=False, verbose=verbose, pre=pre)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1366, in pip_install
    sources = project.sources
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 436, in sources
    meta_ = self.lockfile_content['_meta']
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 337, in lockfile_content
    return json.load(lock)
  File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 4 column 1 (char 35)

Pipfile:

[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"


[packages]

django = "*"
<<<<<<< HEAD
djangorestframework = "*"
=======
celery = "*"
>>>>>>> feature-celery


[dev-packages]

Pipfile.lock:

{
    "_meta": {
        "hash": {
<<<<<<< HEAD
            "sha256": "1f3d4cc7027911c0d5599450f18f080ccf209827c665920bad7fc6e832bb3b38"
=======
            "sha256": "43db93da0ec552507b288b8dc4aa9f463426a41aad9795b8360fcc2a167d6550"
>>>>>>> feature-celery
        },
        "host-environment-markers": {
            "implementation_name": "cpython",
            "implementation_version": "3.6.4",
            "os_name": "posix",
            "platform_machine": "x86_64",
            "platform_python_implementation": "CPython",
            "platform_release": "15.6.0",
            "platform_system": "Darwin",
            "platform_version": "Darwin Kernel Version 15.6.0: Fri Feb 17 10:21:18 PST 2017; root:xnu-3248.60.11.4.1~1/RELEASE_X86_64",
            "python_full_version": "3.6.4",
            "python_version": "3.6",
            "sys_platform": "darwin"
        },
        "pipfile-spec": 6,
        "requires": {},
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.python.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "amqp": {
            "hashes": [
                "sha256:4e28d3ea61a64ae61830000c909662cb053642efddbe96503db0e7783a6ee85b",
                "sha256:cba1ace9d4ff6049b190d8b7991f9c1006b443a5238021aca96dd6ad2ac9da22"
            ],
            "version": "==2.2.2"
        },
        "billiard": {
            "hashes": [
                "sha256:abd9ce008c9a71ccde2c816f8daa36246e92a21e6a799831b887d88277187ecd",
                "sha256:1d7b22bdc47aa52841120fcd22a74ae4fc8c13e9d3935643098184f5788c3ce6"
            ],
            "version": "==3.5.0.3"
        },
        "celery": {
            "hashes": [
                "sha256:81a67f0d53a688ec2bc8557bd5d6d7218f925a6f2e6df80e01560de9e28997ec",
                "sha256:77ff3730198d6a17b3c1f05579ebe570b579efb35f6d7e13dba3b1368d068b35"
            ],
            "version": "==4.1.0"
        },
        "django": {
            "hashes": [
                "sha256:7c8ff92285406fb349e765e9ade685eec7271d6f5c3f918e495a74768b765c99",
                "sha256:dc3b61d054f1bced64628c62025d480f655303aea9f408e5996c339a543b45f0"
            ],
            "version": "==2.0.2"
        },
<<<<<<< HEAD
        "djangorestframework": {
            "hashes": [
                "sha256:1f6baf40ed456ed2af6bd1a4ff8bbc3503cebea16509993aea2b7085bc097766",
                "sha256:9f9e94e8d22b100ed3a43cee8c47a7ff7b185e778a1f2da9ec5c73fc4e081b87"
            ],
            "version": "==3.7.7"
=======
        "kombu": {
            "hashes": [
                "sha256:01f0da9fe222a2183345004243d1518c0fbe5875955f1b24842f2d9c65709ade",
                "sha256:4249d9dd9dbf1fcec471d1c2def20653c9310dd1a217272d77e4844f9d5273cb"
            ],
            "version": "==4.1.0"
>>>>>>> feature-celery
        },
        "pytz": {
            "hashes": [
                "sha256:80af0f3008046b9975242012a985f04c5df1f01eed4ec1633d56cc47a75a6a48",
                "sha256:feb2365914948b8620347784b6b6da356f31c9d03560259070b2f30cff3d469d",
                "sha256:59707844a9825589878236ff2f4e0dc9958511b7ffaae94dc615da07d4a68d33",
                "sha256:d0ef5ef55ed3d37854320d4926b04a4cb42a2e88f71da9ddfdacfde8e364f027",
                "sha256:c41c62827ce9cafacd6f2f7018e4f83a6f1986e87bfd000b8cfbd4ab5da95f1a",
                "sha256:8cc90340159b5d7ced6f2ba77694d946fc975b09f1a51d93f3ce3bb399396f94",
                "sha256:dd2e4ca6ce3785c8dd342d1853dd9052b19290d5bf66060846e5dc6b8d6667f7",
                "sha256:699d18a2a56f19ee5698ab1123bbcc1d269d061996aeb1eda6d89248d3542b82",
                "sha256:fae4cffc040921b8a2d60c6cf0b5d662c1190fe54d718271db4eb17d44a185b7"
            ],
            "version": "==2017.3"
        },
        "vine": {
            "hashes": [
                "sha256:6849544be74ec3638e84d90bc1cf2e1e9224cc10d96cd4383ec3f69e9bce077b",
                "sha256:52116d59bc45392af9fdd3b75ed98ae48a93e822cee21e5fda249105c59a7a72"
            ],
            "version": "==1.1.4"
        }
    },
    "develop": {}
}
Steps to replicate
  1. Create new project folder
  2. git init
  3. pipenv install django
  4. git commit -a -m 'Initial'
  5. git checkout -b feature-celery
  6. pipenv install celery
  7. git commit -a m 'Adds celery'
  8. git checkout master
  9. pipenv install djangorestframework
  10. git commit -a -m 'Adds rest framework'
  11. git merge feature-celery
  12. Resolve merge conflicts in Pipfile
Type

Most helpful comment

Why was this closed? Is there a recommend approach when this happens? It seems like a fairly common case.

All 11 comments

this sounds quite fancy!

Can you turn those instructions into a script?

Thanks!

@sobolevn I think he means a pipenv script using the new scripts section :) and then PR

Why was this closed? Is there a recommend approach when this happens? It seems like a fairly common case.

We're working on stability right now, not new features :)

Ok, sounds good.

I was just wondering if there is any documentation I missed for how to handle this case?

I ended up just deleting my Pipfile.lock and regenerating it to solve the merge conflict. This seems like it is defeating the purpose of Pipfile.lock, but I haven't investigated into this too much yet.

@dwaltrip pipfiles are the source of truth, so introducing multiple new packages will necessarily require a re-lock.

I do the same thing @dwaltrip.

Yea, if you have a merge conflict w/ your pipfiles, you can run pipenv lock to generate a new Pipfile.lock

This works great.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacebrowning picture jacebrowning  Â·  3Comments

erinxocon picture erinxocon  Â·  3Comments

jacek-jablonski picture jacek-jablonski  Â·  3Comments

bgjelstrup picture bgjelstrup  Â·  3Comments

fbender picture fbender  Â·  3Comments