linkedin / shiv

shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441, but with all their dependencies included.
BSD 2-Clause "Simplified" License
1.75k stars 98 forks source link

tests are now failing on master #97

Open Imaclean74 opened 5 years ago

Imaclean74 commented 5 years ago

platform : Mac OS X, 10.14.3 Python version : 3.7.3 Pip version ( if relevant ) : 9.0.3

I was getting test failures on a branch and so checkout master as a baseline. Turns out that's failing for me as well.

git clone git@github.com:linkedin/shiv.git
cd shiv
python3 setup.py venv
source activate
python3 setup.py develop

then

pip install tox
tox -e py37

gives

        # check that the command successfully completed
        assert result.exit_code == 0

        # ensure the created file actually exists
        assert output_file.exists()

        # now run the produced zipapp
        proc = subprocess.run(
            [str(output_file)],
            input=b"import hello;print(hello)",
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            shell=True,
            env=os.environ,
        )

>       assert proc.returncode == 0
E       assert 2 == 0
E        +  where 2 = CompletedProcess(args=['/private/var/folders/x_/h517ndbj2qx9m6ydt_vtsrv00000gn/T/pytest-of-ianmaclean/pytest-27/test_n...x83\xa0\x88\x08\x08\xe8&\x85\x11!B\x13\xc4\x92\xaf\x9f\xe9\xa9\xb6\xba7\xd6[\xde\xba\xe7.\x9e$\r$ip&\xe5 K\x8a\x82'\n").returncode

test/test_cli.py:189: AssertionError

doing some more digging to see exactly whats failing. pyz's built from the built shiv package seem to work fine.

lorencarvalho commented 5 years ago

hey @Imaclean74

can you try to run the test with the [str(output_file)] changed to simply str(output_file)... a quick google seems to suggest that exit 2 with subprocess and shell=True implicates passing the command as a list. Not 100% sure though, I can't reproduce locally on any of my systems.

Imaclean74 commented 5 years ago

hi @lorencarvalho. So - strangely after git pulling the latest changes - pytest succeeds but tox -e py37 fails ( even after changing that line to str(output_file) ). From the stderr below it looks like something is going wrong in the bootstrap phase. It not the end of the world - since pushes to my fork / branch now build ok in travis CI - but it would be nice to have tox working locally as well. If I get some time tomorrow - I'll put a pdb.set_trace() in and have poke around the generated .pyz file. Or if the below output / trace gives you any ideas let me know.

>       assert proc.stdout.decode() == "hello world" + os.linesep
E       AssertionError: assert '' == 'hello world\n'
E         + hello world

../test_cli.py:123: AssertionError
------------------------------------------------- Captured stderr call -------------------------------------------------
/private/var/folders/x_/h517ndbj2qx9m6ydt_vtsrv00000gn/T/pytest-of-ianmaclean/pytest-4/test_hello_world___yes___compi0/tmpxh89tyv0/test.pyz: line 11: syntax error near unexpected token `('
/private/var/folders/x_/h517ndbj2qx9m6ydt_vtsrv00000gn/T/pytest-of-ianmaclean/pytest-4/test_hello_world___yes___compi0/tmpxh89tyv0/test.pyz: line 11: `IL�RH.06����K�M̫��P���N%Bj$&4site-packages/hello-0.0.0.dist-info/entry_points.txt�N��+��I�/N.�,()���H���W�U�V���y\\P���N 0:1site-packages/hello-0.0.0.dist-info/top_level.txt�H����P���N���-site-packages/hello-0.K-*��ϳR0�3��K�M�R�H����K�!WpinnbQ��B������G~n�nAbz*Bȱ�$#����������LN�+F���X��_���3�P���N�Ç�%%site-packages/hello/__init��Ԝ�|�����uM.PK���N site-packages/hello/__pycache__/P���Ne��S  u_bootstrap/__init__.py�X�o�~߿��=D�n����`�>���w8��a(\���Y���    ҿ��
�!}8����a�q�����z܁�j������7��H��8Z�\��MC��\���Zva7�e�ï�7�L3J��(>�3ʮH��4�i�=��w�VË�f�Ր���R$���Ba���ԛj&��lk�Z�jG�*�n�+!މ�ʧ^^���/ �)���)����k�ݪVdJU+����}=<�v<�*�҉~��� jʺ�xU�U�o�U=�  �WN�i�� �C��
                                                                            O0dP����ȁ?`6�߄Snڎ��r�r'u'^��C�Y�;�ߛiho�56jz��ɞu�[(
      ��{��=��蠣^�3��6�*y����+��Ձ��x�~Z�!OS��U?~��?~�}\�όn��?�T����>rC�W�M��r���o&kq���_F0�&$�6����ӁT/������Wܩ����xi�^����%^�ԵA��*�0z��l���S�������j���!B�s�%1m(����Cfq��3S�Y\�V�h3a�{�å�< -a'