Compose: pyrsistent 0.17.0 breaks python2 support

Created on 9 Sep 2020  路  13Comments  路  Source: docker/compose

Description of the issue

docker_compose python module doesn't work in python2 anymore

Context information (for bug reports)

not relevant

Output of docker-compose version

not relevant

Output of docker version

not relevant

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

not relevant

Steps to reproduce the issue

  1. pip install docker-compose
  2. Try to use ansible module docker_compose

Observed result

fails on command

Expected result

should not fail

Stacktrace / full error message

    /usr/local/lib/python2.7/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.
      from cryptography.hazmat.backends import default_backend
    Traceback (most recent call last):
      File "<stdin>", line 102, in <module>
      File "<stdin>", line 94, in _ansiballz_main
      File "<stdin>", line 40, in invoke_module
      File "/usr/lib/python2.7/runpy.py", line 188, in run_module
        fname, loader, pkg_name)
      File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
        mod_name, mod_fname, mod_loader, pkg_name)
      File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
        exec code in run_globals
      File "/tmp/ansible_docker_compose_payload_eqkS_O/ansible_docker_compose_payload.zip/ansible/modules/cloud/docker/docker_compose.py", line 483, in <module>
      File "/usr/local/lib/python2.7/dist-packages/compose/cli/command.py", line 11, in <module>
        from .. import config
      File "/usr/local/lib/python2.7/dist-packages/compose/config/__init__.py", line 6, in <module>
        from .config import ConfigurationError
      File "/usr/local/lib/python2.7/dist-packages/compose/config/config.py", line 51, in <module>
        from .validation import match_named_volumes
      File "/usr/local/lib/python2.7/dist-packages/compose/config/validation.py", line 12, in <module>
        from jsonschema import Draft4Validator
      File "/usr/local/lib/python2.7/dist-packages/jsonschema/__init__.py", line 21, in <module>
        from jsonschema._types import TypeChecker
      File "/usr/local/lib/python2.7/dist-packages/jsonschema/_types.py", line 3, in <module>
        from pyrsistent import pmap
      File "/usr/local/lib/python2.7/dist-packages/pyrsistent/__init__.py", line 3, in <module>
        from pyrsistent._pmap import pmap, m, PMap
      File "/usr/local/lib/python2.7/dist-packages/pyrsistent/_pmap.py", line 98
        ) from e
             ^
    SyntaxError: invalid syntax

Additional information

irrelevant

Possible solution: fix version of pyrsistent as 0.16.0 in requirements.txt

kinbug

All 13 comments

Hi @stas-sbi. Thanks for raising the issue, I forgot to add to the release notes for 1.27.0 that we dropped support for Python2.7.

@aiordache it would be better to populate the python_requires field in setup.py to make PyPi / pip know about this as well. The best solution would be to release a new patch version which implements this and yank the 1.27.0 release, i.e. same as in tobgu/pyrsistent#205.

The issue though is that older versions of compose are also broken now. Can we have a minor bump of 1.26.x which with still works python2? This would give us some time to upgrade.

@stas-sbi I'm sorry, but I'm afraid that a minor bump on 1.26.x won't be the way to go.

Actually the support for python 2.x was dropped quite a long time ago (since January 1st) from Python's side.
We also had a banner in the README.md promising the drop for 1.26.x and we actually dropped in 1.27.x

I see. Ubuntu supports python2 independently though until EOL of Ubuntu 18.04 if I recall correctly.

I'll try to find a work around then.

@stas-sbi the easiest way around this is to provide a constraints file when running pip, which restricts the version of pyrsistent for Python 2.7 only. (If you use the same file with Python 3, you'll still get the latest version.)

Apparently the latest incompatible version of pyrsistent was pushed to python2 repo. Not sure if they are going/can remove it. What I mean is that I try to install docker-compose using python2 I get 1.26.2 version of docker compose but 0.17.2 version of pyrsistent which cannot be installed.

As it's an indirect dependency, you can install a pinned version that supports py2 then try to install docker-compose

Yes, this is what I did. Good enough for now. Thanks.

Thanks for the report @stas-sbi !

same thing. any working solution?

Was this page helpful?
0 / 5 - 0 ratings