diff --git a/pipenv/project.py b/pipenv/project.py index 961ac52e..ddc5f336 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -3,6 +3,7 @@ import codecs import json import os import re +import six import sys import shlex import base64 @@ -371,9 +372,11 @@ class Project(object): @property def scripts(self): scripts = self.parsed_pipfile.get('scripts', {}) + posix = os.name == 'posix' + _scripts = {} for (k, v) in scripts.items(): - scripts[k] = shlex.split(v, posix=True) - return scripts + _scripts[k] = shlex.split(str(v), posix=posix) + return _scripts def update_settings(self, d): settings = self.settings diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 1329d5b2..49cf3cc8 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -1170,3 +1170,38 @@ flask = "==0.12.2" with open(p.pipfile_path, 'a') as f: f.write('requests = "==2.14.0"\n') assert Project().get_lockfile_hash() != Project.calculate_pipfile_hash() + + @pytest.mark.run + def test_scripts_basic(self): + with PipenvInstance(chdir=True) as p: + with open(p.pipfile_path, 'w') as f: + f.write(""" +[scripts] +printfoo = "python -c print('foo')" + """) + + c = p.pipenv('install') + assert c.return_code == 0 + + c = p.pipenv('run printfoo') + assert c.return_code == 0 + assert c.out == 'foo\n' + assert c.err == '' + + @pytest.mark.run + @pytest.mark.skip(reason='This fails on Windows (not sure about POSIX).') + def test_scripts_quoted(self): + with PipenvInstance(chdir=True) as p: + with open(p.pipfile_path, 'w') as f: + f.write(""" +[scripts] +printfoo = "python -c print('foo')" + """) + + c = p.pipenv('install') + assert c.return_code == 0 + + c = p.pipenv('run printfoo') + assert c.return_code == 0 + assert c.out == 'foo\n' + assert c.err == ''