diff --git a/pipenv/project.py b/pipenv/project.py index 7f40576d..918c7184 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -64,6 +64,12 @@ def _normalized(p): DEFAULT_NEWLINES = u"\n" +def encode_toml_elements(obj): + if hasattr(obj, 'primitive_value'): + return obj.primitive_value + raise TypeError(repr(obj) + " is not JSON serializable") + + def preferred_newlines(f): if isinstance(f.newlines, six.text_type): return f.newlines @@ -631,7 +637,8 @@ class Project(object): """ newlines = self._lockfile_newlines s = simplejson.dumps( # Send Unicode in to guarentee Unicode out. - content, indent=4, separators=(u",", u": "), sort_keys=True + content, indent=4, separators=(u",", u": "), sort_keys=True, + default=encode_toml_elements, ) with atomic_open_for_write(self.lockfile_location, newline=newlines) as f: f.write(s) diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index 1ab34f1b..25195bfb 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -1,6 +1,5 @@ import pytest import os -import six from pipenv.utils import temp_environ @@ -348,6 +347,27 @@ requests = {git = "https://github.com/requests/requests.git", ref = "master", ed assert c.return_code == 0 +@pytest.mark.extras +@pytest.mark.lock +@pytest.mark.vcs +@pytest.mark.needs_internet +def test_lock_editable_vcs_with_extras_without_install(PipenvInstance, pypi): + with PipenvInstance(pypi=pypi, chdir=True) as p: + with open(p.pipfile_path, 'w') as f: + f.write(""" +[packages] +requests = {git = "https://github.com/requests/requests.git", editable = true, extras = ["socks"]} + """.strip()) + c = p.pipenv('lock') + assert c.return_code == 0 + assert 'requests' in p.lockfile['default'] + assert 'idna' in p.lockfile['default'] + assert 'chardet' in p.lockfile['default'] + assert "socks" in p.lockfile["default"]["requests"]["extras"] + c = p.pipenv('install') + assert c.return_code == 0 + + @pytest.mark.lock @pytest.mark.skip(reason="This doesn't work for some reason.") def test_lock_respecting_python_version(PipenvInstance, pypi):